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/query/isTerm.php

    r37954 r42343  
    2929
    3030        $GLOBALS['wp_the_query'] = new WP_Query();
    31         $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
     31        $GLOBALS['wp_query']     = $GLOBALS['wp_the_query'];
    3232
    3333        $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     
    3838        flush_rewrite_rules();
    3939
    40         $this->tag_id = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) );
    41         $this->cat_id = self::factory()->category->create( array( 'slug' => 'cat-slug' ) );
    42         $this->tax_id = self::factory()->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) );
    43         $this->tax_id2 = self::factory()->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) );
     40        $this->tag_id  = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) );
     41        $this->cat_id  = self::factory()->category->create( array( 'slug' => 'cat-slug' ) );
     42        $this->tax_id  = self::factory()->term->create(
     43            array(
     44                'taxonomy' => 'testtax',
     45                'slug'     => 'tax-slug',
     46            )
     47        );
     48        $this->tax_id2 = self::factory()->term->create(
     49            array(
     50                'taxonomy' => 'testtax',
     51                'slug'     => 'tax-slug2',
     52            )
     53        );
    4454        $this->post_id = self::factory()->post->create();
    4555        wp_set_object_terms( $this->post_id, $this->cat_id, 'category' );
     
    6979    function test_tag_action_tax() {
    7080        // tag with tax added
    71         $this->go_to( home_url( "/tag/tag-slug/" ) );
     81        $this->go_to( home_url( '/tag/tag-slug/' ) );
    7282        $this->assertQueryTrue( 'is_tag', 'is_archive' );
    7383        $this->assertNotEmpty( get_query_var( 'tax_query' ) );
     
    105115    function test_cat_action_tax() {
    106116        // category with tax added
    107         $this->go_to( home_url( "/category/cat-slug/" ) );
     117        $this->go_to( home_url( '/category/cat-slug/' ) );
    108118        $this->assertQueryTrue( 'is_category', 'is_archive' );
    109119        $this->assertNotEmpty( get_query_var( 'cat' ) );
     
    121131        add_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 );
    122132
    123         $this->go_to( home_url( "/category/uncategorized/" ) );
     133        $this->go_to( home_url( '/category/uncategorized/' ) );
    124134        $this->assertQueryTrue( 'is_category', 'is_archive' );
    125135        $this->assertNotEmpty( get_query_var( 'cat' ) );
     
    176186
    177187    function pre_get_posts_tax_category_tax_query( &$query ) {
    178         $query->set( 'tax_query', array(
    179             array( 'taxonomy' => 'testtax', 'field' => 'term_id', 'terms' => $this->tax_id )
    180         ) );
     188        $query->set(
     189            'tax_query', array(
     190                array(
     191                    'taxonomy' => 'testtax',
     192                    'field'    => 'term_id',
     193                    'terms'    => $this->tax_id,
     194                ),
     195            )
     196        );
    181197    }
    182198
     
    193209                array(
    194210                    'taxonomy' => 'testtax',
    195                     'field' => 'term_id',
    196                     'terms' => array(
     211                    'field'    => 'term_id',
     212                    'terms'    => array(
    197213                        $this->tax_id,
    198214                    ),
    199215                ),
    200             )
    201         );
    202 
    203         $q = new WP_Query( $args );
     216            ),
     217        );
     218
     219        $q      = new WP_Query( $args );
    204220        $object = $q->get_queried_object();
    205221
     
    221237                array(
    222238                    'taxonomy' => 'testtax',
    223                     'field' => 'slug',
    224                     'terms' => array(
     239                    'field'    => 'slug',
     240                    'terms'    => array(
    225241                        'tax-slug',
    226242                    ),
    227243                ),
    228             )
    229         );
    230 
    231         $q = new WP_Query( $args );
     244            ),
     245        );
     246
     247        $q      = new WP_Query( $args );
    232248        $object = $q->get_queried_object();
    233249
     
    246262
    247263        register_taxonomy( 'testtax2', 'post' );
    248         $testtax2_term_id = self::factory()->term->create( array(
    249             'taxonomy' => 'testtax2',
    250             'slug' => 'testtax2-slug',
    251         ) );
     264        $testtax2_term_id = self::factory()->term->create(
     265            array(
     266                'taxonomy' => 'testtax2',
     267                'slug'     => 'testtax2-slug',
     268            )
     269        );
    252270
    253271        $args = array(
     
    256274                array(
    257275                    'taxonomy' => 'testtax',
    258                     'field' => 'slug',
    259                     'terms' => array(
     276                    'field'    => 'slug',
     277                    'terms'    => array(
    260278                        'tax-slug',
    261279                    ),
     
    263281                array(
    264282                    'taxonomy' => 'testtax2',
    265                     'field' => 'slug',
    266                     'terms' => array(
     283                    'field'    => 'slug',
     284                    'terms'    => array(
    267285                        'testtax2-slug',
    268286                    ),
    269287                ),
    270             )
    271         );
    272 
    273         $q = new WP_Query( $args );
     288            ),
     289        );
     290
     291        $q      = new WP_Query( $args );
    274292        $object = $q->get_queried_object();
    275293
Note: See TracChangeset for help on using the changeset viewer.