Make WordPress Core


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

    r35242 r42343  
    1010
    1111    public function test_term_exists_term_int_taxonomy_nonempty_term_exists() {
    12         $t = self::factory()->term->create( array(
    13             'taxonomy' => 'post_tag',
    14         ) );
     12        $t = self::factory()->term->create(
     13            array(
     14                'taxonomy' => 'post_tag',
     15            )
     16        );
    1517
    1618        $found = term_exists( intval( $t ), 'post_tag' );
     
    2325
    2426    public function test_term_exists_term_int_taxonomy_nonempty_wrong_taxonomy() {
    25         $t = self::factory()->term->create( array(
    26             'taxonomy' => 'post_tag',
    27         ) );
     27        $t = self::factory()->term->create(
     28            array(
     29                'taxonomy' => 'post_tag',
     30            )
     31        );
    2832
    2933        $this->assertNull( term_exists( intval( $t ), 'foo' ) );
     
    3135
    3236    public function test_term_exists_term_int_taxonomy_empty_term_exists() {
    33         $t = self::factory()->term->create( array(
    34             'taxonomy' => 'post_tag',
    35         ) );
     37        $t = self::factory()->term->create(
     38            array(
     39                'taxonomy' => 'post_tag',
     40            )
     41        );
    3642
    3743        $found = term_exists( intval( $t ), 'post_tag' );
     
    4450
    4551    public function test_term_exists_unslash_term() {
    46         $t = self::factory()->term->create( array(
    47             'taxonomy' => 'post_tag',
    48             'name' => 'I "love" WordPress\'s taxonomy system',
    49         ) );
     52        $t = self::factory()->term->create(
     53            array(
     54                'taxonomy' => 'post_tag',
     55                'name'     => 'I "love" WordPress\'s taxonomy system',
     56            )
     57        );
    5058
    5159        $found = term_exists( 'I \"love\" WordPress\\\'s taxonomy system' );
     
    5462
    5563    public function test_term_exists_trim_term() {
    56         $t = self::factory()->term->create( array(
    57             'taxonomy' => 'post_tag',
    58             'slug' => 'foo',
    59         ) );
     64        $t = self::factory()->term->create(
     65            array(
     66                'taxonomy' => 'post_tag',
     67                'slug'     => 'foo',
     68            )
     69        );
    6070
    6171        $found = term_exists( '  foo  ' );
     
    8191
    8292    public function test_term_exists_taxonomy_nonempty_parent_nonempty_match_slug() {
    83         register_taxonomy( 'foo', 'post', array(
    84             'hierarchical' => true,
    85         ) );
    86 
    87         $parent_term = self::factory()->term->create( array(
    88             'taxonomy' => 'foo',
    89         ) );
    90 
    91         $t = self::factory()->term->create( array(
    92             'taxonomy' => 'foo',
    93             'parent' => $parent_term,
    94             'slug' => 'child-term',
    95         ) );
     93        register_taxonomy(
     94            'foo', 'post', array(
     95                'hierarchical' => true,
     96            )
     97        );
     98
     99        $parent_term = self::factory()->term->create(
     100            array(
     101                'taxonomy' => 'foo',
     102            )
     103        );
     104
     105        $t = self::factory()->term->create(
     106            array(
     107                'taxonomy' => 'foo',
     108                'parent'   => $parent_term,
     109                'slug'     => 'child-term',
     110            )
     111        );
    96112
    97113        $found = term_exists( 'child-term', 'foo', $parent_term );
     
    107123     */
    108124    public function test_term_exists_taxonomy_nonempty_parent_0_should_return_false_for_child_term() {
    109         register_taxonomy( 'foo', 'post', array(
    110             'hierarchical' => true,
    111         ) );
    112 
    113         $parent_term = self::factory()->term->create( array(
    114             'taxonomy' => 'foo',
    115         ) );
    116 
    117         $t = self::factory()->term->create( array(
    118             'taxonomy' => 'foo',
    119             'parent' => $parent_term,
    120             'slug' => 'child-term',
    121         ) );
     125        register_taxonomy(
     126            'foo', 'post', array(
     127                'hierarchical' => true,
     128            )
     129        );
     130
     131        $parent_term = self::factory()->term->create(
     132            array(
     133                'taxonomy' => 'foo',
     134            )
     135        );
     136
     137        $t = self::factory()->term->create(
     138            array(
     139                'taxonomy' => 'foo',
     140                'parent'   => $parent_term,
     141                'slug'     => 'child-term',
     142            )
     143        );
    122144
    123145        $found = term_exists( 'child-term', 'foo', 0 );
     
    129151
    130152    public function test_term_exists_taxonomy_nonempty_parent_nonempty_match_name() {
    131         register_taxonomy( 'foo', 'post', array(
    132             'hierarchical' => true,
    133         ) );
    134 
    135         $parent_term = self::factory()->term->create( array(
    136             'taxonomy' => 'foo',
    137         ) );
    138 
    139         $t = self::factory()->term->create( array(
    140             'taxonomy' => 'foo',
    141             'parent' => $parent_term,
    142             'name' => 'Child Term',
    143         ) );
     153        register_taxonomy(
     154            'foo', 'post', array(
     155                'hierarchical' => true,
     156            )
     157        );
     158
     159        $parent_term = self::factory()->term->create(
     160            array(
     161                'taxonomy' => 'foo',
     162            )
     163        );
     164
     165        $t = self::factory()->term->create(
     166            array(
     167                'taxonomy' => 'foo',
     168                'parent'   => $parent_term,
     169                'name'     => 'Child Term',
     170            )
     171        );
    144172
    145173        $found = term_exists( 'Child Term', 'foo', $parent_term );
     
    154182        register_taxonomy( 'foo', 'post', array() );
    155183
    156         $t = self::factory()->term->create( array(
    157             'taxonomy' => 'foo',
    158             'slug' => 'kewl-dudez',
    159         ) );
     184        $t = self::factory()->term->create(
     185            array(
     186                'taxonomy' => 'foo',
     187                'slug'     => 'kewl-dudez',
     188            )
     189        );
    160190
    161191        $found = term_exists( 'kewl-dudez', 'foo' );
     
    170200        register_taxonomy( 'foo', 'post', array() );
    171201
    172         $t = self::factory()->term->create( array(
    173             'taxonomy' => 'foo',
    174             'name' => 'Kewl Dudez',
    175         ) );
     202        $t = self::factory()->term->create(
     203            array(
     204                'taxonomy' => 'foo',
     205                'name'     => 'Kewl Dudez',
     206            )
     207        );
    176208
    177209        $found = term_exists( 'Kewl Dudez', 'foo' );
     
    186218        register_taxonomy( 'foo', 'post', array() );
    187219
    188         $t = self::factory()->term->create( array(
    189             'taxonomy' => 'foo',
    190             'name' => 'juicy-fruit',
    191         ) );
     220        $t = self::factory()->term->create(
     221            array(
     222                'taxonomy' => 'foo',
     223                'name'     => 'juicy-fruit',
     224            )
     225        );
    192226
    193227        $found = term_exists( 'juicy-fruit' );
     
    202236        register_taxonomy( 'foo', 'post', array() );
    203237
    204         $t = self::factory()->term->create( array(
    205             'taxonomy' => 'foo',
    206             'name' => 'Juicy Fruit',
    207         ) );
     238        $t = self::factory()->term->create(
     239            array(
     240                'taxonomy' => 'foo',
     241                'name'     => 'Juicy Fruit',
     242            )
     243        );
    208244
    209245        $found = term_exists( 'Juicy Fruit' );
     
    220256        // insert a term
    221257        $term = rand_str();
    222         $t = wp_insert_term( $term, 'wptests_tax' );
     258        $t    = wp_insert_term( $term, 'wptests_tax' );
    223259        $this->assertInternalType( 'array', $t );
    224         $this->assertEquals( $t['term_id'], term_exists($t['term_id']) );
    225         $this->assertEquals( $t['term_id'], term_exists($term) );
     260        $this->assertEquals( $t['term_id'], term_exists( $t['term_id'] ) );
     261        $this->assertEquals( $t['term_id'], term_exists( $term ) );
    226262
    227263        // clean up
     
    231267
    232268    function test_term_exists_unknown() {
    233         $this->assertNull( term_exists(rand_str()) );
    234         $this->assertEquals( 0, term_exists(0) );
    235         $this->assertEquals( 0, term_exists('') );
    236         $this->assertEquals( 0, term_exists(NULL) );
     269        $this->assertNull( term_exists( rand_str() ) );
     270        $this->assertEquals( 0, term_exists( 0 ) );
     271        $this->assertEquals( 0, term_exists( '' ) );
     272        $this->assertEquals( 0, term_exists( null ) );
    237273    }
    238274}
Note: See TracChangeset for help on using the changeset viewer.