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/getTerms.php

    r40293 r42343  
    2727                wp_set_post_terms( $post, array( $term1, $term2 ), 'wptests_tax' );
    2828
    29                 $found = get_terms( array(
    30                         'meta_key' => 'somekey',
    31                         'meta_value' => 'thevalue',
    32                 ) );
     29                $found = get_terms(
     30                        array(
     31                                'meta_key'   => 'somekey',
     32                                'meta_value' => 'thevalue',
     33                        )
     34                );
    3335
    3436                $this->assertEqualSets( array( $term1 ), wp_list_pluck( $found, 'term_id' ) );
     
    4244                $term = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    4345
    44                 $found = get_terms( array(
    45                         'taxonomy' => 'wptests_tax',
    46                         'hide_empty' => false,
    47                         'fields' => 'ids',
    48                         'update_term_meta_cache' => false,
    49                 ) );
     46                $found = get_terms(
     47                        array(
     48                                'taxonomy'               => 'wptests_tax',
     49                                'hide_empty'             => false,
     50                                'fields'                 => 'ids',
     51                                'update_term_meta_cache' => false,
     52                        )
     53                );
    5054
    5155                $this->assertEqualSets( array( $term ), $found );
     
    8791                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    8892
    89                 $found = get_terms( array(
    90                         'hide_empty' => false,
    91                         'fields' => 'ids',
    92                         'update_term_meta_cache' => false,
    93                 ) );
     93                $found = get_terms(
     94                        array(
     95                                'hide_empty'             => false,
     96                                'fields'                 => 'ids',
     97                                'update_term_meta_cache' => false,
     98                        )
     99                );
    94100
    95101                // There may be other terms lying around, so don't do an exact match.
     
    133139
    134140                // Prime cache
    135                 $terms = get_terms( 'post_tag' );
    136                 $time1 = wp_cache_get( 'last_changed', 'terms' );
     141                $terms       = get_terms( 'post_tag' );
     142                $time1       = wp_cache_get( 'last_changed', 'terms' );
    137143                $num_queries = $wpdb->num_queries;
    138144
     
    161167
    162168                // Prime cache
    163                 $terms = get_terms( 'post_tag' );
    164                 $time1 = wp_cache_get( 'last_changed', 'terms' );
     169                $terms       = get_terms( 'post_tag' );
     170                $time1       = wp_cache_get( 'last_changed', 'terms' );
    165171                $num_queries = $wpdb->num_queries;
    166172
     
    168174                wp_delete_term( $terms[0]->term_id, 'post_tag' );
    169175
    170                 $num_queries = $wpdb->num_queries;
     176                $num_queries                           = $wpdb->num_queries;
    171177                $this->assertNotEquals( $time1, $time2 = wp_cache_get( 'last_changed', 'terms' ) );
    172178
     
    193199        function test_get_terms_should_allow_arbitrary_indexed_taxonomies_array() {
    194200                $term_id = self::factory()->tag->create();
    195                 $terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) );
     201                $terms   = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) );
    196202                $this->assertEquals( $term_id, reset( $terms )->term_id );
    197203        }
     
    201207         */
    202208        function test_get_terms_fields() {
    203                 $term_id1 = self::factory()->tag->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
    204                 $term_id2 = self::factory()->tag->create( array( 'slug' => 'hoo', 'name' => 'HOO!', 'parent' => $term_id1 ) );
    205 
    206                 $terms_id_parent = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
    207                 $this->assertEquals( array(
    208                         $term_id1 => 0,
    209                         $term_id2 => $term_id1
    210                 ), $terms_id_parent );
    211 
    212                 $terms_ids = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'ids' ) );
     209                $term_id1 = self::factory()->tag->create(
     210                        array(
     211                                'slug' => 'woo',
     212                                'name' => 'WOO!',
     213                        )
     214                );
     215                $term_id2 = self::factory()->tag->create(
     216                        array(
     217                                'slug'   => 'hoo',
     218                                'name'   => 'HOO!',
     219                                'parent' => $term_id1,
     220                        )
     221                );
     222
     223                $terms_id_parent = get_terms(
     224                        'post_tag', array(
     225                                'hide_empty' => false,
     226                                'fields'     => 'id=>parent',
     227                        )
     228                );
     229                $this->assertEquals(
     230                        array(
     231                                $term_id1 => 0,
     232                                $term_id2 => $term_id1,
     233                        ), $terms_id_parent
     234                );
     235
     236                $terms_ids = get_terms(
     237                        'post_tag', array(
     238                                'hide_empty' => false,
     239                                'fields'     => 'ids',
     240                        )
     241                );
    213242                $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms_ids );
    214243
    215                 $terms_name = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'names' ) );
     244                $terms_name = get_terms(
     245                        'post_tag', array(
     246                                'hide_empty' => false,
     247                                'fields'     => 'names',
     248                        )
     249                );
    216250                $this->assertEqualSets( array( 'WOO!', 'HOO!' ), $terms_name );
    217251
    218                 $terms_id_name = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'id=>name' ) );
    219                 $this->assertEquals( array(
    220                         $term_id1 => 'WOO!',
    221                         $term_id2 => 'HOO!',
    222                 ), $terms_id_name );
    223 
    224                 $terms_id_slug = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'id=>slug' ) );
    225                 $this->assertEquals( array(
    226                         $term_id1 => 'woo',
    227                         $term_id2 => 'hoo'
    228                 ), $terms_id_slug );
    229         }
    230 
    231         /**
     252                $terms_id_name = get_terms(
     253                        'post_tag', array(
     254                                'hide_empty' => false,
     255                                'fields'     => 'id=>name',
     256                        )
     257                );
     258                $this->assertEquals(
     259                        array(
     260                                $term_id1 => 'WOO!',
     261                                $term_id2 => 'HOO!',
     262                        ), $terms_id_name
     263                );
     264
     265                $terms_id_slug = get_terms(
     266                        'post_tag', array(
     267                                'hide_empty' => false,
     268                                'fields'     => 'id=>slug',
     269                        )
     270                );
     271                $this->assertEquals(
     272                        array(
     273                                $term_id1 => 'woo',
     274                                $term_id2 => 'hoo',
     275                        ), $terms_id_slug
     276                );
     277        }
     278
     279        /**
    232280         * @ticket 11823
    233          */
     281         */
    234282        function test_get_terms_include_exclude() {
    235283                global $wpdb;
    236284
    237                 $term_id1 = self::factory()->tag->create();
    238                 $term_id2 = self::factory()->tag->create();
    239                 $inc_terms = get_terms( 'post_tag', array(
    240                         'include' => array( $term_id1, $term_id2 ),
    241                         'hide_empty' => false
    242                 ) );
     285                $term_id1  = self::factory()->tag->create();
     286                $term_id2  = self::factory()->tag->create();
     287                $inc_terms = get_terms(
     288                        'post_tag', array(
     289                                'include'    => array( $term_id1, $term_id2 ),
     290                                'hide_empty' => false,
     291                        )
     292                );
    243293                $this->assertEquals( array( $term_id1, $term_id2 ), wp_list_pluck( $inc_terms, 'term_id' ) );
    244294
    245                 $exc_terms = get_terms( 'post_tag', array(
    246                         'exclude' => array( $term_id1, $term_id2 ),
    247                         'hide_empty' => false
    248                 ) );
     295                $exc_terms = get_terms(
     296                        'post_tag', array(
     297                                'exclude'    => array( $term_id1, $term_id2 ),
     298                                'hide_empty' => false,
     299                        )
     300                );
    249301                $this->assertEquals( array(), wp_list_pluck( $exc_terms, 'term_id' ) );
    250302
    251303                // These should not generate query errors.
    252                 get_terms( 'post_tag', array( 'exclude' => array( 0 ), 'hide_empty' => false ) );
     304                get_terms(
     305                        'post_tag', array(
     306                                'exclude'    => array( 0 ),
     307                                'hide_empty' => false,
     308                        )
     309                );
    253310                $this->assertEmpty( $wpdb->last_error );
    254311
    255                 get_terms( 'post_tag', array( 'exclude' => array( 'unexpected-string' ), 'hide_empty' => false ) );
     312                get_terms(
     313                        'post_tag', array(
     314                                'exclude'    => array( 'unexpected-string' ),
     315                                'hide_empty' => false,
     316                        )
     317                );
    256318                $this->assertEmpty( $wpdb->last_error );
    257319
    258                 get_terms( 'post_tag', array( 'include' => array( 'unexpected-string' ), 'hide_empty' => false ) );
     320                get_terms(
     321                        'post_tag', array(
     322                                'include'    => array( 'unexpected-string' ),
     323                                'hide_empty' => false,
     324                        )
     325                );
    259326                $this->assertEmpty( $wpdb->last_error );
    260327        }
     
    266333                register_taxonomy( 'wptests_tax', 'post' );
    267334
    268                 $terms = self::factory()->term->create_many( 2, array(
    269                         'taxonomy' => 'wptests_tax',
    270                 ) );
    271 
    272                 $found = get_terms( 'wptests_tax', array(
    273                         'taxonomy' => 'wptests_tax',
    274                         'hide_empty' => false,
    275                         'exclude_tree' => array( $terms[0] ),
    276                         'hierarchical' => true,
    277                 ) );
     335                $terms = self::factory()->term->create_many(
     336                        2, array(
     337                                'taxonomy' => 'wptests_tax',
     338                        )
     339                );
     340
     341                $found = get_terms(
     342                        'wptests_tax', array(
     343                                'taxonomy'     => 'wptests_tax',
     344                                'hide_empty'   => false,
     345                                'exclude_tree' => array( $terms[0] ),
     346                                'hierarchical' => true,
     347                        )
     348                );
    278349
    279350                $this->assertEquals( array( $terms[1] ), wp_list_pluck( $found, 'term_id' ) );
     
    289360                $term_id_uncategorized = get_option( 'default_category' );
    290361
    291                 $term_id1 = self::factory()->category->create();
     362                $term_id1  = self::factory()->category->create();
    292363                $term_id11 = self::factory()->category->create( array( 'parent' => $term_id1 ) );
    293                 $term_id2 = self::factory()->category->create();
     364                $term_id2  = self::factory()->category->create();
    294365                $term_id22 = self::factory()->category->create( array( 'parent' => $term_id2 ) );
    295366
    296                 $terms = get_terms( 'category', array(
    297                         'exclude' => $term_id_uncategorized,
    298                         'fields' => 'ids',
    299                         'hide_empty' => false,
    300                 ) );
     367                $terms = get_terms(
     368                        'category', array(
     369                                'exclude'    => $term_id_uncategorized,
     370                                'fields'     => 'ids',
     371                                'hide_empty' => false,
     372                        )
     373                );
    301374                $this->assertEquals( array( $term_id1, $term_id11, $term_id2, $term_id22 ), $terms );
    302375
    303                 $terms = get_terms( 'category', array(
    304                         'fields' => 'ids',
    305                         'exclude_tree' => "$term_id1,$term_id_uncategorized",
    306                         'hide_empty' => false,
    307                 ) );
     376                $terms = get_terms(
     377                        'category', array(
     378                                'fields'       => 'ids',
     379                                'exclude_tree' => "$term_id1,$term_id_uncategorized",
     380                                'hide_empty'   => false,
     381                        )
     382                );
    308383
    309384                $this->assertEquals( array( $term_id2, $term_id22 ), $terms );
     
    319394                $term_id3 = self::factory()->tag->create( array( 'name' => 'Foo' ) );
    320395
    321                 $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'search' => 'bur', 'fields' => 'ids' ) );
     396                $terms = get_terms(
     397                        'post_tag', array(
     398                                'hide_empty' => false,
     399                                'search'     => 'bur',
     400                                'fields'     => 'ids',
     401                        )
     402                );
    322403                $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms );
    323404        }
     
    327408         */
    328409        function test_get_terms_like() {
    329                 $term_id1 = self::factory()->tag->create( array( 'name' => 'burrito', 'description' => 'This is a burrito.' ) );
    330                 $term_id2 = self::factory()->tag->create( array( 'name' => 'taco', 'description' => 'Burning man.' ) );
    331 
    332                 $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'name__like' => 'bur', 'fields' => 'ids' ) );
     410                $term_id1 = self::factory()->tag->create(
     411                        array(
     412                                'name'        => 'burrito',
     413                                'description' => 'This is a burrito.',
     414                        )
     415                );
     416                $term_id2 = self::factory()->tag->create(
     417                        array(
     418                                'name'        => 'taco',
     419                                'description' => 'Burning man.',
     420                        )
     421                );
     422
     423                $terms = get_terms(
     424                        'post_tag', array(
     425                                'hide_empty' => false,
     426                                'name__like' => 'bur',
     427                                'fields'     => 'ids',
     428                        )
     429                );
    333430                $this->assertEqualSets( array( $term_id1 ), $terms );
    334431
    335                 $terms2 = get_terms( 'post_tag', array( 'hide_empty' => false, 'description__like' => 'bur', 'fields' => 'ids' ) );
     432                $terms2 = get_terms(
     433                        'post_tag', array(
     434                                'hide_empty'        => false,
     435                                'description__like' => 'bur',
     436                                'fields'            => 'ids',
     437                        )
     438                );
    336439                $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms2 );
    337440
    338                 $terms3 = get_terms( 'post_tag', array( 'hide_empty' => false, 'name__like' => 'Bur', 'fields' => 'ids' ) );
     441                $terms3 = get_terms(
     442                        'post_tag', array(
     443                                'hide_empty' => false,
     444                                'name__like' => 'Bur',
     445                                'fields'     => 'ids',
     446                        )
     447                );
    339448                $this->assertEqualSets( array( $term_id1 ), $terms3 );
    340449
    341                 $terms4 = get_terms( 'post_tag', array( 'hide_empty' => false, 'description__like' => 'Bur', 'fields' => 'ids' ) );
     450                $terms4 = get_terms(
     451                        'post_tag', array(
     452                                'hide_empty'        => false,
     453                                'description__like' => 'Bur',
     454                                'fields'            => 'ids',
     455                        )
     456                );
    342457                $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms4 );
    343458
    344                 $terms5 = get_terms( 'post_tag', array( 'hide_empty' => false, 'name__like' => 'ENCHILADA', 'fields' => 'ids' ) );
     459                $terms5 = get_terms(
     460                        'post_tag', array(
     461                                'hide_empty' => false,
     462                                'name__like' => 'ENCHILADA',
     463                                'fields'     => 'ids',
     464                        )
     465                );
    345466                $this->assertEmpty( $terms5 );
    346467
    347                 $terms6 = get_terms( 'post_tag', array( 'hide_empty' => false, 'description__like' => 'ENCHILADA', 'fields' => 'ids' ) );
     468                $terms6 = get_terms(
     469                        'post_tag', array(
     470                                'hide_empty'        => false,
     471                                'description__like' => 'ENCHILADA',
     472                                'fields'            => 'ids',
     473                        )
     474                );
    348475                $this->assertEmpty( $terms6 );
    349476
    350                 $terms7 = get_terms( 'post_tag', array( 'hide_empty' => false, 'name__like' => 'o', 'fields' => 'ids' ) );
     477                $terms7 = get_terms(
     478                        'post_tag', array(
     479                                'hide_empty' => false,
     480                                'name__like' => 'o',
     481                                'fields'     => 'ids',
     482                        )
     483                );
    351484                $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms7 );
    352485
    353                 $terms8 = get_terms( 'post_tag', array( 'hide_empty' => false, 'description__like' => '.', 'fields' => 'ids' ) );
     486                $terms8 = get_terms(
     487                        'post_tag', array(
     488                                'hide_empty'        => false,
     489                                'description__like' => '.',
     490                                'fields'            => 'ids',
     491                        )
     492                );
    354493                $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms8 );
    355494        }
     
    362501                register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    363502
    364                 $cheese = self::factory()->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) );
    365 
    366                 $cheddar = self::factory()->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) );
     503                $cheese = self::factory()->term->create(
     504                        array(
     505                                'name'     => 'Cheese',
     506                                'taxonomy' => $tax,
     507                        )
     508                );
     509
     510                $cheddar = self::factory()->term->create(
     511                        array(
     512                                'name'     => 'Cheddar',
     513                                'parent'   => $cheese,
     514                                'taxonomy' => $tax,
     515                        )
     516                );
    367517
    368518                $post_ids = self::factory()->post->create_many( 2 );
     
    373523                $this->assertEquals( 2, $term->count );
    374524
    375                 $brie = self::factory()->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) );
     525                $brie    = self::factory()->term->create(
     526                        array(
     527                                'name'     => 'Brie',
     528                                'parent'   => $cheese,
     529                                'taxonomy' => $tax,
     530                        )
     531                );
    376532                $post_id = self::factory()->post->create();
    377533                wp_set_post_terms( $post_id, $brie, $tax );
     
    379535                $this->assertEquals( 1, $term->count );
    380536
    381                 $crackers = self::factory()->term->create( array( 'name' => 'Crackers', 'taxonomy' => $tax ) );
    382 
    383                 $butter = self::factory()->term->create( array( 'name' => 'Butter', 'parent' => $crackers, 'taxonomy' => $tax ) );
     537                $crackers = self::factory()->term->create(
     538                        array(
     539                                'name'     => 'Crackers',
     540                                'taxonomy' => $tax,
     541                        )
     542                );
     543
     544                $butter   = self::factory()->term->create(
     545                        array(
     546                                'name'     => 'Butter',
     547                                'parent'   => $crackers,
     548                                'taxonomy' => $tax,
     549                        )
     550                );
    384551                $post_ids = self::factory()->post->create_many( 1 );
    385552                foreach ( $post_ids as $id ) {
     
    389556                $this->assertEquals( 1, $term->count );
    390557
    391                 $multigrain = self::factory()->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) );
    392                 $post_ids = self::factory()->post->create_many( 1 );
     558                $multigrain = self::factory()->term->create(
     559                        array(
     560                                'name'     => 'Multigrain',
     561                                'parent'   => $crackers,
     562                                'taxonomy' => $tax,
     563                        )
     564                );
     565                $post_ids   = self::factory()->post->create_many( 1 );
    393566                foreach ( $post_ids as $id ) {
    394567                        wp_set_post_terms( $id, $multigrain, $tax );
     
    397570                $this->assertEquals( 1, $term->count );
    398571
    399                 $fruit = self::factory()->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) );
    400                 $cranberries = self::factory()->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) );
    401 
    402                 $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) );
     572                $fruit       = self::factory()->term->create(
     573                        array(
     574                                'name'     => 'Fruit',
     575                                'taxonomy' => $tax,
     576                        )
     577                );
     578                $cranberries = self::factory()->term->create(
     579                        array(
     580                                'name'     => 'Cranberries',
     581                                'parent'   => $fruit,
     582                                'taxonomy' => $tax,
     583                        )
     584                );
     585
     586                $terms = get_terms(
     587                        $tax, array(
     588                                'parent'       => 0,
     589                                'cache_domain' => $tax,
     590                        )
     591                );
    403592                $this->assertEquals( 2, count( $terms ) );
    404593                $this->assertEquals( wp_list_pluck( $terms, 'name' ), array( 'Cheese', 'Crackers' ) );
     
    412601                register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    413602
    414                 $cheese = self::factory()->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) );
    415                 $cheddar = self::factory()->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) );
    416                 $spread = self::factory()->term->create( array( 'name' => 'Spread', 'parent' => $cheddar, 'taxonomy' => $tax ) );
     603                $cheese  = self::factory()->term->create(
     604                        array(
     605                                'name'     => 'Cheese',
     606                                'taxonomy' => $tax,
     607                        )
     608                );
     609                $cheddar = self::factory()->term->create(
     610                        array(
     611                                'name'     => 'Cheddar',
     612                                'parent'   => $cheese,
     613                                'taxonomy' => $tax,
     614                        )
     615                );
     616                $spread  = self::factory()->term->create(
     617                        array(
     618                                'name'     => 'Spread',
     619                                'parent'   => $cheddar,
     620                                'taxonomy' => $tax,
     621                        )
     622                );
    417623                $post_id = self::factory()->post->create();
    418624                wp_set_post_terms( $post_id, $spread, $tax );
     
    420626                $this->assertEquals( 1, $term->count );
    421627
    422                 $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) );
     628                $terms = get_terms(
     629                        $tax, array(
     630                                'parent'       => 0,
     631                                'cache_domain' => $tax,
     632                        )
     633                );
    423634                $this->assertEquals( 1, count( $terms ) );
    424635                $this->assertEquals( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) );
     
    434645                register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    435646                $parent = 0;
    436                 $t = array();
     647                $t      = array();
    437648                foreach ( range( 1, 7 ) as $depth ) {
    438                         $t[$depth] = self::factory()->term->create( array( 'name' => 'term' . $depth, 'taxonomy' => $tax, 'parent' => $parent ) );
    439                         $parent = $t[$depth];
     649                        $t[ $depth ] = self::factory()->term->create(
     650                                array(
     651                                        'name'     => 'term' . $depth,
     652                                        'taxonomy' => $tax,
     653                                        'parent'   => $parent,
     654                                )
     655                        );
     656                        $parent      = $t[ $depth ];
    440657                }
    441658                $post_id = self::factory()->post->create();
     
    444661                $this->assertEquals( 1, $term->count );
    445662
    446                 $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) );
     663                $terms = get_terms(
     664                        $tax, array(
     665                                'parent'       => 0,
     666                                'cache_domain' => $tax,
     667                        )
     668                );
    447669                $this->assertEquals( 1, count( $terms ) );
    448670                $this->assertEquals( array( 'term1' ), wp_list_pluck( $terms, 'name' ) );
     
    456678        function test_get_terms_child_of() {
    457679                $parent = self::factory()->category->create();
    458                 $child = self::factory()->category->create( array( 'parent' => $parent ) );
    459 
    460                 $terms = get_terms( 'category', array( 'child_of' => $parent, 'hide_empty' => false ) );
     680                $child  = self::factory()->category->create( array( 'parent' => $parent ) );
     681
     682                $terms = get_terms(
     683                        'category', array(
     684                                'child_of'   => $parent,
     685                                'hide_empty' => false,
     686                        )
     687                );
    461688                $this->assertEquals( 1, count( $terms ) );
    462689        }
     
    468695                global $wpdb;
    469696
    470                 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) );
     697                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    471698
    472699                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     
    474701                $num_queries = $wpdb->num_queries;
    475702
    476                 $found = get_terms( 'wptests_tax', array(
    477                         'hide_empty' => false,
    478                         'child_of' => $terms[0],
    479                 ) );
     703                $found = get_terms(
     704                        'wptests_tax', array(
     705                                'hide_empty' => false,
     706                                'child_of'   => $terms[0],
     707                        )
     708                );
    480709
    481710                $this->assertEmpty( $found );
     
    492721                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    493722                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    494                 $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );
    495 
    496                 $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
    497                         'fields' => 'ids',
    498                         'hide_empty' => false,
    499                         'child_of' => $t2,
    500                 ) );
     723                $t3 = self::factory()->term->create(
     724                        array(
     725                                'taxonomy' => 'wptests_tax2',
     726                                'parent'   => $t2,
     727                        )
     728                );
     729
     730                $found = get_terms(
     731                        array( 'wptests_tax1', 'wptests_tax2' ), array(
     732                                'fields'     => 'ids',
     733                                'hide_empty' => false,
     734                                'child_of'   => $t2,
     735                        )
     736                );
    501737
    502738                $this->assertEqualSets( array( $t3 ), $found );
     
    563799                $t2 = self::factory()->tag->create( array( 'slug' => 'bar' ) );
    564800
    565                 $found = get_terms( 'post_tag', array(
    566                         'hide_empty' => false,
    567                         'fields' => 'ids',
    568                         'slug' => 'foo',
    569                 ) );
     801                $found = get_terms(
     802                        'post_tag', array(
     803                                'hide_empty' => false,
     804                                'fields'     => 'ids',
     805                                'slug'       => 'foo',
     806                        )
     807                );
    570808
    571809                $this->assertEquals( array( $t1 ), $found );
     
    580818                $t3 = self::factory()->tag->create( array( 'slug' => 'barry' ) );
    581819
    582                 $found = get_terms( 'post_tag', array(
    583                         'hide_empty' => false,
    584                         'fields' => 'ids',
    585                         'slug' => array( 'foo', 'barry' )
    586                 ) );
     820                $found = get_terms(
     821                        'post_tag', array(
     822                                'hide_empty' => false,
     823                                'fields'     => 'ids',
     824                                'slug'       => array( 'foo', 'barry' ),
     825                        )
     826                );
    587827
    588828                $this->assertEquals( array( $t1, $t3 ), $found );
     
    596836                $t2 = self::factory()->tag->create( array( 'name' => 'Bar' ) );
    597837
    598                 $found = get_terms( 'post_tag', array(
    599                         'hide_empty' => false,
    600                         'fields' => 'ids',
    601                         'name' => 'Foo',
    602                 ) );
     838                $found = get_terms(
     839                        'post_tag', array(
     840                                'hide_empty' => false,
     841                                'fields'     => 'ids',
     842                                'name'       => 'Foo',
     843                        )
     844                );
    603845
    604846                $this->assertEquals( array( $t1 ), $found );
     
    613855                $t3 = self::factory()->tag->create( array( 'name' => 'Barry' ) );
    614856
    615                 $found = get_terms( 'post_tag', array(
    616                         'hide_empty' => false,
    617                         'fields' => 'ids',
    618                         'name' => array( 'Foo', 'Barry' )
    619                 ) );
     857                $found = get_terms(
     858                        'post_tag', array(
     859                                'hide_empty' => false,
     860                                'fields'     => 'ids',
     861                                'name'       => array( 'Foo', 'Barry' ),
     862                        )
     863                );
    620864
    621865                $this->assertEqualSets( array( $t3, $t1 ), $found );
     
    628872                register_taxonomy( 'wptests_tax', 'post' );
    629873
    630                 $t = self::factory()->term->create( array(
    631                         'taxonomy' => 'wptests_tax',
    632                         'name' => 'Foo & Bar',
    633                         'slug' => 'foo-and-bar',
    634                 ) );
    635 
    636                 $found = get_terms( 'wptests_tax', array(
    637                         'hide_empty' => false,
    638                         'fields' => 'ids',
    639                         'name' => 'Foo & Bar',
    640                 ) );
     874                $t = self::factory()->term->create(
     875                        array(
     876                                'taxonomy' => 'wptests_tax',
     877                                'name'     => 'Foo & Bar',
     878                                'slug'     => 'foo-and-bar',
     879                        )
     880                );
     881
     882                $found = get_terms(
     883                        'wptests_tax', array(
     884                                'hide_empty' => false,
     885                                'fields'     => 'ids',
     886                                'name'       => 'Foo & Bar',
     887                        )
     888                );
    641889                $this->assertEqualSets( array( $t ), $found );
    642890
    643891                // array format.
    644                 $found = get_terms( 'wptests_tax', array(
    645                         'hide_empty' => false,
    646                         'fields' => 'ids',
    647                         'name' => array( 'Foo & Bar' ),
    648                 ) );
     892                $found = get_terms(
     893                        'wptests_tax', array(
     894                                'hide_empty' => false,
     895                                'fields'     => 'ids',
     896                                'name'       => array( 'Foo & Bar' ),
     897                        )
     898                );
    649899                $this->assertEqualSets( array( $t ), $found );
    650900        }
     
    658908                $name = "Foo'Bar";
    659909
    660                 $t = self::factory()->term->create( array(
    661                         'taxonomy' => 'wptests_tax',
    662                         'name' => $name,
    663                 ) );
     910                $t = self::factory()->term->create(
     911                        array(
     912                                'taxonomy' => 'wptests_tax',
     913                                'name'     => $name,
     914                        )
     915                );
    664916
    665917                $term = get_term( $t, 'wptests_tax' );
     
    667919                $this->assertSame( $name, $term->name );
    668920
    669                 $found = get_terms( 'wptests_tax', array(
    670                         'hide_empty' => false,
    671                         'fields' => 'ids',
    672                         'name' => $name,
    673                 ) );
     921                $found = get_terms(
     922                        'wptests_tax', array(
     923                                'hide_empty' => false,
     924                                'fields'     => 'ids',
     925                                'name'       => $name,
     926                        )
     927                );
    674928
    675929                $this->assertEqualSets( array( $t ), $found );
     
    683937                $flat_tax = 'countries';
    684938                register_taxonomy( $flat_tax, 'post', array( 'hierarchical' => false ) );
    685                 $australia = self::factory()->term->create( array( 'name' => 'Australia', 'taxonomy' => $flat_tax ) );
    686                 $china     = self::factory()->term->create( array( 'name' => 'China',     'taxonomy' => $flat_tax ) );
    687                 $tanzania  =  self::factory()->term->create( array( 'name' => 'Tanzania',  'taxonomy' => $flat_tax ) );
    688 
    689                 $terms = get_terms( $flat_tax, array(
    690                         'childless' => true,
    691                         'hide_empty' => false,
    692                         'fields' => 'ids',
    693                 ) );
     939                $australia = self::factory()->term->create(
     940                        array(
     941                                'name'     => 'Australia',
     942                                'taxonomy' => $flat_tax,
     943                        )
     944                );
     945                $china     = self::factory()->term->create(
     946                        array(
     947                                'name'     => 'China',
     948                                'taxonomy' => $flat_tax,
     949                        )
     950                );
     951                $tanzania  = self::factory()->term->create(
     952                        array(
     953                                'name'     => 'Tanzania',
     954                                'taxonomy' => $flat_tax,
     955                        )
     956                );
     957
     958                $terms = get_terms(
     959                        $flat_tax, array(
     960                                'childless'  => true,
     961                                'hide_empty' => false,
     962                                'fields'     => 'ids',
     963                        )
     964                );
    694965
    695966                $expected = array( $australia, $china, $tanzania );
     
    715986                */
    716987                // Level 1
    717                 $canada = self::factory()->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
     988                $canada = self::factory()->term->create(
     989                        array(
     990                                'name'     => 'Canada',
     991                                'taxonomy' => $tax,
     992                        )
     993                );
    718994
    719995                // Level 2
    720                 $ontario = self::factory()->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) );
    721                 $quebec  = self::factory()->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) );
    722                 $pei     = self::factory()->term->create( array( 'name' => 'PEI', 'parent' => $canada, 'taxonomy' => $tax ) );
     996                $ontario = self::factory()->term->create(
     997                        array(
     998                                'name'     => 'Ontario',
     999                                'parent'   => $canada,
     1000                                'taxonomy' => $tax,
     1001                        )
     1002                );
     1003                $quebec  = self::factory()->term->create(
     1004                        array(
     1005                                'name'     => 'Quebec',
     1006                                'parent'   => $canada,
     1007                                'taxonomy' => $tax,
     1008                        )
     1009                );
     1010                $pei     = self::factory()->term->create(
     1011                        array(
     1012                                'name'     => 'PEI',
     1013                                'parent'   => $canada,
     1014                                'taxonomy' => $tax,
     1015                        )
     1016                );
    7231017
    7241018                // Level 3
    725                 $toronto  = self::factory()->term->create( array( 'name' => 'Toronto', 'parent' => $ontario, 'taxonomy' => $tax ) );
    726                 $ottawa   = self::factory()->term->create( array( 'name' => 'Ottawa', 'parent' => $ontario, 'taxonomy' => $tax ) );
    727                 $montreal = self::factory()->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) );
     1019                $toronto  = self::factory()->term->create(
     1020                        array(
     1021                                'name'     => 'Toronto',
     1022                                'parent'   => $ontario,
     1023                                'taxonomy' => $tax,
     1024                        )
     1025                );
     1026                $ottawa   = self::factory()->term->create(
     1027                        array(
     1028                                'name'     => 'Ottawa',
     1029                                'parent'   => $ontario,
     1030                                'taxonomy' => $tax,
     1031                        )
     1032                );
     1033                $montreal = self::factory()->term->create(
     1034                        array(
     1035                                'name'     => 'Montreal',
     1036                                'parent'   => $quebec,
     1037                                'taxonomy' => $tax,
     1038                        )
     1039                );
    7281040
    7291041                // Level 4
    730                 $nepean = self::factory()->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) );
    731 
    732                 $terms = get_terms( $tax, array(
    733                         'childless' => true,
    734                         'hide_empty' => false,
    735                         'fields' => 'ids',
    736                 ) );
     1042                $nepean = self::factory()->term->create(
     1043                        array(
     1044                                'name'     => 'Nepean',
     1045                                'parent'   => $ottawa,
     1046                                'taxonomy' => $tax,
     1047                        )
     1048                );
     1049
     1050                $terms = get_terms(
     1051                        $tax, array(
     1052                                'childless'  => true,
     1053                                'hide_empty' => false,
     1054                                'fields'     => 'ids',
     1055                        )
     1056                );
    7371057
    7381058                $this->assertEqualSets( array( $montreal, $nepean, $toronto, $pei ), $terms );
     
    7471067
    7481068                // Level 1
    749                 $canada = self::factory()->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
     1069                $canada = self::factory()->term->create(
     1070                        array(
     1071                                'name'     => 'Canada',
     1072                                'taxonomy' => $tax,
     1073                        )
     1074                );
    7501075
    7511076                // Level 2
    752                 $ontario = self::factory()->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) );
    753                 $quebec  = self::factory()->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) );
     1077                $ontario = self::factory()->term->create(
     1078                        array(
     1079                                'name'     => 'Ontario',
     1080                                'parent'   => $canada,
     1081                                'taxonomy' => $tax,
     1082                        )
     1083                );
     1084                $quebec  = self::factory()->term->create(
     1085                        array(
     1086                                'name'     => 'Quebec',
     1087                                'parent'   => $canada,
     1088                                'taxonomy' => $tax,
     1089                        )
     1090                );
    7541091
    7551092                // Level 3
    756                 $laval   = self::factory()->term->create( array( 'name' => 'Laval', 'parent' => $quebec, 'taxonomy' => $tax ) );
    757                 $montreal = self::factory()->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) );
     1093                $laval    = self::factory()->term->create(
     1094                        array(
     1095                                'name'     => 'Laval',
     1096                                'parent'   => $quebec,
     1097                                'taxonomy' => $tax,
     1098                        )
     1099                );
     1100                $montreal = self::factory()->term->create(
     1101                        array(
     1102                                'name'     => 'Montreal',
     1103                                'parent'   => $quebec,
     1104                                'taxonomy' => $tax,
     1105                        )
     1106                );
    7581107
    7591108                // Level 4
    760                 $dorval = self::factory()->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) );
    761 
    762                 $terms = get_terms( $tax, array(
    763                         'childless' => true,
    764                         'child_of' => $quebec,
    765                         'hide_empty' => false,
    766                         'fields' => 'ids',
    767                 ) );
     1109                $dorval = self::factory()->term->create(
     1110                        array(
     1111                                'name'     => 'Dorval',
     1112                                'parent'   => $montreal,
     1113                                'taxonomy' => $tax,
     1114                        )
     1115                );
     1116
     1117                $terms = get_terms(
     1118                        $tax, array(
     1119                                'childless'  => true,
     1120                                'child_of'   => $quebec,
     1121                                'hide_empty' => false,
     1122                                'fields'     => 'ids',
     1123                        )
     1124                );
    7681125
    7691126                $this->assertEqualSets( array( $laval ), $terms );
     
    7781135
    7791136                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    780                 $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) );
     1137                $t2 = self::factory()->term->create(
     1138                        array(
     1139                                'taxonomy' => 'wptests_tax1',
     1140                                'parent'   => $t1,
     1141                        )
     1142                );
    7811143                $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    782                 $t4 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t3 ) );
    783 
    784                 $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
    785                         'fields' => 'ids',
    786                         'hide_empty' => false,
    787                         'childless' => true,
    788                 ) );
     1144                $t4 = self::factory()->term->create(
     1145                        array(
     1146                                'taxonomy' => 'wptests_tax2',
     1147                                'parent'   => $t3,
     1148                        )
     1149                );
     1150
     1151                $found = get_terms(
     1152                        array( 'wptests_tax1', 'wptests_tax2' ), array(
     1153                                'fields'     => 'ids',
     1154                                'hide_empty' => false,
     1155                                'childless'  => true,
     1156                        )
     1157                );
    7891158
    7901159                $this->assertEqualSets( array( $t2, $t4 ), $found );
     
    7981167                $terms = $this->create_hierarchical_terms_and_posts();
    7991168
    800                 $found = get_terms( $tax, array(
    801                         'hide_empty' => false,
    802                         'fields' => 'ids',
    803                 ) );
     1169                $found = get_terms(
     1170                        $tax, array(
     1171                                'hide_empty' => false,
     1172                                'fields'     => 'ids',
     1173                        )
     1174                );
    8041175
    8051176                $expected = array(
     
    8231194                $terms = $this->create_hierarchical_terms_and_posts();
    8241195
    825                 $found = get_terms( $tax, array(
    826                         'hide_empty' => true,
    827                         'fields' => 'ids',
    828                 ) );
     1196                $found = get_terms(
     1197                        $tax, array(
     1198                                'hide_empty' => true,
     1199                                'fields'     => 'ids',
     1200                        )
     1201                );
    8291202
    8301203                $expected = array(
     
    8461219                $terms = $this->create_hierarchical_terms_and_posts();
    8471220
    848                 $found = get_terms( $tax, array(
    849                         'hide_empty' => true,
    850                         'fields' => 'ids',
    851                         'hierarchical' => false,
    852                 ) );
     1221                $found = get_terms(
     1222                        $tax, array(
     1223                                'hide_empty'   => true,
     1224                                'fields'       => 'ids',
     1225                                'hierarchical' => false,
     1226                        )
     1227                );
    8531228
    8541229                $expected = array(
     
    8691244                $terms = $this->create_hierarchical_terms_and_posts();
    8701245
    871                 $found = get_terms( $tax, array(
    872                         'hide_empty' => false,
    873                         'fields' => 'names',
    874                 ) );
     1246                $found = get_terms(
     1247                        $tax, array(
     1248                                'hide_empty' => false,
     1249                                'fields'     => 'names',
     1250                        )
     1251                );
    8751252
    8761253                $expected = array(
     
    8941271                $terms = $this->create_hierarchical_terms_and_posts();
    8951272
    896                 $found = get_terms( $tax, array(
    897                         'hide_empty' => true,
    898                         'fields' => 'names',
    899                 ) );
     1273                $found = get_terms(
     1274                        $tax, array(
     1275                                'hide_empty' => true,
     1276                                'fields'     => 'names',
     1277                        )
     1278                );
    9001279
    9011280                $expected = array(
     
    9171296                $terms = $this->create_hierarchical_terms_and_posts();
    9181297
    919                 $found = get_terms( $tax, array(
    920                         'hide_empty' => true,
    921                         'fields' => 'names',
    922                         'hierarchical' => false,
    923                 ) );
     1298                $found = get_terms(
     1299                        $tax, array(
     1300                                'hide_empty'   => true,
     1301                                'fields'       => 'names',
     1302                                'hierarchical' => false,
     1303                        )
     1304                );
    9241305
    9251306                $expected = array(
     
    9401321                $terms = $this->create_hierarchical_terms_and_posts();
    9411322
    942                 $found = get_terms( $tax, array(
    943                         'hide_empty' => false,
    944                         'fields' => 'count',
    945                 ) );
     1323                $found = get_terms(
     1324                        $tax, array(
     1325                                'hide_empty' => false,
     1326                                'fields'     => 'count',
     1327                        )
     1328                );
    9461329
    9471330                _unregister_taxonomy( 'hierarchical_fields' );
     
    9571340                $terms = $this->create_hierarchical_terms_and_posts();
    9581341
    959                 $found = get_terms( $tax, array(
    960                         'hide_empty' => true,
    961                         'fields' => 'count',
    962                 ) );
     1342                $found = get_terms(
     1343                        $tax, array(
     1344                                'hide_empty' => true,
     1345                                'fields'     => 'count',
     1346                        )
     1347                );
    9631348
    9641349                _unregister_taxonomy( 'hierarchical_fields' );
     
    9751360                $terms = $this->create_hierarchical_terms_and_posts();
    9761361
    977                 $found = get_terms( $tax, array(
    978                         'hide_empty' => true,
    979                         'fields' => 'count',
    980                         'hierarchical' => false,
    981                 ) );
     1362                $found = get_terms(
     1363                        $tax, array(
     1364                                'hide_empty'   => true,
     1365                                'fields'       => 'count',
     1366                                'hierarchical' => false,
     1367                        )
     1368                );
    9821369
    9831370                _unregister_taxonomy( 'hierarchical_fields' );
     
    9931380                $terms = $this->create_hierarchical_terms_and_posts();
    9941381
    995                 $found = get_terms( $tax, array(
    996                         'hide_empty' => false,
    997                         'fields' => 'id=>parent',
    998                 ) );
     1382                $found = get_terms(
     1383                        $tax, array(
     1384                                'hide_empty' => false,
     1385                                'fields'     => 'id=>parent',
     1386                        )
     1387                );
    9991388
    10001389                $expected = array(
    1001                         $terms['parent1'] => 0,
    1002                         $terms['parent2'] => 0,
    1003                         $terms['child1'] => $terms['parent1'],
    1004                         $terms['child2'] => $terms['parent1'],
     1390                        $terms['parent1']     => 0,
     1391                        $terms['parent2']     => 0,
     1392                        $terms['child1']      => $terms['parent1'],
     1393                        $terms['child2']      => $terms['parent1'],
    10051394                        $terms['grandchild1'] => $terms['child1'],
    10061395                );
     
    10181407                $terms = $this->create_hierarchical_terms_and_posts();
    10191408
    1020                 $found = get_terms( $tax, array(
    1021                         'hide_empty' => true,
    1022                         'fields' => 'id=>parent',
    1023                 ) );
     1409                $found = get_terms(
     1410                        $tax, array(
     1411                                'hide_empty' => true,
     1412                                'fields'     => 'id=>parent',
     1413                        )
     1414                );
    10241415
    10251416                $expected = array(
    10261417                        $terms['parent1'] => 0,
    10271418                        $terms['parent2'] => 0,
    1028                         $terms['child1'] => $terms['parent1'],
     1419                        $terms['child1']  => $terms['parent1'],
    10291420                );
    10301421
     
    10411432                $terms = $this->create_hierarchical_terms_and_posts();
    10421433
    1043                 $found = get_terms( $tax, array(
    1044                         'hide_empty' => true,
    1045                         'fields' => 'id=>parent',
    1046                         'hierarchical' => false,
    1047                 ) );
     1434                $found = get_terms(
     1435                        $tax, array(
     1436                                'hide_empty'   => true,
     1437                                'fields'       => 'id=>parent',
     1438                                'hierarchical' => false,
     1439                        )
     1440                );
    10481441
    10491442                $expected = array(
    10501443                        $terms['parent2'] => 0,
    1051                         $terms['child1'] => $terms['parent1'],
     1444                        $terms['child1']  => $terms['parent1'],
    10521445                );
    10531446
     
    10641457                $terms = $this->create_hierarchical_terms_and_posts();
    10651458
    1066                 $found = get_terms( $tax, array(
    1067                         'hide_empty' => false,
    1068                         'fields' => 'id=>slug',
    1069                 ) );
     1459                $found = get_terms(
     1460                        $tax, array(
     1461                                'hide_empty' => false,
     1462                                'fields'     => 'id=>slug',
     1463                        )
     1464                );
    10701465
    10711466                $expected = array(
    1072                         $terms['parent1'] => 'parent-1',
    1073                         $terms['parent2'] => 'parent-2',
    1074                         $terms['child1'] => 'child-1',
    1075                         $terms['child2'] => 'child-2',
     1467                        $terms['parent1']     => 'parent-1',
     1468                        $terms['parent2']     => 'parent-2',
     1469                        $terms['child1']      => 'child-1',
     1470                        $terms['child2']      => 'child-2',
    10761471                        $terms['grandchild1'] => 'grandchild-1',
    10771472                );
     
    10921487                $terms = $this->create_hierarchical_terms_and_posts();
    10931488
    1094                 $found = get_terms( $tax, array(
    1095                         'hide_empty' => true,
    1096                         'fields' => 'id=>slug',
    1097                 ) );
     1489                $found = get_terms(
     1490                        $tax, array(
     1491                                'hide_empty' => true,
     1492                                'fields'     => 'id=>slug',
     1493                        )
     1494                );
    10981495
    10991496                $expected = array(
    11001497                        $terms['parent1'] => 'parent-1',
    11011498                        $terms['parent2'] => 'parent-2',
    1102                         $terms['child1'] => 'child-1',
     1499                        $terms['child1']  => 'child-1',
    11031500                );
    11041501
     
    11151512                $terms = $this->create_hierarchical_terms_and_posts();
    11161513
    1117                 $found = get_terms( $tax, array(
    1118                         'hide_empty' => true,
    1119                         'fields' => 'id=>slug',
    1120                         'hierarchical' => false,
    1121                 ) );
     1514                $found = get_terms(
     1515                        $tax, array(
     1516                                'hide_empty'   => true,
     1517                                'fields'       => 'id=>slug',
     1518                                'hierarchical' => false,
     1519                        )
     1520                );
    11221521
    11231522                $expected = array(
    11241523                        $terms['parent2'] => 'parent-2',
    1125                         $terms['child1'] => 'child-1',
     1524                        $terms['child1']  => 'child-1',
    11261525                );
    11271526
     
    11381537                $terms = $this->create_hierarchical_terms_and_posts();
    11391538
    1140                 $found = get_terms( $tax, array(
    1141                         'hide_empty' => false,
    1142                         'fields' => 'id=>name',
    1143                 ) );
     1539                $found = get_terms(
     1540                        $tax, array(
     1541                                'hide_empty' => false,
     1542                                'fields'     => 'id=>name',
     1543                        )
     1544                );
    11441545
    11451546                $expected = array(
    1146                         $terms['parent1'] => 'Parent 1',
    1147                         $terms['parent2'] => 'Parent 2',
    1148                         $terms['child1'] => 'Child 1',
    1149                         $terms['child2'] => 'Child 2',
     1547                        $terms['parent1']     => 'Parent 1',
     1548                        $terms['parent2']     => 'Parent 2',
     1549                        $terms['child1']      => 'Child 1',
     1550                        $terms['child2']      => 'Child 2',
    11501551                        $terms['grandchild1'] => 'Grandchild 1',
    11511552                );
     
    11661567                $terms = $this->create_hierarchical_terms_and_posts();
    11671568
    1168                 $found = get_terms( $tax, array(
    1169                         'hide_empty' => true,
    1170                         'fields' => 'id=>name',
    1171                 ) );
     1569                $found = get_terms(
     1570                        $tax, array(
     1571                                'hide_empty' => true,
     1572                                'fields'     => 'id=>name',
     1573                        )
     1574                );
    11721575
    11731576                $expected = array(
    11741577                        $terms['parent1'] => 'Parent 1',
    11751578                        $terms['parent2'] => 'Parent 2',
    1176                         $terms['child1'] => 'Child 1',
     1579                        $terms['child1']  => 'Child 1',
    11771580                );
    11781581
     
    11891592                $terms = $this->create_hierarchical_terms_and_posts();
    11901593
    1191                 $found = get_terms( $tax, array(
    1192                         'hide_empty' => true,
    1193                         'fields' => 'id=>name',
    1194                         'hierarchical' => false,
    1195                 ) );
     1594                $found = get_terms(
     1595                        $tax, array(
     1596                                'hide_empty'   => true,
     1597                                'fields'       => 'id=>name',
     1598                                'hierarchical' => false,
     1599                        )
     1600                );
    11961601
    11971602                $expected = array(
    11981603                        $terms['parent2'] => 'Parent 2',
    1199                         $terms['child1'] => 'Child 1',
     1604                        $terms['child1']  => 'Child 1',
    12001605                );
    12011606
     
    12131618
    12141619                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    1215                 $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) );
    1216                 $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t2 ) );
     1620                $t2 = self::factory()->term->create(
     1621                        array(
     1622                                'taxonomy' => 'wptests_tax1',
     1623                                'parent'   => $t1,
     1624                        )
     1625                );
     1626                $t3 = self::factory()->term->create(
     1627                        array(
     1628                                'taxonomy' => 'wptests_tax1',
     1629                                'parent'   => $t2,
     1630                        )
     1631                );
    12171632
    12181633                $t4 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    1219                 $t5 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t4 ) );
    1220                 $t6 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t5 ) );
     1634                $t5 = self::factory()->term->create(
     1635                        array(
     1636                                'taxonomy' => 'wptests_tax2',
     1637                                'parent'   => $t4,
     1638                        )
     1639                );
     1640                $t6 = self::factory()->term->create(
     1641                        array(
     1642                                'taxonomy' => 'wptests_tax2',
     1643                                'parent'   => $t5,
     1644                        )
     1645                );
    12211646
    12221647                $p = self::factory()->post->create();
     
    12251650                wp_set_object_terms( $p, $t6, 'wptests_tax2' );
    12261651
    1227                 $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
    1228                         'hierarchical' => true,
    1229                         'hide_empty' => true,
    1230                         'fields' => 'ids',
    1231                 ) );
     1652                $found = get_terms(
     1653                        array( 'wptests_tax1', 'wptests_tax2' ), array(
     1654                                'hierarchical' => true,
     1655                                'hide_empty'   => true,
     1656                                'fields'       => 'ids',
     1657                        )
     1658                );
    12321659
    12331660                /*
     
    12591686                $t4 = self::factory()->term->create( array( 'taxonomy' => $tax ) );
    12601687
    1261                 $found = get_terms( $tax, array(
    1262                         'fields' => 'ids',
    1263                         'include' => array( $t4, $t1, $t2 ),
    1264                         'orderby' => 'include',
    1265                         'hide_empty' => false,
    1266                 ) );
     1688                $found = get_terms(
     1689                        $tax, array(
     1690                                'fields'     => 'ids',
     1691                                'include'    => array( $t4, $t1, $t2 ),
     1692                                'orderby'    => 'include',
     1693                                'hide_empty' => false,
     1694                        )
     1695                );
    12671696
    12681697                _unregister_taxonomy( 'wptests_tax' );
     
    12781707                register_taxonomy( $tax, 'post' );
    12791708
    1280                 $t1 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'fff' ) );
    1281                 $t2 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'aaa' ) );
    1282                 $t3 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'zzz' ) );
    1283                 $t4 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'jjj' ) );
    1284 
    1285                 $found = get_terms( $tax, array(
    1286                         'fields' => 'ids',
    1287                         'orderby' => 'description',
    1288                         'hide_empty' => false,
    1289                 ) );
     1709                $t1 = self::factory()->term->create(
     1710                        array(
     1711                                'taxonomy'    => $tax,
     1712                                'description' => 'fff',
     1713                        )
     1714                );
     1715                $t2 = self::factory()->term->create(
     1716                        array(
     1717                                'taxonomy'    => $tax,
     1718                                'description' => 'aaa',
     1719                        )
     1720                );
     1721                $t3 = self::factory()->term->create(
     1722                        array(
     1723                                'taxonomy'    => $tax,
     1724                                'description' => 'zzz',
     1725                        )
     1726                );
     1727                $t4 = self::factory()->term->create(
     1728                        array(
     1729                                'taxonomy'    => $tax,
     1730                                'description' => 'jjj',
     1731                        )
     1732                );
     1733
     1734                $found = get_terms(
     1735                        $tax, array(
     1736                                'fields'     => 'ids',
     1737                                'orderby'    => 'description',
     1738                                'hide_empty' => false,
     1739                        )
     1740                );
    12901741
    12911742                _unregister_taxonomy( 'wptests_tax' );
     
    12991750        public function test_orderby_term_id() {
    13001751                register_taxonomy( 'wptests_tax', 'post' );
    1301                 $t1 = self::factory()->term->create( array(
    1302                         'taxonomy' => 'wptests_tax',
    1303                         'name' => 'AAA',
    1304                 ) );
    1305                 $t2 = self::factory()->term->create( array(
    1306                         'taxonomy' => 'wptests_tax',
    1307                         'name' => 'ZZZ',
    1308                 ) );
    1309                 $t3 = self::factory()->term->create( array(
    1310                         'taxonomy' => 'wptests_tax',
    1311                         'name' => 'JJJ',
    1312                 ) );
    1313 
    1314                 $found = get_terms( 'wptests_tax', array(
    1315                         'orderby' => 'term_id',
    1316                         'hide_empty' => false,
    1317                         'fields' => 'ids',
    1318                 ) );
     1752                $t1 = self::factory()->term->create(
     1753                        array(
     1754                                'taxonomy' => 'wptests_tax',
     1755                                'name'     => 'AAA',
     1756                        )
     1757                );
     1758                $t2 = self::factory()->term->create(
     1759                        array(
     1760                                'taxonomy' => 'wptests_tax',
     1761                                'name'     => 'ZZZ',
     1762                        )
     1763                );
     1764                $t3 = self::factory()->term->create(
     1765                        array(
     1766                                'taxonomy' => 'wptests_tax',
     1767                                'name'     => 'JJJ',
     1768                        )
     1769                );
     1770
     1771                $found = get_terms(
     1772                        'wptests_tax', array(
     1773                                'orderby'    => 'term_id',
     1774                                'hide_empty' => false,
     1775                                'fields'     => 'ids',
     1776                        )
     1777                );
    13191778
    13201779                $this->assertEquals( array( $t1, $t2, $t3 ), $found );
     
    13351794
    13361795                // Matches the first meta query clause.
    1337                 $found = get_terms( 'wptests_tax', array(
    1338                         'hide_empty' => false,
    1339                         'meta_query' => array(
    1340                                 'relation' => 'AND',
    1341                                 array(
    1342                                         'key' => 'foo',
    1343                                         'compare' => 'EXISTS',
     1796                $found = get_terms(
     1797                        'wptests_tax', array(
     1798                                'hide_empty' => false,
     1799                                'meta_query' => array(
     1800                                        'relation' => 'AND',
     1801                                        array(
     1802                                                'key'     => 'foo',
     1803                                                'compare' => 'EXISTS',
     1804                                        ),
     1805                                        array(
     1806                                                'key'     => 'fee',
     1807                                                'compare' => 'EXISTS',
     1808                                        ),
    13441809                                ),
    1345                                 array(
    1346                                         'key' => 'fee',
    1347                                         'compare' => 'EXISTS',
    1348                                 ),
    1349                         ),
    1350                         'orderby' => 'meta_value',
    1351                         'order' => 'ASC',
    1352                         'fields' => 'ids',
    1353                 ) );
     1810                                'orderby'    => 'meta_value',
     1811                                'order'      => 'ASC',
     1812                                'fields'     => 'ids',
     1813                        )
     1814                );
    13541815
    13551816                $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
     
    13701831
    13711832                // Matches the first meta query clause.
    1372                 $found = get_terms( 'wptests_tax', array(
    1373                         'hide_empty' => false,
    1374                         'meta_query' => array(
    1375                                 'relation' => 'AND',
    1376                                 array(
    1377                                         'key' => 'foo',
    1378                                         'compare' => 'EXISTS',
     1833                $found = get_terms(
     1834                        'wptests_tax', array(
     1835                                'hide_empty' => false,
     1836                                'meta_query' => array(
     1837                                        'relation' => 'AND',
     1838                                        array(
     1839                                                'key'     => 'foo',
     1840                                                'compare' => 'EXISTS',
     1841                                        ),
     1842                                        array(
     1843                                                'key'     => 'fee',
     1844                                                'compare' => 'EXISTS',
     1845                                        ),
    13791846                                ),
    1380                                 array(
    1381                                         'key' => 'fee',
    1382                                         'compare' => 'EXISTS',
    1383                                 ),
    1384                         ),
    1385                         'orderby' => 'meta_value_num',
    1386                         'order' => 'ASC',
    1387                         'fields' => 'ids',
    1388                 ) );
     1847                                'orderby'    => 'meta_value_num',
     1848                                'order'      => 'ASC',
     1849                                'fields'     => 'ids',
     1850                        )
     1851                );
    13891852
    13901853                $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
     
    14071870                add_term_meta( $terms[2], 'faa', 'zzz' );
    14081871
    1409                 $found = get_terms( 'wptests_tax', array(
    1410                         'hide_empty' => false,
    1411                         'meta_key' => 'fee',
    1412                         'orderby' => 'meta_value',
    1413                         'order' => 'ASC',
    1414                         'fields' => 'ids',
    1415                 ) );
     1872                $found = get_terms(
     1873                        'wptests_tax', array(
     1874                                'hide_empty' => false,
     1875                                'meta_key'   => 'fee',
     1876                                'orderby'    => 'meta_value',
     1877                                'order'      => 'ASC',
     1878                                'fields'     => 'ids',
     1879                        )
     1880                );
    14161881
    14171882                $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
    14181883
    1419                 $found = get_terms( 'wptests_tax', array(
    1420                         'hide_empty' => false,
    1421                         'meta_query' => array(
    1422                                 array(
    1423                                         'key' => 'foo',
    1424                                         'compare' => 'EXISTS',
     1884                $found = get_terms(
     1885                        'wptests_tax', array(
     1886                                'hide_empty' => false,
     1887                                'meta_query' => array(
     1888                                        array(
     1889                                                'key'     => 'foo',
     1890                                                'compare' => 'EXISTS',
     1891                                        ),
    14251892                                ),
    1426                         ),
    1427                         'meta_key' => 'fee',
    1428                         'orderby' => 'meta_value',
    1429                         'order' => 'ASC',
    1430                         'fields' => 'ids',
    1431                 ) );
     1893                                'meta_key'   => 'fee',
     1894                                'orderby'    => 'meta_value',
     1895                                'order'      => 'ASC',
     1896                                'fields'     => 'ids',
     1897                        )
     1898                );
    14321899
    14331900                $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
    14341901
    14351902                // Matches the first meta query clause.
    1436                 $found = get_terms( 'wptests_tax', array(
    1437                         'hide_empty' => false,
    1438                         'meta_query' => array(
    1439                                 'relation' => 'AND',
    1440                                 array(
    1441                                         'key' => 'foo',
    1442                                         'compare' => 'EXISTS',
     1903                $found = get_terms(
     1904                        'wptests_tax', array(
     1905                                'hide_empty' => false,
     1906                                'meta_query' => array(
     1907                                        'relation' => 'AND',
     1908                                        array(
     1909                                                'key'     => 'foo',
     1910                                                'compare' => 'EXISTS',
     1911                                        ),
     1912                                        array(
     1913                                                'key'     => 'fee',
     1914                                                'compare' => 'EXISTS',
     1915                                        ),
    14431916                                ),
    1444                                 array(
    1445                                         'key' => 'fee',
    1446                                         'compare' => 'EXISTS',
     1917                                'meta_key'   => 'fee',
     1918                                'orderby'    => 'meta_value',
     1919                                'order'      => 'ASC',
     1920                                'fields'     => 'ids',
     1921                        )
     1922                );
     1923
     1924                $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
     1925
     1926                // Matches the meta query clause corresponding to the 'meta_key' param.
     1927                $found = get_terms(
     1928                        'wptests_tax', array(
     1929                                'hide_empty' => false,
     1930                                'meta_query' => array(
     1931                                        'relation' => 'AND',
     1932                                        array(
     1933                                                'key'     => 'foo',
     1934                                                'compare' => 'EXISTS',
     1935                                        ),
     1936                                        array(
     1937                                                'key'     => 'fee',
     1938                                                'compare' => 'EXISTS',
     1939                                        ),
    14471940                                ),
    1448                         ),
    1449                         'meta_key' => 'fee',
    1450                         'orderby' => 'meta_value',
    1451                         'order' => 'ASC',
    1452                         'fields' => 'ids',
    1453                 ) );
    1454 
    1455                 $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
    1456 
    1457                 // Matches the meta query clause corresponding to the 'meta_key' param.
    1458                 $found = get_terms( 'wptests_tax', array(
    1459                         'hide_empty' => false,
    1460                         'meta_query' => array(
    1461                                 'relation' => 'AND',
    1462                                 array(
    1463                                         'key' => 'foo',
    1464                                         'compare' => 'EXISTS',
    1465                                 ),
    1466                                 array(
    1467                                         'key' => 'fee',
    1468                                         'compare' => 'EXISTS',
    1469                                 ),
    1470                         ),
    1471                         'meta_key' => 'faa',
    1472                         'orderby' => 'meta_value',
    1473                         'order' => 'ASC',
    1474                         'fields' => 'ids',
    1475                 ) );
     1941                                'meta_key'   => 'faa',
     1942                                'orderby'    => 'meta_value',
     1943                                'order'      => 'ASC',
     1944                                'fields'     => 'ids',
     1945                        )
     1946                );
    14761947
    14771948                $this->assertEqualSets( array( $terms[1], $terms[0], $terms[2] ), $found );
     
    14941965                add_term_meta( $terms[2], 'faa', '999' );
    14951966
    1496                 $found = get_terms( 'wptests_tax', array(
    1497                         'hide_empty' => false,
    1498                         'meta_key' => 'fee',
    1499                         'orderby' => 'meta_value',
    1500                         'order' => 'ASC',
    1501                         'fields' => 'ids',
    1502                 ) );
     1967                $found = get_terms(
     1968                        'wptests_tax', array(
     1969                                'hide_empty' => false,
     1970                                'meta_key'   => 'fee',
     1971                                'orderby'    => 'meta_value',
     1972                                'order'      => 'ASC',
     1973                                'fields'     => 'ids',
     1974                        )
     1975                );
    15031976
    15041977                $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
    15051978
    1506                 $found = get_terms( 'wptests_tax', array(
    1507                         'hide_empty' => false,
    1508                         'meta_query' => array(
    1509                                 array(
    1510                                         'key' => 'foo',
    1511                                         'compare' => 'EXISTS',
     1979                $found = get_terms(
     1980                        'wptests_tax', array(
     1981                                'hide_empty' => false,
     1982                                'meta_query' => array(
     1983                                        array(
     1984                                                'key'     => 'foo',
     1985                                                'compare' => 'EXISTS',
     1986                                        ),
    15121987                                ),
    1513                         ),
    1514                         'meta_key' => 'fee',
    1515                         'orderby' => 'meta_value',
    1516                         'order' => 'ASC',
    1517                         'fields' => 'ids',
    1518                 ) );
     1988                                'meta_key'   => 'fee',
     1989                                'orderby'    => 'meta_value',
     1990                                'order'      => 'ASC',
     1991                                'fields'     => 'ids',
     1992                        )
     1993                );
    15191994
    15201995                $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
    15211996
    1522                 $found = get_terms( 'wptests_tax', array(
    1523                         'hide_empty' => false,
    1524                         'meta_query' => array(
    1525                                 'relation' => 'AND',
    1526                                 array(
    1527                                         'key' => 'foo',
    1528                                         'compare' => 'EXISTS',
     1997                $found = get_terms(
     1998                        'wptests_tax', array(
     1999                                'hide_empty' => false,
     2000                                'meta_query' => array(
     2001                                        'relation' => 'AND',
     2002                                        array(
     2003                                                'key'     => 'foo',
     2004                                                'compare' => 'EXISTS',
     2005                                        ),
     2006                                        array(
     2007                                                'key'     => 'fee',
     2008                                                'compare' => 'EXISTS',
     2009                                        ),
    15292010                                ),
    1530                                 array(
    1531                                         'key' => 'fee',
    1532                                         'compare' => 'EXISTS',
     2011                                'meta_key'   => 'fee',
     2012                                'orderby'    => 'meta_value',
     2013                                'order'      => 'ASC',
     2014                                'fields'     => 'ids',
     2015                        )
     2016                );
     2017
     2018                $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
     2019
     2020                $found = get_terms(
     2021                        'wptests_tax', array(
     2022                                'hide_empty' => false,
     2023                                'meta_query' => array(
     2024                                        'relation' => 'AND',
     2025                                        array(
     2026                                                'key'     => 'foo',
     2027                                                'compare' => 'EXISTS',
     2028                                        ),
     2029                                        array(
     2030                                                'key'     => 'fee',
     2031                                                'compare' => 'EXISTS',
     2032                                        ),
    15332033                                ),
    1534                         ),
    1535                         'meta_key' => 'fee',
    1536                         'orderby' => 'meta_value',
    1537                         'order' => 'ASC',
    1538                         'fields' => 'ids',
    1539                 ) );
    1540 
    1541                 $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
    1542 
    1543                 $found = get_terms( 'wptests_tax', array(
    1544                         'hide_empty' => false,
    1545                         'meta_query' => array(
    1546                                 'relation' => 'AND',
    1547                                 array(
    1548                                         'key' => 'foo',
    1549                                         'compare' => 'EXISTS',
    1550                                 ),
    1551                                 array(
    1552                                         'key' => 'fee',
    1553                                         'compare' => 'EXISTS',
    1554                                 ),
    1555                         ),
    1556                         'meta_key' => 'faa',
    1557                         'orderby' => 'meta_value',
    1558                         'order' => 'ASC',
    1559                         'fields' => 'ids',
    1560                 ) );
     2034                                'meta_key'   => 'faa',
     2035                                'orderby'    => 'meta_value',
     2036                                'order'      => 'ASC',
     2037                                'fields'     => 'ids',
     2038                        )
     2039                );
    15612040
    15622041                $this->assertEqualSets( array( $terms[1], $terms[0], $terms[2] ), $found );
     
    15762055                add_term_meta( $terms[2], 'fee', 'zzz' );
    15772056
    1578                 $found = get_terms( 'wptests_tax', array(
    1579                         'hide_empty' => false,
    1580                         'meta_query' => array(
    1581                                 'relation' => 'AND',
    1582                                 'foo_key' => array(
    1583                                         'key' => 'foo',
    1584                                         'compare' => 'EXISTS',
     2057                $found = get_terms(
     2058                        'wptests_tax', array(
     2059                                'hide_empty' => false,
     2060                                'meta_query' => array(
     2061                                        'relation' => 'AND',
     2062                                        'foo_key'  => array(
     2063                                                'key'     => 'foo',
     2064                                                'compare' => 'EXISTS',
     2065                                        ),
     2066                                        'fee_key'  => array(
     2067                                                'key'     => 'fee',
     2068                                                'compare' => 'EXISTS',
     2069                                        ),
    15852070                                ),
    1586                                 'fee_key' => array(
    1587                                         'key' => 'fee',
    1588                                         'compare' => 'EXISTS',
     2071                                'orderby'    => 'foo_key',
     2072                                'order'      => 'ASC',
     2073                                'fields'     => 'ids',
     2074                        )
     2075                );
     2076
     2077                $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
     2078
     2079                $found = get_terms(
     2080                        'wptests_tax', array(
     2081                                'hide_empty' => false,
     2082                                'meta_query' => array(
     2083                                        'relation' => 'AND',
     2084                                        'foo_key'  => array(
     2085                                                'key'     => 'foo',
     2086                                                'compare' => 'EXISTS',
     2087                                        ),
     2088                                        'fee_key'  => array(
     2089                                                'key'     => 'fee',
     2090                                                'compare' => 'EXISTS',
     2091                                        ),
    15892092                                ),
    1590                         ),
    1591                         'orderby' => 'foo_key',
    1592                         'order' => 'ASC',
    1593                         'fields' => 'ids',
    1594                 ) );
    1595 
    1596                 $this->assertEqualSets( array( $terms[1], $terms[2], $terms[0] ), $found );
    1597 
    1598                 $found = get_terms( 'wptests_tax', array(
    1599                         'hide_empty' => false,
    1600                         'meta_query' => array(
    1601                                 'relation' => 'AND',
    1602                                 'foo_key' => array(
    1603                                         'key' => 'foo',
    1604                                         'compare' => 'EXISTS',
     2093                                'orderby'    => 'fee_key',
     2094                                'order'      => 'ASC',
     2095                                'fields'     => 'ids',
     2096                        )
     2097                );
     2098
     2099                $this->assertEqualSets( array( $terms[1], $terms[0], $terms[2] ), $found );
     2100
     2101                $expected = get_terms(
     2102                        'wptests_tax', array(
     2103                                'hide_empty' => false,
     2104                                'meta_query' => array(
     2105                                        'relation' => 'AND',
     2106                                        'foo_key'  => array(
     2107                                                'key'     => 'foo',
     2108                                                'compare' => 'EXISTS',
     2109                                        ),
     2110                                        'fee_key'  => array(
     2111                                                'key'     => 'fee',
     2112                                                'compare' => 'EXISTS',
     2113                                        ),
    16052114                                ),
    1606                                 'fee_key' => array(
    1607                                         'key' => 'fee',
    1608                                         'compare' => 'EXISTS',
     2115                                'fields'     => 'ids',
     2116                        )
     2117                );
     2118
     2119                $found = get_terms(
     2120                        'wptests_tax', array(
     2121                                'hide_empty' => false,
     2122                                'meta_query' => array(
     2123                                        'relation' => 'AND',
     2124                                        'foo_key'  => array(
     2125                                                'key'     => 'foo',
     2126                                                'compare' => 'EXISTS',
     2127                                        ),
     2128                                        'fee_key'  => array(
     2129                                                'key'     => 'fee',
     2130                                                'compare' => 'EXISTS',
     2131                                        ),
    16092132                                ),
    1610                         ),
    1611                         'orderby' => 'fee_key',
    1612                         'order' => 'ASC',
    1613                         'fields' => 'ids',
    1614                 ) );
    1615 
    1616                 $this->assertEqualSets( array( $terms[1], $terms[0], $terms[2] ), $found );
    1617 
    1618                 $expected = get_terms( 'wptests_tax', array(
    1619                         'hide_empty' => false,
    1620                         'meta_query' => array(
    1621                                 'relation' => 'AND',
    1622                                 'foo_key' => array(
    1623                                         'key' => 'foo',
    1624                                         'compare' => 'EXISTS',
    1625                                 ),
    1626                                 'fee_key' => array(
    1627                                         'key' => 'fee',
    1628                                         'compare' => 'EXISTS',
    1629                                 ),
    1630                         ),
    1631                         'fields' => 'ids',
    1632                 ) );
    1633 
    1634                 $found = get_terms( 'wptests_tax', array(
    1635                         'hide_empty' => false,
    1636                         'meta_query' => array(
    1637                                 'relation' => 'AND',
    1638                                 'foo_key' => array(
    1639                                         'key' => 'foo',
    1640                                         'compare' => 'EXISTS',
    1641                                 ),
    1642                                 'fee_key' => array(
    1643                                         'key' => 'fee',
    1644                                         'compare' => 'EXISTS',
    1645                                 ),
    1646                         ),
    1647                         'orderby' => 'faa_key',
    1648                         'fields' => 'ids',
    1649                 ) );
     2133                                'orderby'    => 'faa_key',
     2134                                'fields'     => 'ids',
     2135                        )
     2136                );
    16502137
    16512138                $this->assertEqualSets( $expected, $found );
     
    16562143
    16572144                // Case where hierarchical is false
    1658                 $terms = get_terms( 'category', array(
    1659                         'hierarchical' => false,
    1660                         'parent' => $initial_terms['one_term']['term_id']
    1661                 ) );
     2145                $terms = get_terms(
     2146                        'category', array(
     2147                                'hierarchical' => false,
     2148                                'parent'       => $initial_terms['one_term']['term_id'],
     2149                        )
     2150                );
    16622151
    16632152                // Verify that there are no children
     
    16722161
    16732162                // Case where hierarchical is true
    1674                 $terms = get_terms( 'category', array(
    1675                         'hierarchical' => true,
    1676                         'parent' => $initial_terms['one_term']['term_id']
    1677                 ) );
     2163                $terms = get_terms(
     2164                        'category', array(
     2165                                'hierarchical' => true,
     2166                                'parent'       => $initial_terms['one_term']['term_id'],
     2167                        )
     2168                );
    16782169
    16792170                // Verify that the children with non-empty descendants are returned
     
    16822173                        $initial_terms['five_term']['term_id'],
    16832174                );
    1684                 $actual = wp_list_pluck( $terms, 'term_id' );
     2175                $actual   = wp_list_pluck( $terms, 'term_id' );
    16852176                $this->assertEqualSets( $expected, $actual );
    16862177        }
     
    16882179        public function test_hierarchical_false_with_child_of_and_direct_child() {
    16892180                $initial_terms = $this->create_hierarchical_terms();
    1690                 $post_id = self::factory()->post->create();
     2181                $post_id       = self::factory()->post->create();
    16912182                wp_set_post_terms(
    16922183                        $post_id,
     
    16962187
    16972188                // Case where hierarchical is false
    1698                 $terms = get_terms( 'category', array(
    1699                         'hierarchical' => false,
    1700                         'child_of' => $initial_terms['one_term']['term_id']
    1701                 ) );
     2189                $terms = get_terms(
     2190                        'category', array(
     2191                                'hierarchical' => false,
     2192                                'child_of'     => $initial_terms['one_term']['term_id'],
     2193                        )
     2194                );
    17022195
    17032196                $expected = array(
     
    17132206
    17142207                // Case where hierarchical is false
    1715                 $terms = get_terms( 'category', array(
    1716                         'hierarchical' => false,
    1717                         'child_of' => $initial_terms['one_term']['term_id']
    1718                 ) );
     2208                $terms = get_terms(
     2209                        'category', array(
     2210                                'hierarchical' => false,
     2211                                'child_of'     => $initial_terms['one_term']['term_id'],
     2212                        )
     2213                );
    17192214
    17202215                // Verify that there are no children
     
    17262221
    17272222                // Case where hierarchical is true
    1728                 $terms = get_terms( 'category', array(
    1729                         'hierarchical' => true,
    1730                         'child_of' => $initial_terms['one_term']['term_id']
    1731                 ) );
     2223                $terms = get_terms(
     2224                        'category', array(
     2225                                'hierarchical' => true,
     2226                                'child_of'     => $initial_terms['one_term']['term_id'],
     2227                        )
     2228                );
    17322229
    17332230                $expected = array(
     
    17372234                        $initial_terms['six_term']['term_id'],
    17382235                );
    1739                 $actual = wp_list_pluck( $terms, 'term_id' );
     2236                $actual   = wp_list_pluck( $terms, 'term_id' );
    17402237                $this->assertEqualSets( $expected, $actual );
    17412238        }
     
    17442241                $initial_terms = $this->create_hierarchical_terms();
    17452242
    1746                 $terms = get_terms( 'category', array(
    1747                         'hide_empty' => false,
    1748                         'child_of' => $initial_terms['one_term']['term_id'],
    1749                         'parent' => $initial_terms['one_term']['term_id']
    1750                 ) );
     2243                $terms = get_terms(
     2244                        'category', array(
     2245                                'hide_empty' => false,
     2246                                'child_of'   => $initial_terms['one_term']['term_id'],
     2247                                'parent'     => $initial_terms['one_term']['term_id'],
     2248                        )
     2249                );
    17512250
    17522251                // Verify that parent takes precedence over child_of and returns only direct children.
     
    17542253                        $initial_terms['two_term']['term_id'],
    17552254                        $initial_terms['five_term']['term_id'],
    1756                         $initial_terms['seven_term']['term_id']
    1757                 );
    1758                 $actual = wp_list_pluck( $terms, 'term_id' );
     2255                        $initial_terms['seven_term']['term_id'],
     2256                );
     2257                $actual   = wp_list_pluck( $terms, 'term_id' );
    17592258                $this->assertEqualSets( $expected, $actual );
    17602259        }
     
    17662265                global $wpdb;
    17672266
    1768                 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) );
     2267                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    17692268
    17702269                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     
    17722271                $num_queries = $wpdb->num_queries;
    17732272
    1774                 $found = get_terms( 'wptests_tax', array(
    1775                         'hide_empty' => false,
    1776                         'parent' => $terms[0],
    1777                 ) );
     2273                $found = get_terms(
     2274                        'wptests_tax', array(
     2275                                'hide_empty' => false,
     2276                                'parent'     => $terms[0],
     2277                        )
     2278                );
    17782279
    17792280                $this->assertEmpty( $found );
     
    17902291                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    17912292                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    1792                 $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );
    1793 
    1794                 $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
    1795                         'fields' => 'ids',
    1796                         'hide_empty' => false,
    1797                         'parent' => $t2,
    1798                 ) );
     2293                $t3 = self::factory()->term->create(
     2294                        array(
     2295                                'taxonomy' => 'wptests_tax2',
     2296                                'parent'   => $t2,
     2297                        )
     2298                );
     2299
     2300                $found = get_terms(
     2301                        array( 'wptests_tax1', 'wptests_tax2' ), array(
     2302                                'fields'     => 'ids',
     2303                                'hide_empty' => false,
     2304                                'parent'     => $t2,
     2305                        )
     2306                );
    17992307
    18002308                $this->assertEqualSets( array( $t3 ), $found );
     
    18052313
    18062314                // Case where hierarchical is false
    1807                 $terms = get_terms( 'category', array(
    1808                         'hierarchical' => false,
    1809                         'child_of' => $initial_terms['one_term']['term_id'],
    1810                         'parent' => $initial_terms['one_term']['term_id']
    1811                 ) );
     2315                $terms = get_terms(
     2316                        'category', array(
     2317                                'hierarchical' => false,
     2318                                'child_of'     => $initial_terms['one_term']['term_id'],
     2319                                'parent'       => $initial_terms['one_term']['term_id'],
     2320                        )
     2321                );
    18122322
    18132323                // hierarchical=false means that descendants are not fetched.
     
    18222332
    18232333                // Case where hierarchical is true
    1824                 $terms = get_terms( 'category', array(
    1825                         'hierarchical' => true,
    1826                         'child_of' => $initial_terms['one_term']['term_id'],
    1827                         'parent' => $initial_terms['one_term']['term_id'],
    1828                 ) );
     2334                $terms = get_terms(
     2335                        'category', array(
     2336                                'hierarchical' => true,
     2337                                'child_of'     => $initial_terms['one_term']['term_id'],
     2338                                'parent'       => $initial_terms['one_term']['term_id'],
     2339                        )
     2340                );
    18292341
    18302342                // Verify that parent takes precedence over child_of
     
    18332345                        $initial_terms['five_term']['term_id'],
    18342346                );
    1835                 $actual = wp_list_pluck( $terms, 'term_id' );
     2347                $actual   = wp_list_pluck( $terms, 'term_id' );
    18362348                $this->assertEqualSets( $expected, $actual );
    18372349        }
     
    18422354                $posts = self::factory()->post->create_many( 3 );
    18432355
    1844                 $t1 = self::factory()->term->create( array(
    1845                         'taxonomy' => 'wptests_tax_1',
    1846                 ) );
    1847                 $t2 = self::factory()->term->create( array(
    1848                         'taxonomy' => 'wptests_tax_1',
    1849                         'parent' => $t1,
    1850                 ) );
    1851                 $t3 = self::factory()->term->create( array(
    1852                         'taxonomy' => 'wptests_tax_1',
    1853                         'parent' => $t2,
    1854                 ) );
     2356                $t1 = self::factory()->term->create(
     2357                        array(
     2358                                'taxonomy' => 'wptests_tax_1',
     2359                        )
     2360                );
     2361                $t2 = self::factory()->term->create(
     2362                        array(
     2363                                'taxonomy' => 'wptests_tax_1',
     2364                                'parent'   => $t1,
     2365                        )
     2366                );
     2367                $t3 = self::factory()->term->create(
     2368                        array(
     2369                                'taxonomy' => 'wptests_tax_1',
     2370                                'parent'   => $t2,
     2371                        )
     2372                );
    18552373
    18562374                wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax_1' );
     
    18582376                wp_set_object_terms( $posts[2], array( $t3 ), 'wptests_tax_1' );
    18592377
    1860                 $found = get_terms( 'wptests_tax_1', array(
    1861                         'pad_counts' => true,
    1862                 ) );
     2378                $found = get_terms(
     2379                        'wptests_tax_1', array(
     2380                                'pad_counts' => true,
     2381                        )
     2382                );
    18632383
    18642384                $this->assertEqualSets( array( $t1, $t2, $t3 ), wp_list_pluck( $found, 'term_id' ) );
     
    18932413                wp_set_post_terms( $posts[2], $c3, 'category' );
    18942414
    1895                 $terms = get_terms( 'category', array(
    1896                         'pad_counts' => true,
    1897                 ) );
     2415                $terms = get_terms(
     2416                        'category', array(
     2417                                'pad_counts' => true,
     2418                        )
     2419                );
    18982420
    18992421                $this->assertEqualSets( array( $c1, $c2, $c3 ), wp_list_pluck( $terms, 'term_id' ) );
     
    19132435                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    19142436                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    1915                 $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );
     2437                $t3 = self::factory()->term->create(
     2438                        array(
     2439                                'taxonomy' => 'wptests_tax2',
     2440                                'parent'   => $t2,
     2441                        )
     2442                );
    19162443
    19172444                $posts = self::factory()->post->create_many( 3 );
     
    19202447                wp_set_object_terms( $posts[2], $t3, 'wptests_tax2' );
    19212448
    1922                 $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
    1923                         'pad_counts' => true,
    1924                 ) );
     2449                $found = get_terms(
     2450                        array( 'wptests_tax1', 'wptests_tax2' ), array(
     2451                                'pad_counts' => true,
     2452                        )
     2453                );
    19252454
    19262455                $this->assertEqualSets( array( $t1, $t2, $t3 ), wp_list_pluck( $found, 'term_id' ) );
     
    19492478                add_term_meta( $terms[2], 'foo', 'bar' );
    19502479
    1951                 $found = get_terms( 'wptests_tax', array(
    1952                         'hide_empty' => false,
    1953                         'include' => $terms,
    1954                 ) );
     2480                $found = get_terms(
     2481                        'wptests_tax', array(
     2482                                'hide_empty' => false,
     2483                                'include'    => $terms,
     2484                        )
     2485                );
    19552486
    19562487                $num_queries = $wpdb->num_queries;
     
    19752506                add_term_meta( $terms[2], 'foo', 'bar' );
    19762507
    1977                 $found = get_terms( 'wptests_tax', array(
    1978                         'hide_empty' => false,
    1979                         'include' => $terms,
    1980                         'update_term_meta_cache' => false,
    1981                 ) );
     2508                $found = get_terms(
     2509                        'wptests_tax', array(
     2510                                'hide_empty'             => false,
     2511                                'include'                => $terms,
     2512                                'update_term_meta_cache' => false,
     2513                        )
     2514                );
    19822515
    19832516                $num_queries = $wpdb->num_queries;
     
    20012534                add_term_meta( $terms[3], 'foob', 'ar' );
    20022535
    2003                 $found = get_terms( 'wptests_tax', array(
    2004                         'hide_empty' => false,
    2005                         'meta_query' => array(
    2006                                 array(
    2007                                         'key' => 'foo',
    2008                                         'value' => 'bar',
     2536                $found = get_terms(
     2537                        'wptests_tax', array(
     2538                                'hide_empty' => false,
     2539                                'meta_query' => array(
     2540                                        array(
     2541                                                'key'   => 'foo',
     2542                                                'value' => 'bar',
     2543                                        ),
    20092544                                ),
    2010                         ),
    2011                         'fields' => 'ids',
    2012                 ) );
     2545                                'fields'     => 'ids',
     2546                        )
     2547                );
    20132548
    20142549                $this->assertEqualSets( array( $terms[0], $terms[1] ), $found );
     
    20242559                add_term_meta( $terms[0], 'foo', 'ber' );
    20252560
    2026                 $found = get_terms( 'wptests_tax', array(
    2027                         'hide_empty' => false,
    2028                         'meta_query' => array(
    2029                                 array(
    2030                                         'key' => 'foo',
    2031                                         'value' => 'bur',
    2032                                         'compare' => '!=',
     2561                $found = get_terms(
     2562                        'wptests_tax', array(
     2563                                'hide_empty' => false,
     2564                                'meta_query' => array(
     2565                                        array(
     2566                                                'key'     => 'foo',
     2567                                                'value'   => 'bur',
     2568                                                'compare' => '!=',
     2569                                        ),
    20332570                                ),
    2034                         ),
    2035                         'fields' => 'ids',
    2036                 ) );
     2571                                'fields'     => 'ids',
     2572                        )
     2573                );
    20372574
    20382575                $this->assertEqualSets( array( $terms[0] ), $found );
     
    20462583                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    20472584
    2048                 $found = get_terms( 'wptests_tax', array(
    2049                         'hide_empty' => false,
    2050                         'fields' => 'all',
    2051                 ) );
     2585                $found = get_terms(
     2586                        'wptests_tax', array(
     2587                                'hide_empty' => false,
     2588                                'fields'     => 'all',
     2589                        )
     2590                );
    20522591
    20532592                $this->assertNotEmpty( $found );
     
    20692608
    20702609                // Prime the cache.
    2071                 get_terms( 'wptests_tax', array(
    2072                         'hide_empty' => false,
    2073                         'fields' => 'all',
    2074                 ) );
     2610                get_terms(
     2611                        'wptests_tax', array(
     2612                                'hide_empty' => false,
     2613                                'fields'     => 'all',
     2614                        )
     2615                );
    20752616
    20762617                $num_queries = $wpdb->num_queries;
    20772618
    2078                 $found = get_terms( 'wptests_tax', array(
    2079                         'hide_empty' => false,
    2080                         'fields' => 'all',
    2081                 ) );
     2619                $found = get_terms(
     2620                        'wptests_tax', array(
     2621                                'hide_empty' => false,
     2622                                'fields'     => 'all',
     2623                        )
     2624                );
    20822625
    20832626                $this->assertSame( $num_queries, $wpdb->num_queries );
     
    20992642                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    21002643
    2101                 $found = get_terms( 'wptests_tax', array(
    2102                         'hide_empty' => false,
    2103                         'fields' => 'all',
    2104                 ) );
     2644                $found = get_terms(
     2645                        'wptests_tax', array(
     2646                                'hide_empty' => false,
     2647                                'fields'     => 'all',
     2648                        )
     2649                );
    21052650
    21062651                $num_queries = $wpdb->num_queries;
    2107                 $term0 = get_term( $terms[0] );
     2652                $term0       = get_term( $terms[0] );
    21082653                $this->assertSame( $num_queries, $wpdb->num_queries );
    21092654
     
    21172662                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    21182663
    2119                 $found = get_terms( 'wptests_tax', array(
    2120                         'hide_empty' => false,
    2121                         'fields' => 'id=>parent',
    2122                         'number' => 2,
    2123                         'orderby' => 'id',
    2124                         'order' => 'ASC',
    2125                         'hierarchical' => true,
    2126                 ) );
     2664                $found = get_terms(
     2665                        'wptests_tax', array(
     2666                                'hide_empty'   => false,
     2667                                'fields'       => 'id=>parent',
     2668                                'number'       => 2,
     2669                                'orderby'      => 'id',
     2670                                'order'        => 'ASC',
     2671                                'hierarchical' => true,
     2672                        )
     2673                );
    21272674
    21282675                $this->assertSame( array( $terms[0], $terms[1] ), array_keys( $found ) );
     
    21372684                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    21382685
    2139                 $found = get_terms( 'wptests_tax', array(
    2140                         'number'     => 3,
    2141                         'offset'     => 0,
    2142                         'hide_empty' => false,
    2143                         'fields'     => 'ids',
    2144                 ) );
     2686                $found = get_terms(
     2687                        'wptests_tax', array(
     2688                                'number'     => 3,
     2689                                'offset'     => 0,
     2690                                'hide_empty' => false,
     2691                                'fields'     => 'ids',
     2692                        )
     2693                );
    21452694                $this->assertEqualSets( $terms, $found );
    21462695        }
     
    21542703                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    21552704
    2156                 $found = get_terms( 'wptests_tax', array(
    2157                         'number'     => 1,
    2158                         'offset'     => 1,
    2159                         'hide_empty' => false,
    2160                         'fields'     => 'ids',
    2161                         'orderby'    => 'term_id',
    2162                         'order'      => 'ASC',
    2163                 ) );
     2705                $found = get_terms(
     2706                        'wptests_tax', array(
     2707                                'number'     => 1,
     2708                                'offset'     => 1,
     2709                                'hide_empty' => false,
     2710                                'fields'     => 'ids',
     2711                                'orderby'    => 'term_id',
     2712                                'order'      => 'ASC',
     2713                        )
     2714                );
    21642715                $this->assertEqualSets( array( $terms[1] ), $found );
    21652716        }
     
    21732724                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    21742725
    2175                 $found = get_terms( 'wptests_tax', array(
    2176                         'number'     => 2,
    2177                         'offset'     => 1,
    2178                         'hide_empty' => false,
    2179                         'fields'     => 'ids',
    2180                         'orderby'    => 'term_id',
    2181                         'order'      => 'ASC',
    2182                 ) );
     2726                $found = get_terms(
     2727                        'wptests_tax', array(
     2728                                'number'     => 2,
     2729                                'offset'     => 1,
     2730                                'hide_empty' => false,
     2731                                'fields'     => 'ids',
     2732                                'orderby'    => 'term_id',
     2733                                'order'      => 'ASC',
     2734                        )
     2735                );
    21832736                $this->assertEqualSets( array( $terms[1] ), $found );
    21842737        }
     
    21922745                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    21932746
    2194                 $found = get_terms( 'wptests_tax', array(
    2195                         'number'     => 100,
    2196                         'offset'     => 3,
    2197                         'hide_empty' => false,
    2198                         'fields'     => 'ids',
    2199                         'orderby'    => 'term_id',
    2200                         'order'      => 'ASC',
    2201                 ) );
     2747                $found = get_terms(
     2748                        'wptests_tax', array(
     2749                                'number'     => 100,
     2750                                'offset'     => 3,
     2751                                'hide_empty' => false,
     2752                                'fields'     => 'ids',
     2753                                'orderby'    => 'term_id',
     2754                                'order'      => 'ASC',
     2755                        )
     2756                );
    22022757                $this->assertEqualSets( array(), $found );
    22032758        }
     
    22102765                add_filter( 'get_terms', array( __CLASS__, 'maybe_filter_count' ) );
    22112766
    2212                 $found = get_terms( array(
    2213                         'hide_empty' => 0,
    2214                         'fields' => 'count',
    2215                 ) );
     2767                $found = get_terms(
     2768                        array(
     2769                                'hide_empty' => 0,
     2770                                'fields'     => 'count',
     2771                        )
     2772                );
    22162773
    22172774                remove_filter( 'get_terms', array( __CLASS__, 'maybe_filter_count' ) );
     
    22302787                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    22312788
    2232                 $term_id = self::factory()->term->create( array(
    2233                         'name' => '0',
    2234                         'slug' => '0',
    2235                         'taxonomy' => 'wptests_tax',
    2236                 ) );
    2237 
    2238                 $found = get_terms( array(
    2239                         'taxonomy'   => 'wptests_tax',
    2240                         'hide_empty' => 0,
    2241                         'slug'       => '0',
    2242                 ) );
     2789                $term_id = self::factory()->term->create(
     2790                        array(
     2791                                'name'     => '0',
     2792                                'slug'     => '0',
     2793                                'taxonomy' => 'wptests_tax',
     2794                        )
     2795                );
     2796
     2797                $found = get_terms(
     2798                        array(
     2799                                'taxonomy'   => 'wptests_tax',
     2800                                'hide_empty' => 0,
     2801                                'slug'       => '0',
     2802                        )
     2803                );
    22432804
    22442805                $this->assertEqualSets( array( $term_id ), wp_list_pluck( $found, 'term_id' ) );
     
    22512812                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    22522813
    2253                 $term_id1 = self::factory()->term->create( array(
    2254                         'name'     => '0',
    2255                         'slug'     => '0',
    2256                         'taxonomy' => 'wptests_tax',
    2257                 ) );
    2258 
    2259                 $term_id2 = self::factory()->term->create( array(
    2260                         'name'     => 'Test',
    2261                         'slug'     => 'test',
    2262                         'taxonomy' => 'wptests_tax',
    2263                 ) );
    2264 
    2265                 $found = get_terms( array(
    2266                         'taxonomy'   => 'wptests_tax',
    2267                         'hide_empty' => 0,
    2268                         'slug'       => array(
    2269                                 '0',
    2270                                 'test',
    2271                         ),
    2272                 ) );
     2814                $term_id1 = self::factory()->term->create(
     2815                        array(
     2816                                'name'     => '0',
     2817                                'slug'     => '0',
     2818                                'taxonomy' => 'wptests_tax',
     2819                        )
     2820                );
     2821
     2822                $term_id2 = self::factory()->term->create(
     2823                        array(
     2824                                'name'     => 'Test',
     2825                                'slug'     => 'test',
     2826                                'taxonomy' => 'wptests_tax',
     2827                        )
     2828                );
     2829
     2830                $found = get_terms(
     2831                        array(
     2832                                'taxonomy'   => 'wptests_tax',
     2833                                'hide_empty' => 0,
     2834                                'slug'       => array(
     2835                                        '0',
     2836                                        'test',
     2837                                ),
     2838                        )
     2839                );
    22732840
    22742841                $this->assertEqualSets( array( $term_id1, $term_id2 ), wp_list_pluck( $found, 'term_id' ) );
     
    22782845                $terms = array();
    22792846
    2280                 $terms['parent1'] = self::factory()->term->create( array( 'slug' => 'parent-1', 'name' => 'Parent 1', 'taxonomy' => 'hierarchical_fields' ) );
    2281                 $terms['parent2'] = self::factory()->term->create( array( 'slug' => 'parent-2', 'name' => 'Parent 2', 'taxonomy' => 'hierarchical_fields' ) );
    2282                 $terms['child1'] = self::factory()->term->create( array( 'slug' => 'child-1', 'name' => 'Child 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) );
    2283                 $terms['child2'] = self::factory()->term->create( array( 'slug' => 'child-2', 'name' => 'Child 2', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) );
    2284                 $terms['grandchild1'] = self::factory()->term->create( array( 'slug' => 'grandchild-1', 'name' => 'Grandchild 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['child1'] ) );
     2847                $terms['parent1']     = self::factory()->term->create(
     2848                        array(
     2849                                'slug'     => 'parent-1',
     2850                                'name'     => 'Parent 1',
     2851                                'taxonomy' => 'hierarchical_fields',
     2852                        )
     2853                );
     2854                $terms['parent2']     = self::factory()->term->create(
     2855                        array(
     2856                                'slug'     => 'parent-2',
     2857                                'name'     => 'Parent 2',
     2858                                'taxonomy' => 'hierarchical_fields',
     2859                        )
     2860                );
     2861                $terms['child1']      = self::factory()->term->create(
     2862                        array(
     2863                                'slug'     => 'child-1',
     2864                                'name'     => 'Child 1',
     2865                                'taxonomy' => 'hierarchical_fields',
     2866                                'parent'   => $terms['parent1'],
     2867                        )
     2868                );
     2869                $terms['child2']      = self::factory()->term->create(
     2870                        array(
     2871                                'slug'     => 'child-2',
     2872                                'name'     => 'Child 2',
     2873                                'taxonomy' => 'hierarchical_fields',
     2874                                'parent'   => $terms['parent1'],
     2875                        )
     2876                );
     2877                $terms['grandchild1'] = self::factory()->term->create(
     2878                        array(
     2879                                'slug'     => 'grandchild-1',
     2880                                'name'     => 'Grandchild 1',
     2881                                'taxonomy' => 'hierarchical_fields',
     2882                                'parent'   => $terms['child1'],
     2883                        )
     2884                );
    22852885
    22862886                $post_id = self::factory()->post->create();
     
    23002900                //     - Six (1)
    23012901                //   - Seven
    2302                 $one_term = wp_insert_term(
     2902                $one_term   = wp_insert_term(
    23032903                        'One',
    23042904                        'category'
    23052905                );
    2306                 $two_term = wp_insert_term(
     2906                $two_term   = wp_insert_term(
    23072907                        'Two',
    23082908                        'category',
    23092909                        array(
    2310                                 'parent' => $one_term['term_id']
     2910                                'parent' => $one_term['term_id'],
    23112911                        )
    23122912                );
     
    23152915                        'category',
    23162916                        array(
    2317                                 'parent' => $two_term['term_id']
    2318                         )
    2319                 );
    2320                 $four_term = wp_insert_term(
     2917                                'parent' => $two_term['term_id'],
     2918                        )
     2919                );
     2920                $four_term  = wp_insert_term(
    23212921                        'Four',
    23222922                        'category',
    23232923                        array(
    2324                                 'parent' => $two_term['term_id']
    2325                         )
    2326                 );
    2327                 $five_term = wp_insert_term(
     2924                                'parent' => $two_term['term_id'],
     2925                        )
     2926                );
     2927                $five_term  = wp_insert_term(
    23282928                        'Five',
    23292929                        'category',
    23302930                        array(
    2331                                 'parent' => $one_term['term_id']
    2332                         )
    2333                 );
    2334                 $six_term = wp_insert_term(
     2931                                'parent' => $one_term['term_id'],
     2932                        )
     2933                );
     2934                $six_term   = wp_insert_term(
    23352935                        'Six',
    23362936                        'category',
    23372937                        array(
    2338                                 'parent' => $five_term['term_id']
     2938                                'parent' => $five_term['term_id'],
    23392939                        )
    23402940                );
     
    23432943                        'category',
    23442944                        array(
    2345                                 'parent' => $one_term['term_id']
     2945                                'parent' => $one_term['term_id'],
    23462946                        )
    23472947                );
    23482948
    23492949                // Ensure child terms are not empty
    2350                 $first_post_id = self::factory()->post->create();
     2950                $first_post_id  = self::factory()->post->create();
    23512951                $second_post_id = self::factory()->post->create();
    23522952                wp_set_post_terms( $first_post_id, array( $three_term['term_id'] ), 'category' );
     
    23542954
    23552955                return array(
    2356                         'one_term' => $one_term,
    2357                         'two_term' => $two_term,
     2956                        'one_term'   => $one_term,
     2957                        'two_term'   => $two_term,
    23582958                        'three_term' => $three_term,
    2359                         'four_term' => $four_term,
    2360                         'five_term' => $five_term,
    2361                         'six_term' => $six_term,
    2362                         'seven_term' => $seven_term
     2959                        'four_term'  => $four_term,
     2960                        'five_term'  => $five_term,
     2961                        'six_term'   => $six_term,
     2962                        'seven_term' => $seven_term,
    23632963                );
    23642964        }
Note: See TracChangeset for help on using the changeset viewer.