Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (9 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/wpUpdateTerm.php

    r39174 r42343  
    2121        public function test_wp_update_term_unslash_name() {
    2222                register_taxonomy( 'wptests_tax', 'post' );
    23                 $t = self::factory()->term->create( array(
    24                         'taxonomy' => 'wptests_tax',
    25                 ) );
    26 
    27                 $found = wp_update_term( $t, 'wptests_tax', array(
    28                         'name' => 'Let\\\'s all say \\"Hooray\\" for WordPress taxonomy',
    29                 ) );
     23                $t = self::factory()->term->create(
     24                        array(
     25                                'taxonomy' => 'wptests_tax',
     26                        )
     27                );
     28
     29                $found = wp_update_term(
     30                        $t, 'wptests_tax', array(
     31                                'name' => 'Let\\\'s all say \\"Hooray\\" for WordPress taxonomy',
     32                        )
     33                );
    3034
    3135                $term = get_term( $found['term_id'], 'wptests_tax' );
    … …  
    3741        public function test_wp_update_term_unslash_description() {
    3842                register_taxonomy( 'wptests_tax', 'post' );
    39                 $t = self::factory()->term->create( array(
    40                         'taxonomy' => 'wptests_tax',
    41                 ) );
    42 
    43                 $found = wp_update_term( $t, 'wptests_tax', array(
    44                         'description' => 'Let\\\'s all say \\"Hooray\\" for WordPress taxonomy',
    45                 ) );
     43                $t = self::factory()->term->create(
     44                        array(
     45                                'taxonomy' => 'wptests_tax',
     46                        )
     47                );
     48
     49                $found = wp_update_term(
     50                        $t, 'wptests_tax', array(
     51                                'description' => 'Let\\\'s all say \\"Hooray\\" for WordPress taxonomy',
     52                        )
     53                );
    4654
    4755                $term = get_term( $found['term_id'], 'wptests_tax' );
    … …  
    5361        public function test_wp_update_term_name_empty_string() {
    5462                register_taxonomy( 'wptests_tax', 'post' );
    55                 $t = self::factory()->term->create( array(
    56                         'taxonomy' => 'wptests_tax',
    57                 ) );
    58 
    59                 $found = wp_update_term( $t, 'wptests_tax', array(
    60                         'name' => '',
    61                 ) );
     63                $t = self::factory()->term->create(
     64                        array(
     65                                'taxonomy' => 'wptests_tax',
     66                        )
     67                );
     68
     69                $found = wp_update_term(
     70                        $t, 'wptests_tax', array(
     71                                'name' => '',
     72                        )
     73                );
    6274
    6375                $this->assertWPError( $found );
    … …  
    7082         */
    7183        function test_wp_update_term_parent_does_not_exist() {
    72                 register_taxonomy( 'wptests_tax', array(
    73                         'hierarchical' => true,
    74                 ) );
     84                register_taxonomy(
     85                        'wptests_tax', array(
     86                                'hierarchical' => true,
     87                        )
     88                );
    7589                $fake_term_id = 787878;
    7690
    7791                $this->assertNull( term_exists( $fake_term_id, 'wptests_tax' ) );
    7892
    79                 $t = self::factory()->term->create( array(
    80                         'taxonomy' => 'wptests_tax',
    81                 ) );
    82 
    83                 $found = wp_update_term( $t, 'wptests_tax', array(
    84                         'parent' => $fake_term_id,
    85                 ) );
     93                $t = self::factory()->term->create(
     94                        array(
     95                                'taxonomy' => 'wptests_tax',
     96                        )
     97                );
     98
     99                $found = wp_update_term(
     100                        $t, 'wptests_tax', array(
     101                                'parent' => $fake_term_id,
     102                        )
     103                );
    86104
    87105                $this->assertWPError( $found );
    … …  
    95113        public function test_wp_update_term_slug_empty_string_while_not_updating_name() {
    96114                register_taxonomy( 'wptests_tax', 'post' );
    97                 $t = self::factory()->term->create( array(
    98                         'taxonomy' => 'wptests_tax',
    99                         'name' => 'Foo Bar',
    100                 ) );
    101 
    102                 $found = wp_update_term( $t, 'wptests_tax', array(
    103                         'slug' => '',
    104                 ) );
     115                $t = self::factory()->term->create(
     116                        array(
     117                                'taxonomy' => 'wptests_tax',
     118                                'name'     => 'Foo Bar',
     119                        )
     120                );
     121
     122                $found = wp_update_term(
     123                        $t, 'wptests_tax', array(
     124                                'slug' => '',
     125                        )
     126                );
    105127
    106128                $term = get_term( $t, 'wptests_tax' );
    … …  
    111133        public function test_wp_update_term_slug_empty_string_while_updating_name() {
    112134                register_taxonomy( 'wptests_tax', 'post' );
    113                 $t = self::factory()->term->create( array(
    114                         'taxonomy' => 'wptests_tax',
    115                 ) );
    116 
    117                 $found = wp_update_term( $t, 'wptests_tax', array(
    118                         'name' => 'Foo Bar',
    119                         'slug' => '',
    120                 ) );
     135                $t = self::factory()->term->create(
     136                        array(
     137                                'taxonomy' => 'wptests_tax',
     138                        )
     139                );
     140
     141                $found = wp_update_term(
     142                        $t, 'wptests_tax', array(
     143                                'name' => 'Foo Bar',
     144                                'slug' => '',
     145                        )
     146                );
    121147
    122148                $term = get_term( $t, 'wptests_tax' );
    … …  
    127153        public function test_wp_update_term_slug_set_slug() {
    128154                register_taxonomy( 'wptests_tax', 'post' );
    129                 $t = self::factory()->term->create( array(
    130                         'taxonomy' => 'wptests_tax',
    131                 ) );
    132 
    133                 $found = wp_update_term( $t, 'wptests_tax', array(
    134                         'slug' => 'foo-bar',
    135                 ) );
     155                $t = self::factory()->term->create(
     156                        array(
     157                                'taxonomy' => 'wptests_tax',
     158                        )
     159                );
     160
     161                $found = wp_update_term(
     162                        $t, 'wptests_tax', array(
     163                                'slug' => 'foo-bar',
     164                        )
     165                );
    136166
    137167                $term = get_term( $t, 'wptests_tax' );
    … …  
    146176                register_taxonomy( 'wptests_tax', 'post' );
    147177
    148                 $t1 = self::factory()->term->create( array(
    149                         'name' => 'Foo',
    150                         'slug' => 'foo',
    151                         'taxonomy' => 'wptests_tax',
    152                 ) );
    153 
    154                 $t2 = self::factory()->term->create( array(
    155                         'name' => 'Bar',
    156                         'slug' => 'bar',
    157                         'taxonomy' => 'wptests_tax',
    158                 ) );
    159 
    160                 $updated = wp_update_term( $t2, 'wptests_tax', array(
    161                         'slug' => 'foo',
    162                 ) );
     178                $t1 = self::factory()->term->create(
     179                        array(
     180                                'name'     => 'Foo',
     181                                'slug'     => 'foo',
     182                                'taxonomy' => 'wptests_tax',
     183                        )
     184                );
     185
     186                $t2 = self::factory()->term->create(
     187                        array(
     188                                'name'     => 'Bar',
     189                                'slug'     => 'bar',
     190                                'taxonomy' => 'wptests_tax',
     191                        )
     192                );
     193
     194                $updated = wp_update_term(
     195                        $t2, 'wptests_tax', array(
     196                                'slug' => 'foo',
     197                        )
     198                );
    163199
    164200                $this->assertWPError( $updated );
    … …  
    173209                register_taxonomy( 'wptests_tax_2', 'post' );
    174210
    175                 $t1 = self::factory()->term->create( array(
    176                         'name' => 'Foo',
    177                         'slug' => 'foo',
    178                         'taxonomy' => 'wptests_tax',
    179                 ) );
    180 
    181                 $t2 = self::factory()->term->create( array(
    182                         'name' => 'Foo',
    183                         'slug' => 'bar',
    184                         'taxonomy' => 'wptests_tax_2',
    185                 ) );
    186 
    187                 $updated = wp_update_term( $t2, 'wptests_tax_2', array(
    188                         'slug' => 'foo',
    189                 ) );
     211                $t1 = self::factory()->term->create(
     212                        array(
     213                                'name'     => 'Foo',
     214                                'slug'     => 'foo',
     215                                'taxonomy' => 'wptests_tax',
     216                        )
     217                );
     218
     219                $t2 = self::factory()->term->create(
     220                        array(
     221                                'name'     => 'Foo',
     222                                'slug'     => 'bar',
     223                                'taxonomy' => 'wptests_tax_2',
     224                        )
     225                );
     226
     227                $updated = wp_update_term(
     228                        $t2, 'wptests_tax_2', array(
     229                                'slug' => 'foo',
     230                        )
     231                );
    190232
    191233                $this->assertNotWPError( $updated );
    … …  
    203245                register_taxonomy( 'wptests_tax_2', 'post' );
    204246
    205                 $t1 = self::factory()->term->create( array(
    206                         'name' => 'Foo',
    207                         'slug' => 'foo',
    208                         'taxonomy' => 'wptests_tax',
    209                 ) );
    210 
    211                 $t2 = self::factory()->term->create( array(
    212                         'name' => 'Bar',
    213                         'slug' => 'bar',
    214                         'taxonomy' => 'wptests_tax_2',
    215                 ) );
    216 
    217                 $updated = wp_update_term( $t2, 'wptests_tax_2', array(
    218                         'name' => 'Foo',
    219                 ) );
     247                $t1 = self::factory()->term->create(
     248                        array(
     249                                'name'     => 'Foo',
     250                                'slug'     => 'foo',
     251                                'taxonomy' => 'wptests_tax',
     252                        )
     253                );
     254
     255                $t2 = self::factory()->term->create(
     256                        array(
     257                                'name'     => 'Bar',
     258                                'slug'     => 'bar',
     259                                'taxonomy' => 'wptests_tax_2',
     260                        )
     261                );
     262
     263                $updated = wp_update_term(
     264                        $t2, 'wptests_tax_2', array(
     265                                'name' => 'Foo',
     266                        )
     267                );
    220268
    221269                $this->assertNotWPError( $updated );
    … …  
    229277         */
    230278        public function test_wp_update_term_should_allow_duplicate_names_at_different_levels_of_the_same_taxonomy() {
    231                 register_taxonomy( 'wptests_tax', 'post', array(
    232                         'hierarchical' => true,
    233                 ) );
    234 
    235                 $t1 = self::factory()->term->create( array(
    236                         'name' => 'Foo',
    237                         'slug' => 'foo',
    238                         'taxonomy' => 'wptests_tax',
    239                 ) );
    240 
    241                 $t2 = self::factory()->term->create( array(
    242                         'name' => 'Bar',
    243                         'slug' => 'bar',
    244                         'taxonomy' => 'wptests_tax',
    245                         'parent' => $t1,
    246                 ) );
    247 
    248                 $t3 = self::factory()->term->create( array(
    249                         'name' => 'Bar Child',
    250                         'slug' => 'bar-child',
    251                         'taxonomy' => 'wptests_tax',
    252                         'parent' => $t2,
    253                 ) );
    254 
    255                 $updated = wp_update_term( $t3, 'wptests_tax', array(
    256                         'name' => 'Bar',
    257                 ) );
     279                register_taxonomy(
     280                        'wptests_tax', 'post', array(
     281                                'hierarchical' => true,
     282                        )
     283                );
     284
     285                $t1 = self::factory()->term->create(
     286                        array(
     287                                'name'     => 'Foo',
     288                                'slug'     => 'foo',
     289                                'taxonomy' => 'wptests_tax',
     290                        )
     291                );
     292
     293                $t2 = self::factory()->term->create(
     294                        array(
     295                                'name'     => 'Bar',
     296                                'slug'     => 'bar',
     297                                'taxonomy' => 'wptests_tax',
     298                                'parent'   => $t1,
     299                        )
     300                );
     301
     302                $t3 = self::factory()->term->create(
     303                        array(
     304                                'name'     => 'Bar Child',
     305                                'slug'     => 'bar-child',
     306                                'taxonomy' => 'wptests_tax',
     307                                'parent'   => $t2,
     308                        )
     309                );
     310
     311                $updated = wp_update_term(
     312                        $t3, 'wptests_tax', array(
     313                                'name' => 'Bar',
     314                        )
     315                );
    258316
    259317                $this->assertNotWPError( $updated );
    … …  
    276334
    277335                // Manually modify because shared terms shouldn't naturally occur.
    278                 $wpdb->update( $wpdb->term_taxonomy,
     336                $wpdb->update(
     337                        $wpdb->term_taxonomy,
    279338                        array( 'term_id' => $t1['term_id'] ),
    280339                        array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ),
    … …  
    292351                $this->assertSame( $t1_terms[0]->term_id, $t2_terms[0]->term_id );
    293352
    294                 wp_update_term( $t2_terms[0]->term_id, 'wptests_tax_2', array(
    295                         'name' => 'New Foo',
    296                 ) );
     353                wp_update_term(
     354                        $t2_terms[0]->term_id, 'wptests_tax_2', array(
     355                                'name' => 'New Foo',
     356                        )
     357                );
    297358
    298359                $t1_terms = wp_get_object_terms( $posts[0], 'wptests_tax' );
    … …  
    303364        public function test_wp_update_term_alias_of_no_term_group() {
    304365                register_taxonomy( 'wptests_tax', 'post' );
    305                 $t1 = self::factory()->term->create( array(
    306                         'taxonomy' => 'wptests_tax',
    307                 ) );
     366                $t1     = self::factory()->term->create(
     367                        array(
     368                                'taxonomy' => 'wptests_tax',
     369                        )
     370                );
    308371                $term_1 = get_term( $t1, 'wptests_tax' );
    309372
    310373                $created_term_ids = wp_insert_term( 'Foo', 'wptests_tax' );
    311                 wp_update_term( $created_term_ids['term_id'], 'wptests_tax', array(
    312                         'alias_of' => $term_1->slug,
    313                 ) );
     374                wp_update_term(
     375                        $created_term_ids['term_id'], 'wptests_tax', array(
     376                                'alias_of' => $term_1->slug,
     377                        )
     378                );
    314379                $created_term = get_term( $created_term_ids['term_id'], 'wptests_tax' );
    315380
    … …  
    324389        public function test_wp_update_term_alias_of_existing_term_group() {
    325390                register_taxonomy( 'wptests_tax', 'post' );
    326                 $t1 = self::factory()->term->create( array(
    327                         'taxonomy' => 'wptests_tax',
    328                 ) );
     391                $t1     = self::factory()->term->create(
     392                        array(
     393                                'taxonomy' => 'wptests_tax',
     394                        )
     395                );
    329396                $term_1 = get_term( $t1, 'wptests_tax' );
    330397
    331                 $t2 = self::factory()->term->create( array(
    332                         'taxonomy' => 'wptests_tax',
    333                         'alias_of' => $term_1->slug,
    334                 ) );
     398                $t2     = self::factory()->term->create(
     399                        array(
     400                                'taxonomy' => 'wptests_tax',
     401                                'alias_of' => $term_1->slug,
     402                        )
     403                );
    335404                $term_2 = get_term( $t2, 'wptests_tax' );
    336405
    337406                $created_term_ids = wp_insert_term( 'Foo', 'wptests_tax' );
    338                 wp_update_term( $created_term_ids['term_id'], 'wptests_tax', array(
    339                         'alias_of' => $term_2->slug,
    340                 ) );
     407                wp_update_term(
     408                        $created_term_ids['term_id'], 'wptests_tax', array(
     409                                'alias_of' => $term_2->slug,
     410                        )
     411                );
    341412                $created_term = get_term( $created_term_ids['term_id'], 'wptests_tax' );
    342413                _unregister_taxonomy( 'wptests_tax' );
    … …  
    349420                register_taxonomy( 'wptests_tax', 'post' );
    350421                $created_term_ids = wp_insert_term( 'Foo', 'wptests_tax' );
    351                 wp_update_term( $created_term_ids['term_id'], 'wptests_tax', array(
    352                         'alias_of' => 'bar',
    353                 ) );
     422                wp_update_term(
     423                        $created_term_ids['term_id'], 'wptests_tax', array(
     424                                'alias_of' => 'bar',
     425                        )
     426                );
    354427                $created_term = get_term( $created_term_ids['term_id'], 'wptests_tax' );
    355428                _unregister_taxonomy( 'wptests_tax' );
    … …  
    360433        public function test_wp_update_term_slug_same_as_old_slug() {
    361434                register_taxonomy( 'wptests_tax', 'post' );
    362                 $t = self::factory()->term->create( array(
    363                         'taxonomy' => 'wptests_tax',
    364                         'slug' => 'foo',
    365                 ) );
    366 
    367                 $found = wp_update_term( $t, 'wptests_tax', array(
    368                         'slug' => 'foo',
    369                 ) );
     435                $t = self::factory()->term->create(
     436                        array(
     437                                'taxonomy' => 'wptests_tax',
     438                                'slug'     => 'foo',
     439                        )
     440                );
     441
     442                $found = wp_update_term(
     443                        $t, 'wptests_tax', array(
     444                                'slug' => 'foo',
     445                        )
     446                );
    370447
    371448                $term = get_term( $t, 'wptests_tax' );
    … …  
    378455        public function test_wp_update_term_duplicate_slug_generated_due_to_empty_slug_param() {
    379456                register_taxonomy( 'wptests_tax', 'post' );
    380                 $t1 = self::factory()->term->create( array(
    381                         'taxonomy' => 'wptests_tax',
    382                         'slug' => 'foo-bar',
    383                 ) );
    384                 $t2 = self::factory()->term->create( array(
    385                         'taxonomy' => 'wptests_tax',
    386                         'name' => 'not foo bar',
    387                 ) );
    388 
    389                 $found = wp_update_term( $t2, 'wptests_tax', array(
    390                         'slug' => '',
    391                         'name' => 'Foo? Bar!', // Will sanitize to 'foo-bar'.
    392                 ) );
     457                $t1 = self::factory()->term->create(
     458                        array(
     459                                'taxonomy' => 'wptests_tax',
     460                                'slug'     => 'foo-bar',
     461                        )
     462                );
     463                $t2 = self::factory()->term->create(
     464                        array(
     465                                'taxonomy' => 'wptests_tax',
     466                                'name'     => 'not foo bar',
     467                        )
     468                );
     469
     470                $found = wp_update_term(
     471                        $t2, 'wptests_tax', array(
     472                                'slug' => '',
     473                                'name' => 'Foo? Bar!', // Will sanitize to 'foo-bar'.
     474                        )
     475                );
    393476
    394477                $term = get_term( $t2, 'wptests_tax' );
    … …  
    400483
    401484        public function test_wp_update_term_duplicate_slug_with_changed_parent() {
    402                 register_taxonomy( 'wptests_tax', 'post', array(
    403                         'hierarchical' => true,
    404                 ) );
    405                 $p = self::factory()->term->create( array(
    406                         'taxonomy' => 'wptests_tax',
    407                 ) );
    408                 $t1 = self::factory()->term->create( array(
    409                         'taxonomy' => 'wptests_tax',
    410                         'slug' => 'foo-bar',
    411                 ) );
    412                 $t2 = self::factory()->term->create( array(
    413                         'taxonomy' => 'wptests_tax',
    414                 ) );
    415 
    416                 $found = wp_update_term( $t2, 'wptests_tax', array(
    417                         'parent' => $p,
    418                         'slug' => 'foo-bar',
    419                 ) );
    420 
    421                 $term = get_term( $t2, 'wptests_tax' );
     485                register_taxonomy(
     486                        'wptests_tax', 'post', array(
     487                                'hierarchical' => true,
     488                        )
     489                );
     490                $p  = self::factory()->term->create(
     491                        array(
     492                                'taxonomy' => 'wptests_tax',
     493                        )
     494                );
     495                $t1 = self::factory()->term->create(
     496                        array(
     497                                'taxonomy' => 'wptests_tax',
     498                                'slug'     => 'foo-bar',
     499                        )
     500                );
     501                $t2 = self::factory()->term->create(
     502                        array(
     503                                'taxonomy' => 'wptests_tax',
     504                        )
     505                );
     506
     507                $found = wp_update_term(
     508                        $t2, 'wptests_tax', array(
     509                                'parent' => $p,
     510                                'slug'   => 'foo-bar',
     511                        )
     512                );
     513
     514                $term        = get_term( $t2, 'wptests_tax' );
    422515                $parent_term = get_term( $p, 'wptests_tax' );
    423516
    … …  
    429522        public function test_wp_update_term_duplicate_slug_failure() {
    430523                register_taxonomy( 'wptests_tax', 'post' );
    431                 $t1 = self::factory()->term->create( array(
    432                         'taxonomy' => 'wptests_tax',
    433                         'slug' => 'foo-bar',
    434                 ) );
    435                 $t2 = self::factory()->term->create( array(
    436                         'taxonomy' => 'wptests_tax',
    437                         'slug' => 'my-old-slug',
    438                 ) );
    439 
    440                 $found = wp_update_term( $t2, 'wptests_tax', array(
    441                         'slug' => 'foo-bar',
    442                 ) );
     524                $t1 = self::factory()->term->create(
     525                        array(
     526                                'taxonomy' => 'wptests_tax',
     527                                'slug'     => 'foo-bar',
     528                        )
     529                );
     530                $t2 = self::factory()->term->create(
     531                        array(
     532                                'taxonomy' => 'wptests_tax',
     533                                'slug'     => 'my-old-slug',
     534                        )
     535                );
     536
     537                $found = wp_update_term(
     538                        $t2, 'wptests_tax', array(
     539                                'slug' => 'foo-bar',
     540                        )
     541                );
    443542
    444543                $term = get_term( $t2, 'wptests_tax' );
    … …  
    452551        public function test_wp_update_term_should_return_term_id_and_term_taxonomy_id() {
    453552                register_taxonomy( 'wptests_tax', 'post' );
    454                 $t = self::factory()->term->create( array(
    455                         'taxonomy' => 'wptests_tax',
    456                 ) );
    457                 $found = wp_update_term( $t, 'wptests_tax', array(
    458                         'slug' => 'foo',
    459                 ) );
    460 
    461                 $term_by_id = get_term( $found['term_id'], 'wptests_tax' );
     553                $t     = self::factory()->term->create(
     554                        array(
     555                                'taxonomy' => 'wptests_tax',
     556                        )
     557                );
     558                $found = wp_update_term(
     559                        $t, 'wptests_tax', array(
     560                                'slug' => 'foo',
     561                        )
     562                );
     563
     564                $term_by_id   = get_term( $found['term_id'], 'wptests_tax' );
    462565                $term_by_slug = get_term_by( 'slug', 'foo', 'wptests_tax' );
    463566                $term_by_ttid = get_term_by( 'term_taxonomy_id', $found['term_taxonomy_id'], 'wptests_tax' );
    … …  
    478581        public function test_wp_update_term_should_return_int_values_for_term_id_and_term_taxonomy_id() {
    479582                register_taxonomy( 'wptests_tax', 'post' );
    480                 $t = self::factory()->term->create( array(
    481                         'taxonomy' => 'wptests_tax',
    482                 ) );
    483                 $found = wp_update_term( $t, 'wptests_tax', array(
    484                         'slug' => 'foo',
    485                 ) );
     583                $t     = self::factory()->term->create(
     584                        array(
     585                                'taxonomy' => 'wptests_tax',
     586                        )
     587                );
     588                $found = wp_update_term(
     589                        $t, 'wptests_tax', array(
     590                                'slug' => 'foo',
     591                        )
     592                );
    486593
    487594                $this->assertInternalType( 'int', $found['term_id'] );
    … …  
    490597
    491598        public function test_wp_update_term_should_clean_term_cache() {
    492                 register_taxonomy( 'wptests_tax', 'post', array(
    493                         'hierarchical' => true,
    494                 ) );
    495 
    496                 $t1 = self::factory()->term->create( array(
    497                         'taxonomy' => 'wptests_tax',
    498                 ) );
    499                 $t2 = self::factory()->term->create( array(
    500                         'taxonomy' => 'wptests_tax',
    501                 ) );
     599                register_taxonomy(
     600                        'wptests_tax', 'post', array(
     601                                'hierarchical' => true,
     602                        )
     603                );
     604
     605                $t1 = self::factory()->term->create(
     606                        array(
     607                                'taxonomy' => 'wptests_tax',
     608                        )
     609                );
     610                $t2 = self::factory()->term->create(
     611                        array(
     612                                'taxonomy' => 'wptests_tax',
     613                        )
     614                );
    502615
    503616                /*
    … …  
    510623                wp_cache_set( 'get', array( 1, 2, 3 ), 'wptests_tax' );
    511624
    512                 $found = wp_update_term( $t1, 'wptests_tax', array(
    513                         'parent' => $t2,
    514                 ) );
     625                $found = wp_update_term(
     626                        $t1, 'wptests_tax', array(
     627                                'parent' => $t2,
     628                        )
     629                );
    515630                _unregister_taxonomy( 'wptests_tax' );
    516631
    … …  
    527642         */
    528643        public function test_wp_update_term_should_assign_new_slug_when_reassigning_parent_as_long_as_there_is_no_other_term_with_the_same_slug() {
    529                 register_taxonomy( 'wptests_tax', 'post', array(
    530                         'hierarchical' => true,
    531                 ) );
    532                 register_taxonomy( 'wptests_tax_2', 'post', array(
    533                         'hierarchical' => true,
    534                 ) );
    535 
    536                 $t1 = self::factory()->term->create( array(
    537                         'taxonomy' => 'wptests_tax',
    538                         'slug' => 'parent-term',
    539                 ) );
    540 
    541                 $t2 = self::factory()->term->create( array(
    542                         'taxonomy' => 'wptests_tax',
    543                         'slug' => 'foo',
    544                 ) );
    545 
    546                 wp_update_term( $t2, 'wptests_tax', array(
    547                         'parent' => $t1,
    548                 ) );
     644                register_taxonomy(
     645                        'wptests_tax', 'post', array(
     646                                'hierarchical' => true,
     647                        )
     648                );
     649                register_taxonomy(
     650                        'wptests_tax_2', 'post', array(
     651                                'hierarchical' => true,
     652                        )
     653                );
     654
     655                $t1 = self::factory()->term->create(
     656                        array(
     657                                'taxonomy' => 'wptests_tax',
     658                                'slug'     => 'parent-term',
     659                        )
     660                );
     661
     662                $t2 = self::factory()->term->create(
     663                        array(
     664                                'taxonomy' => 'wptests_tax',
     665                                'slug'     => 'foo',
     666                        )
     667                );
     668
     669                wp_update_term(
     670                        $t2, 'wptests_tax', array(
     671                                'parent' => $t1,
     672                        )
     673                );
    549674
    550675                $t2_term = get_term( $t2, 'wptests_tax' );
    … …  
    559684         */
    560685        public function test_wp_update_term_should_not_assign_new_slug_when_reassigning_parent_as_long_as_there_is_no_other_slug_conflict_within_the_taxonomy() {
    561                 register_taxonomy( 'wptests_tax', 'post', array(
    562                         'hierarchical' => true,
    563                 ) );
    564                 register_taxonomy( 'wptests_tax_2', 'post', array(
    565                         'hierarchical' => true,
    566                 ) );
    567 
    568                 $t1 = self::factory()->term->create( array(
    569                         'taxonomy' => 'wptests_tax',
    570                         'slug' => 'parent-term',
    571                 ) );
     686                register_taxonomy(
     687                        'wptests_tax', 'post', array(
     688                                'hierarchical' => true,
     689                        )
     690                );
     691                register_taxonomy(
     692                        'wptests_tax_2', 'post', array(
     693                                'hierarchical' => true,
     694                        )
     695                );
     696
     697                $t1 = self::factory()->term->create(
     698                        array(
     699                                'taxonomy' => 'wptests_tax',
     700                                'slug'     => 'parent-term',
     701                        )
     702                );
    572703
    573704                // Same slug but in a different tax.
    574                 $t2 = self::factory()->term->create( array(
    575                         'taxonomy' => 'wptests_tax_2',
    576                         'slug' => 'foo',
    577                 ) );
    578 
    579                 $t3 = self::factory()->term->create( array(
    580                         'taxonomy' => 'wptests_tax',
    581                         'slug' => 'foo',
    582                 ) );
    583 
    584                 wp_update_term( $t3, 'wptests_tax', array(
    585                         'parent' => $t1,
    586                 ) );
     705                $t2 = self::factory()->term->create(
     706                        array(
     707                                'taxonomy' => 'wptests_tax_2',
     708                                'slug'     => 'foo',
     709                        )
     710                );
     711
     712                $t3 = self::factory()->term->create(
     713                        array(
     714                                'taxonomy' => 'wptests_tax',
     715                                'slug'     => 'foo',
     716                        )
     717                );
     718
     719                wp_update_term(
     720                        $t3, 'wptests_tax', array(
     721                                'parent' => $t1,
     722                        )
     723                );
    587724
    588725                $t3_term = get_term( $t3, 'wptests_tax' );
    … …  
    597734         */
    598735        public function test_wp_update_term_with_null_get_term() {
    599                 $t = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
     736                $t     = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
    600737                $found = wp_update_term( $t, 'post_tag', array( 'slug' => 'foo' ) );
    601738
Note: See TracChangeset for help on using the changeset viewer.