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

    r42211 r42343  
    66class Tests_Taxonomy extends WP_UnitTestCase {
    77        function test_get_post_taxonomies() {
    8                 $this->assertEquals(array('category', 'post_tag', 'post_format'), get_object_taxonomies('post'));
     8                $this->assertEquals( array( 'category', 'post_tag', 'post_format' ), get_object_taxonomies( 'post' ) );
    99        }
    1010
    1111        function test_get_link_taxonomies() {
    12                 $this->assertEquals(array('link_category'), get_object_taxonomies('link'));
     12                $this->assertEquals( array( 'link_category' ), get_object_taxonomies( 'link' ) );
    1313        }
    1414
    … …  
    1818        function test_get_unknown_taxonomies() {
    1919                // taxonomies for an unknown object type
    20                 $this->assertEquals( array(), get_object_taxonomies(rand_str()) );
    21                 $this->assertEquals( array(), get_object_taxonomies('') );
    22                 $this->assertEquals( array(), get_object_taxonomies(0) );
    23                 $this->assertEquals( array(), get_object_taxonomies(NULL) );
     20                $this->assertEquals( array(), get_object_taxonomies( rand_str() ) );
     21                $this->assertEquals( array(), get_object_taxonomies( '' ) );
     22                $this->assertEquals( array(), get_object_taxonomies( 0 ) );
     23                $this->assertEquals( array(), get_object_taxonomies( null ) );
    2424        }
    2525
    2626        function test_get_post_taxonomy() {
    27                 foreach ( get_object_taxonomies('post') as $taxonomy ) {
    28                         $tax = get_taxonomy($taxonomy);
     27                foreach ( get_object_taxonomies( 'post' ) as $taxonomy ) {
     28                        $tax = get_taxonomy( $taxonomy );
    2929                        // should return an object with the correct taxonomy object type
    3030                        $this->assertTrue( is_object( $tax ) );
    … …  
    6060
    6161                $taxes = get_the_taxonomies( $post_id, array( 'term_template' => '<span class="foo"><a href="%1$s">%2$s</a></span>' ) );
    62                 $link = get_category_link( 1 );
     62                $link  = get_category_link( 1 );
    6363                $this->assertEquals( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $taxes['category'] );
    6464        }
    … …  
    7171                $output = ob_get_clean();
    7272
    73                 $link = get_category_link( 1 );
     73                $link     = get_category_link( 1 );
    7474                $expected = 'Categories: <a href="' . $link . '">Uncategorized</a>.';
    7575                $this->assertEquals( $expected, $output );
    … …  
    8282                $post_id = self::factory()->post->create();
    8383
    84                 $output = get_echo( 'the_taxonomies', array( array( 'post' => $post_id, 'term_template' => '%2$s' ) ) );
     84                $output = get_echo(
     85                        'the_taxonomies', array(
     86                                array(
     87                                        'post'          => $post_id,
     88                                        'term_template' => '%2$s',
     89                                ),
     90                        )
     91                );
    8592                $this->assertEquals( 'Categories: Uncategorized.', $output );
    8693
    87                 $output = get_echo( 'the_taxonomies', array( array( 'post' => $post_id, 'term_template' => '<span class="foo"><a href="%1$s">%2$s</a></span>' ) ) );
    88                 $link = get_category_link( 1 );
     94                $output = get_echo(
     95                        'the_taxonomies', array(
     96                                array(
     97                                        'post'          => $post_id,
     98                                        'term_template' => '<span class="foo"><a href="%1$s">%2$s</a></span>',
     99                                ),
     100                        )
     101                );
     102                $link   = get_category_link( 1 );
    89103                $this->assertEquals( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $output );
    90104        }
    91105
    92106        function test_get_link_taxonomy() {
    93                 foreach ( get_object_taxonomies('link') as $taxonomy ) {
    94                         $tax = get_taxonomy($taxonomy);
     107                foreach ( get_object_taxonomies( 'link' ) as $taxonomy ) {
     108                        $tax = get_taxonomy( $taxonomy );
    95109                        // should return an object with the correct taxonomy object type
    96                         $this->assertTrue( is_object($tax) );
     110                        $this->assertTrue( is_object( $tax ) );
    97111                        $this->assertTrue( is_array( $tax->object_type ) );
    98112                        $this->assertEquals( array( 'link' ), $tax->object_type );
    … …  
    101115
    102116        function test_taxonomy_exists_known() {
    103                 $this->assertTrue( taxonomy_exists('category') );
    104                 $this->assertTrue( taxonomy_exists('post_tag') );
    105                 $this->assertTrue( taxonomy_exists('link_category') );
     117                $this->assertTrue( taxonomy_exists( 'category' ) );
     118                $this->assertTrue( taxonomy_exists( 'post_tag' ) );
     119                $this->assertTrue( taxonomy_exists( 'link_category' ) );
    106120        }
    107121
    108122        function test_taxonomy_exists_unknown() {
    109                 $this->assertFalse( taxonomy_exists(rand_str()) );
    110                 $this->assertFalse( taxonomy_exists('') );
    111                 $this->assertFalse( taxonomy_exists(0) );
    112                 $this->assertFalse( taxonomy_exists(NULL) );
     123                $this->assertFalse( taxonomy_exists( rand_str() ) );
     124                $this->assertFalse( taxonomy_exists( '' ) );
     125                $this->assertFalse( taxonomy_exists( 0 ) );
     126                $this->assertFalse( taxonomy_exists( null ) );
    113127        }
    114128
    115129        function test_is_taxonomy_hierarchical() {
    116                 $this->assertTrue( is_taxonomy_hierarchical('category') );
    117                 $this->assertFalse( is_taxonomy_hierarchical('post_tag') );
    118                 $this->assertFalse( is_taxonomy_hierarchical('link_category') );
     130                $this->assertTrue( is_taxonomy_hierarchical( 'category' ) );
     131                $this->assertFalse( is_taxonomy_hierarchical( 'post_tag' ) );
     132                $this->assertFalse( is_taxonomy_hierarchical( 'link_category' ) );
    119133        }
    120134
    121135        function test_is_taxonomy_hierarchical_unknown() {
    122                 $this->assertFalse( is_taxonomy_hierarchical(rand_str()) );
    123                 $this->assertFalse( is_taxonomy_hierarchical('') );
    124                 $this->assertFalse( is_taxonomy_hierarchical(0) );
    125                 $this->assertFalse( is_taxonomy_hierarchical(NULL) );
     136                $this->assertFalse( is_taxonomy_hierarchical( rand_str() ) );
     137                $this->assertFalse( is_taxonomy_hierarchical( '' ) );
     138                $this->assertFalse( is_taxonomy_hierarchical( 0 ) );
     139                $this->assertFalse( is_taxonomy_hierarchical( null ) );
    126140        }
    127141
    … …  
    130144                // make up a new taxonomy name, and ensure it's unused
    131145                $tax = rand_str();
    132                 $this->assertFalse( taxonomy_exists($tax) );
     146                $this->assertFalse( taxonomy_exists( $tax ) );
    133147
    134148                register_taxonomy( $tax, 'post' );
    135                 $this->assertTrue( taxonomy_exists($tax) );
    136                 $this->assertFalse( is_taxonomy_hierarchical($tax) );
     149                $this->assertTrue( taxonomy_exists( $tax ) );
     150                $this->assertFalse( is_taxonomy_hierarchical( $tax ) );
    137151
    138152                // clean up
    139                 unset($GLOBALS['wp_taxonomies'][$tax]);
     153                unset( $GLOBALS['wp_taxonomies'][ $tax ] );
    140154        }
    141155
    … …  
    144158                // make up a new taxonomy name, and ensure it's unused
    145159                $tax = rand_str();
    146                 $this->assertFalse( taxonomy_exists($tax) );
    147 
    148                 register_taxonomy( $tax, 'post', array('hierarchical'=>true) );
    149                 $this->assertTrue( taxonomy_exists($tax) );
    150                 $this->assertTrue( is_taxonomy_hierarchical($tax) );
     160                $this->assertFalse( taxonomy_exists( $tax ) );
     161
     162                register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
     163                $this->assertTrue( taxonomy_exists( $tax ) );
     164                $this->assertTrue( is_taxonomy_hierarchical( $tax ) );
    151165
    152166                // clean up
    153                 unset($GLOBALS['wp_taxonomies'][$tax]);
     167                unset( $GLOBALS['wp_taxonomies'][ $tax ] );
    154168        }
    155169
    … …  
    176190         */
    177191        public function test_register_taxonomy_show_in_quick_edit_should_default_to_value_of_show_ui() {
    178                 register_taxonomy( 'wptests_tax_1', 'post', array(
    179                         'show_ui' => true,
    180                 ) );
    181 
    182                 register_taxonomy( 'wptests_tax_2', 'post', array(
    183                         'show_ui' => false,
    184                 ) );
     192                register_taxonomy(
     193                        'wptests_tax_1', 'post', array(
     194                                'show_ui' => true,
     195                        )
     196                );
     197
     198                register_taxonomy(
     199                        'wptests_tax_2', 'post', array(
     200                                'show_ui' => false,
     201                        )
     202                );
    185203
    186204                $tax_1 = get_taxonomy( 'wptests_tax_1' );
    … …  
    197215                // Create a taxonomy to test with
    198216                $tax = 'test_tax';
    199                 $this->assertFalse( taxonomy_exists($tax) );
     217                $this->assertFalse( taxonomy_exists( $tax ) );
    200218                register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    201219
    … …  
    235253                $this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'user' ) );
    236254
    237                 unset($GLOBALS['wp_taxonomies'][$tax]);
     255                unset( $GLOBALS['wp_taxonomies'][ $tax ] );
    238256                _unregister_post_type( $post_type );
    239257
    … …  
    263281
    264282        public function test_get_objects_in_term_should_return_objects_ids() {
    265                 $tag_id = self::factory()->tag->create();
    266                 $cat_id = self::factory()->category->create();
    267                 $posts_with_tag = array();
     283                $tag_id              = self::factory()->tag->create();
     284                $cat_id              = self::factory()->category->create();
     285                $posts_with_tag      = array();
    268286                $posts_with_category = array();
    269287
    … …  
    298316                register_taxonomy( 'wptests_tax', 'post' );
    299317
    300                 $posts = self::factory()->post->create_many( 2 );
    301                 $term_id = self::factory()->term->create( array(
    302                         'taxonomy' => 'wptests_tax',
    303                 ) );
     318                $posts   = self::factory()->post->create_many( 2 );
     319                $term_id = self::factory()->term->create(
     320                        array(
     321                                'taxonomy' => 'wptests_tax',
     322                        )
     323                );
    304324
    305325                wp_set_object_terms( $posts[1], $term_id, 'wptests_tax' );
    … …  
    321341                register_taxonomy( 'wptests_tax', 'post' );
    322342
    323                 $posts = self::factory()->post->create_many( 2 );
    324                 $term_id = self::factory()->term->create( array(
    325                         'taxonomy' => 'wptests_tax',
    326                 ) );
     343                $posts   = self::factory()->post->create_many( 2 );
     344                $term_id = self::factory()->term->create(
     345                        array(
     346                                'taxonomy' => 'wptests_tax',
     347                        )
     348                );
    327349
    328350                wp_set_object_terms( $posts[1], $term_id, 'wptests_tax' );
    … …  
    344366                register_taxonomy( 'wptests_tax', 'post' );
    345367
    346                 $posts = self::factory()->post->create_many( 2 );
    347                 $term_id = self::factory()->term->create( array(
    348                         'taxonomy' => 'wptests_tax',
    349                 ) );
     368                $posts   = self::factory()->post->create_many( 2 );
     369                $term_id = self::factory()->term->create(
     370                        array(
     371                                'taxonomy' => 'wptests_tax',
     372                        )
     373                );
    350374
    351375                wp_set_object_terms( $posts[1], $term_id, 'wptests_tax' );
    … …  
    380404        function test_insert_category_create() {
    381405                $cat = array(
    382                         'cat_ID' => 0,
     406                        'cat_ID'   => 0,
    383407                        'taxonomy' => 'category',
    384                         'cat_name' => 'test1'
     408                        'cat_name' => 'test1',
    385409                );
    386410                $this->assertTrue( is_numeric( wp_insert_category( $cat, true ) ) );
    … …  
    389413        function test_insert_category_update() {
    390414                $cat = array(
    391                         'cat_ID' => 1,
     415                        'cat_ID'   => 1,
    392416                        'taxonomy' => 'category',
    393                         'cat_name' => 'Updated Name'
     417                        'cat_name' => 'Updated Name',
    394418                );
    395419                $this->assertEquals( 1, wp_insert_category( $cat ) );
    … …  
    398422        function test_insert_category_force_error_handle() {
    399423                $cat = array(
    400                         'cat_ID' => 0,
     424                        'cat_ID'   => 0,
    401425                        'taxonomy' => 'force_error',
    402                         'cat_name' => 'Error'
     426                        'cat_name' => 'Error',
    403427                );
    404428                $this->assertTrue( is_a( wp_insert_category( $cat, true ), 'WP_Error' ) );
    … …  
    407431        function test_insert_category_force_error_no_handle() {
    408432                $cat = array(
    409                         'cat_ID' => 0,
     433                        'cat_ID'   => 0,
    410434                        'taxonomy' => 'force_error',
    411                         'cat_name' => 'Error'
     435                        'cat_name' => 'Error',
    412436                );
    413437                $this->assertEquals( 0, wp_insert_category( $cat, false ) );
    … …  
    416440        public function test_get_ancestors_taxonomy_non_hierarchical() {
    417441                register_taxonomy( 'wptests_tax', 'post' );
    418                 $t = self::factory()->term->create( array(
    419                         'taxonomy' => 'wptests_tax',
    420                 ) );
     442                $t = self::factory()->term->create(
     443                        array(
     444                                'taxonomy' => 'wptests_tax',
     445                        )
     446                );
    421447
    422448                $this->assertSame( array(), get_ancestors( $t, 'wptests_tax' ) );
    … …  
    425451
    426452        public function test_get_ancestors_taxonomy() {
    427                 register_taxonomy( 'wptests_tax', 'post', array(
    428                         'hierarchical' => true,
    429                 ) );
    430                 $t1 = self::factory()->term->create( array(
    431                         'taxonomy' => 'wptests_tax',
    432                 ) );
    433                 $t2 = self::factory()->term->create( array(
    434                         'taxonomy' => 'wptests_tax',
    435                         'parent' => $t1,
    436                 ) );
    437                 $t3 = self::factory()->term->create( array(
    438                         'taxonomy' => 'wptests_tax',
    439                         'parent' => $t2,
    440                 ) );
    441                 $t4 = self::factory()->term->create( array(
    442                         'taxonomy' => 'wptests_tax',
    443                         'parent' => $t1,
    444                 ) );
     453                register_taxonomy(
     454                        'wptests_tax', 'post', array(
     455                                'hierarchical' => true,
     456                        )
     457                );
     458                $t1 = self::factory()->term->create(
     459                        array(
     460                                'taxonomy' => 'wptests_tax',
     461                        )
     462                );
     463                $t2 = self::factory()->term->create(
     464                        array(
     465                                'taxonomy' => 'wptests_tax',
     466                                'parent'   => $t1,
     467                        )
     468                );
     469                $t3 = self::factory()->term->create(
     470                        array(
     471                                'taxonomy' => 'wptests_tax',
     472                                'parent'   => $t2,
     473                        )
     474                );
     475                $t4 = self::factory()->term->create(
     476                        array(
     477                                'taxonomy' => 'wptests_tax',
     478                                'parent'   => $t1,
     479                        )
     480                );
    445481
    446482                $this->assertEqualSets( array( $t2, $t1 ), get_ancestors( $t3, 'wptests_tax' ) );
    … …  
    450486        public function test_get_ancestors_post_type_non_hierarchical() {
    451487                register_post_type( 'wptests_pt' );
    452                 $p = self::factory()->post->create( array(
    453                         'taxonomy' => 'wptests_pt',
    454                 ) );
     488                $p = self::factory()->post->create(
     489                        array(
     490                                'taxonomy' => 'wptests_pt',
     491                        )
     492                );
    455493
    456494                $this->assertEqualSets( array(), get_ancestors( $p, 'wptests_tax' ) );
    … …  
    458496
    459497        public function test_get_ancestors_post_type() {
    460                 register_post_type( 'wptests_pt', array(
    461                         'hierarchical' => true,
    462                 ) );
    463                 $p1 = self::factory()->post->create( array(
    464                         'post_type' => 'wptests_pt',
    465                 ) );
    466                 $p2 = self::factory()->post->create( array(
    467                         'post_type' => 'wptests_pt',
    468                         'post_parent' => $p1,
    469                 ) );
    470                 $p3 = self::factory()->post->create( array(
    471                         'post_type' => 'wptests_pt',
    472                         'post_parent' => $p2,
    473                 ) );
    474                 $p4 = self::factory()->post->create( array(
    475                         'post_type' => 'wptests_pt',
    476                         'post_parent' => $p1,
    477                 ) );
     498                register_post_type(
     499                        'wptests_pt', array(
     500                                'hierarchical' => true,
     501                        )
     502                );
     503                $p1 = self::factory()->post->create(
     504                        array(
     505                                'post_type' => 'wptests_pt',
     506                        )
     507                );
     508                $p2 = self::factory()->post->create(
     509                        array(
     510                                'post_type'   => 'wptests_pt',
     511                                'post_parent' => $p1,
     512                        )
     513                );
     514                $p3 = self::factory()->post->create(
     515                        array(
     516                                'post_type'   => 'wptests_pt',
     517                                'post_parent' => $p2,
     518                        )
     519                );
     520                $p4 = self::factory()->post->create(
     521                        array(
     522                                'post_type'   => 'wptests_pt',
     523                                'post_parent' => $p1,
     524                        )
     525                );
    478526
    479527                $this->assertEqualSets( array( $p2, $p1 ), get_ancestors( $p3, 'wptests_pt' ) );
    … …  
    485533         */
    486534        public function test_get_ancestors_taxonomy_post_type_conflict_resource_type_taxonomy() {
    487                 register_post_type( 'wptests_conflict', array(
    488                         'hierarchical' => true,
    489                 ) );
    490                 $p1 = self::factory()->post->create( array(
    491                         'post_type' => 'wptests_conflict',
    492                 ) );
    493                 $p2 = self::factory()->post->create( array(
    494                         'post_type' => 'wptests_conflict',
    495                         'post_parent' => $p1,
    496                 ) );
    497 
    498                 register_taxonomy( 'wptests_conflict', 'post', array(
    499                         'hierarchical' => true,
    500                 ) );
    501                 $t1 = self::factory()->term->create( array(
    502                         'taxonomy' => 'wptests_conflict',
    503                 ) );
    504                 $t2 = self::factory()->term->create( array(
    505                         'taxonomy' => 'wptests_conflict',
    506                         'parent' => $t1,
    507                 ) );
     535                register_post_type(
     536                        'wptests_conflict', array(
     537                                'hierarchical' => true,
     538                        )
     539                );
     540                $p1 = self::factory()->post->create(
     541                        array(
     542                                'post_type' => 'wptests_conflict',
     543                        )
     544                );
     545                $p2 = self::factory()->post->create(
     546                        array(
     547                                'post_type'   => 'wptests_conflict',
     548                                'post_parent' => $p1,
     549                        )
     550                );
     551
     552                register_taxonomy(
     553                        'wptests_conflict', 'post', array(
     554                                'hierarchical' => true,
     555                        )
     556                );
     557                $t1 = self::factory()->term->create(
     558                        array(
     559                                'taxonomy' => 'wptests_conflict',
     560                        )
     561                );
     562                $t2 = self::factory()->term->create(
     563                        array(
     564                                'taxonomy' => 'wptests_conflict',
     565                                'parent'   => $t1,
     566                        )
     567                );
    508568
    509569                $this->assertEqualSets( array( $p1 ), get_ancestors( $p2, 'wptests_conflict', 'post_type' ) );
    … …  
    517577         */
    518578        public function test_nonpublicly_queryable_taxonomy_should_not_be_queryable_using_taxname_query_var() {
    519                 register_taxonomy( 'wptests_tax', 'post', array(
    520                         'publicly_queryable' => false,
    521                 ) );
    522 
    523                 $t = self::factory()->term->create_and_get( array(
    524                         'taxonomy' => 'wptests_tax',
    525                 ) );
     579                register_taxonomy(
     580                        'wptests_tax', 'post', array(
     581                                'publicly_queryable' => false,
     582                        )
     583                );
     584
     585                $t = self::factory()->term->create_and_get(
     586                        array(
     587                                'taxonomy' => 'wptests_tax',
     588                        )
     589                );
    526590
    527591                $p = self::factory()->post->create();
    … …  
    539603                global $wp;
    540604
    541                 register_taxonomy( 'wptests_tax', 'post', array(
    542                         'publicly_queryable' => false,
    543                 ) );
    544                 $t = $this->factory->term->create_and_get( array(
    545                         'taxonomy' => 'wptests_tax',
    546                 ) );
     605                register_taxonomy(
     606                        'wptests_tax', 'post', array(
     607                                'publicly_queryable' => false,
     608                        )
     609                );
     610                $t = $this->factory->term->create_and_get(
     611                        array(
     612                                'taxonomy' => 'wptests_tax',
     613                        )
     614                );
    547615
    548616                $p = $this->factory->post->create();
    … …  
    572640         */
    573641        public function test_nonpublicly_queryable_taxonomy_should_not_be_queryable_using_taxonomy_and_term_vars() {
    574                 register_taxonomy( 'wptests_tax', 'post', array(
    575                         'publicly_queryable' => false,
    576                 ) );
    577 
    578                 $t = self::factory()->term->create_and_get( array(
    579                         'taxonomy' => 'wptests_tax',
    580                 ) );
     642                register_taxonomy(
     643                        'wptests_tax', 'post', array(
     644                                'publicly_queryable' => false,
     645                        )
     646                );
     647
     648                $t = self::factory()->term->create_and_get(
     649                        array(
     650                                'taxonomy' => 'wptests_tax',
     651                        )
     652                );
    581653
    582654                $p = self::factory()->post->create();
    … …  
    592664         */
    593665        public function test_public_taxonomy_should_be_publicly_queryable() {
    594                 register_taxonomy( 'wptests_tax', 'post', array(
    595                         'public' => true,
    596                 ) );
     666                register_taxonomy(
     667                        'wptests_tax', 'post', array(
     668                                'public' => true,
     669                        )
     670                );
    597671
    598672                $this->assertContains( 'wptests_tax', get_taxonomies( array( 'publicly_queryable' => true ) ) );
    599673
    600                 $t = self::factory()->term->create_and_get( array(
    601                         'taxonomy' => 'wptests_tax',
    602                 ) );
     674                $t = self::factory()->term->create_and_get(
     675                        array(
     676                                'taxonomy' => 'wptests_tax',
     677                        )
     678                );
    603679
    604680                $p = self::factory()->post->create();
    … …  
    614690         */
    615691        public function test_private_taxonomy_should_not_be_publicly_queryable() {
    616                 register_taxonomy( 'wptests_tax', 'post', array(
    617                         'public' => false,
    618                 ) );
     692                register_taxonomy(
     693                        'wptests_tax', 'post', array(
     694                                'public' => false,
     695                        )
     696                );
    619697
    620698                $this->assertContains( 'wptests_tax', get_taxonomies( array( 'publicly_queryable' => false ) ) );
    621699
    622                 $t = self::factory()->term->create_and_get( array(
    623                         'taxonomy' => 'wptests_tax',
    624                 ) );
     700                $t = self::factory()->term->create_and_get(
     701                        array(
     702                                'taxonomy' => 'wptests_tax',
     703                        )
     704                );
    625705
    626706                $p = self::factory()->post->create();
    … …  
    636716         */
    637717        public function test_private_taxonomy_should_be_overridden_by_publicly_queryable() {
    638                 register_taxonomy( 'wptests_tax', 'post', array(
    639                         'public' => false,
    640                         'publicly_queryable' => true,
    641                 ) );
     718                register_taxonomy(
     719                        'wptests_tax', 'post', array(
     720                                'public'             => false,
     721                                'publicly_queryable' => true,
     722                        )
     723                );
    642724
    643725                $this->assertContains( 'wptests_tax', get_taxonomies( array( 'publicly_queryable' => true ) ) );
    644726
    645                 $t = self::factory()->term->create_and_get( array(
    646                         'taxonomy' => 'wptests_tax',
    647                 ) );
     727                $t = self::factory()->term->create_and_get(
     728                        array(
     729                                'taxonomy' => 'wptests_tax',
     730                        )
     731                );
    648732
    649733                $p = self::factory()->post->create();
    … …  
    659743         */
    660744        public function test_query_var_should_be_forced_to_false_for_non_public_taxonomy() {
    661                 register_taxonomy( 'wptests_tax', 'post', array(
    662                         'public' => false,
    663                         'query_var' => true,
    664                 ) );
     745                register_taxonomy(
     746                        'wptests_tax', 'post', array(
     747                                'public'    => false,
     748                                'query_var' => true,
     749                        )
     750                );
    665751
    666752                $tax = get_taxonomy( 'wptests_tax' );
    … …  
    713799                global $wp_rewrite;
    714800
    715                 register_taxonomy( 'foo', 'post', array( 'query_var' => 'bar', 'rewrite' => true ) );
     801                register_taxonomy(
     802                        'foo', 'post', array(
     803                                'query_var' => 'bar',
     804                                'rewrite'   => true,
     805                        )
     806                );
    716807
    717808                $this->assertInternalType( 'array', $wp_rewrite->extra_permastructs['foo'] );
    718809                $this->assertTrue( unregister_taxonomy( 'foo' ) );
    719                 $this->assertFalse( isset($wp_rewrite->extra_permastructs['foo'] ) );
     810                $this->assertFalse( isset( $wp_rewrite->extra_permastructs['foo'] ) );
    720811        }
    721812
    … …  
    801892                $term_name     = 'bar';
    802893
    803                 register_taxonomy( $taxonomy_name, array( 'post' ), array(
    804                         'hierarchical' => false,
    805                         'meta_box_cb'  => 'post_categories_meta_box',
    806                 ) );
    807                 $post = self::factory()->post->create_and_get( array(
    808                         'post_type' => 'post',
    809                 ) );
    810 
    811                 $term_id  = self::factory()->term->create_object( array(
    812                         'name'     => $term_name,
    813                         'taxonomy' => $taxonomy_name,
    814                 ) );
     894                register_taxonomy(
     895                        $taxonomy_name, array( 'post' ), array(
     896                                'hierarchical' => false,
     897                                'meta_box_cb'  => 'post_categories_meta_box',
     898                        )
     899                );
     900                $post = self::factory()->post->create_and_get(
     901                        array(
     902                                'post_type' => 'post',
     903                        )
     904                );
     905
     906                $term_id = self::factory()->term->create_object(
     907                        array(
     908                                'name'     => $term_name,
     909                                'taxonomy' => $taxonomy_name,
     910                        )
     911                );
    815912
    816913                wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
    817                 $updated_post_id = edit_post( array(
    818                         'post_ID'   => $post->ID,
    819                         'post_type' => 'post',
    820                         'tax_input' => array(
    821                                 $taxonomy_name => array(
    822                                         (string) $term_id // Cast term_id as string to match whats sent in WP Admin.
     914                $updated_post_id = edit_post(
     915                        array(
     916                                'post_ID'   => $post->ID,
     917                                'post_type' => 'post',
     918                                'tax_input' => array(
     919                                        $taxonomy_name => array(
     920                                                (string) $term_id, // Cast term_id as string to match whats sent in WP Admin.
     921                                        ),
    823922                                ),
    824                         ),
    825                 ) );
    826 
    827                 $terms_obj = get_the_terms( $updated_post_id, $taxonomy_name );
     923                        )
     924                );
     925
     926                $terms_obj        = get_the_terms( $updated_post_id, $taxonomy_name );
    828927                $problematic_term = current( wp_list_pluck( $terms_obj, 'name' ) );
    829928
Note: See TracChangeset for help on using the changeset viewer.