Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 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/category.php

    r37464 r42343  
    2626        // create new taxonomy to ensure not included
    2727        register_taxonomy( 'test_tax_cat', 'post' );
    28         wp_insert_term( "test1", 'test_tax_cat' );
     28        wp_insert_term( 'test1', 'test_tax_cat' );
    2929
    3030        // Validate length is 1 + created due to uncategorized
    3131        $cat_ids = get_all_category_ids();
    32         $this->assertEquals( 3, count($cat_ids));
     32        $this->assertEquals( 3, count( $cat_ids ) );
    3333    }
    3434
     
    3939
    4040        // create Test Categories
    41         $testcat = self::factory()->category->create_and_get(
     41        $testcat  = self::factory()->category->create_and_get(
    4242            array(
    4343                'slug' => 'testcat',
    44                 'name' => 'Test Category 1'
     44                'name' => 'Test Category 1',
    4545            )
    4646        );
     
    4848            array(
    4949                'slug' => 'testcat2',
    50                 'name' => 'Test Category 2'
     50                'name' => 'Test Category 2',
    5151            )
    5252        );
     
    6969
    7070        // create Test Categories and Array Representations
    71         $testcat_array = array(
    72             'slug' => 'testmcc',
    73             'name' => 'Test MCC',
    74             'description' => 'Category Test'
    75         );
    76         $testcat = self::factory()->category->create_and_get( $testcat_array );
     71        $testcat_array            = array(
     72            'slug'        => 'testmcc',
     73            'name'        => 'Test MCC',
     74            'description' => 'Category Test',
     75        );
     76        $testcat                  = self::factory()->category->create_and_get( $testcat_array );
    7777        $testcat_array['term_id'] = $testcat->term_id;
    7878
    79         $testcat2_array = array(
    80             'slug' => 'testmcc',
    81             'name' => 'Test MCC',
     79        $testcat2_array            = array(
     80            'slug'        => 'testmcc',
     81            'name'        => 'Test MCC',
    8282            'description' => 'Category Test',
    83             'parent' => $testcat->term_id
    84         );
    85         $testcat2 = self::factory()->category->create_and_get( $testcat2_array );
     83            'parent'      => $testcat->term_id,
     84        );
     85        $testcat2                  = self::factory()->category->create_and_get( $testcat2_array );
    8686        $testcat2_array['term_id'] = $testcat2->term_id;
    8787
     
    149149            array(
    150150                'slug' => 'testcat',
    151                 'name' => 'Test Category 1'
     151                'name' => 'Test Category 1',
    152152            )
    153153        );
     
    169169            array(
    170170                'slug' => 'testcat',
    171                 'name' => 'Test Category 1'
     171                'name' => 'Test Category 1',
    172172            )
    173173        );
     
    175175        // Validate
    176176        $this->assertEquals( $testcat->term_id, get_cat_ID( $testcat->name ) );
    177         $this->assertEquals( 0, get_cat_ID( "NO CAT" ) );
     177        $this->assertEquals( 0, get_cat_ID( 'NO CAT' ) );
    178178        $this->assertEquals( 0, get_cat_ID( 12 ) );
    179179
     
    186186
    187187        // create Test Categories
    188         $root_id = self::factory()->category->create(
     188        $root_id           = self::factory()->category->create(
    189189            array(
    190190                'slug' => 'root',
    191191            )
    192192        );
    193         $root_cat_id = self::factory()->category->create(
    194             array(
    195                 'slug' => 'cat',
    196                 'parent' => $root_id
    197             )
    198         );
    199         $root_cat_cat_id = self::factory()->category->create(
    200             array(
    201                 'slug' => 'cat', //note this is modified on create
    202                 'parent' => $root_cat_id
    203             )
    204         );
    205         $root_path_id = self::factory()->category->create(
    206             array(
    207                 'slug' => 'path',
    208                 'parent' => $root_id
    209             )
    210         );
    211         $root_path_cat_id = self::factory()->category->create(
    212             array(
    213                 'slug' => 'cat', //note this is modified on create
    214                 'parent' => $root_path_id
    215             )
    216         );
    217         $root_level_id = self::factory()->category->create(
    218             array(
    219                 'slug' => 'level-1',
    220                 'parent' => $root_id
     193        $root_cat_id       = self::factory()->category->create(
     194            array(
     195                'slug'   => 'cat',
     196                'parent' => $root_id,
     197            )
     198        );
     199        $root_cat_cat_id   = self::factory()->category->create(
     200            array(
     201                'slug'   => 'cat', //note this is modified on create
     202                'parent' => $root_cat_id,
     203            )
     204        );
     205        $root_path_id      = self::factory()->category->create(
     206            array(
     207                'slug'   => 'path',
     208                'parent' => $root_id,
     209            )
     210        );
     211        $root_path_cat_id  = self::factory()->category->create(
     212            array(
     213                'slug'   => 'cat', //note this is modified on create
     214                'parent' => $root_path_id,
     215            )
     216        );
     217        $root_level_id     = self::factory()->category->create(
     218            array(
     219                'slug'   => 'level-1',
     220                'parent' => $root_id,
    221221            )
    222222        );
    223223        $root_level_cat_id = self::factory()->category->create(
    224224            array(
    225                 'slug' => 'cat', //note this is modified on create
    226                 'parent' => $root_level_id
     225                'slug'   => 'cat', //note this is modified on create
     226                'parent' => $root_level_id,
    227227            )
    228228        );
     
    232232        $this->assertEquals( $root_level_id, $ret_cat->term_id );
    233233        $this->assertNull( get_category_by_path( 'level-1', true ) );
    234         $this->assertNull( get_category_by_path( 'nocat/nocat/', true) );
     234        $this->assertNull( get_category_by_path( 'nocat/nocat/', true ) );
    235235
    236236        // Validate Partial Match
     
    241241        $ret_cat = get_category_by_path( 'root$2Fcat%20%2Flevel-1', false );
    242242        $this->assertEquals( $root_level_id, $ret_cat->term_id );
    243         $this->assertNull( get_category_by_path( 'nocat/nocat/', false) );
     243        $this->assertNull( get_category_by_path( 'nocat/nocat/', false ) );
    244244    }
    245245}
Note: See TracChangeset for help on using the changeset viewer.