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

    r41662 r42343  
    5454        add_term_meta( $t, 'foo1', 'baz' );
    5555
    56         $found = get_term_meta( $t );
     56        $found    = get_term_meta( $t );
    5757        $expected = array(
    58             'foo' => array( 'bar' ),
     58            'foo'  => array( 'bar' ),
    5959            'foo1' => array( 'baz' ),
    6060        );
     
    6969        add_term_meta( $t, 'foo1', 'baz' );
    7070
    71         $found = get_term_meta( $t, 'foo' );
     71        $found    = get_term_meta( $t, 'foo' );
    7272        $expected = array( 'bar', 'baz' );
    7373
     
    155155     */
    156156    public function test_lazy_load_term_meta_should_fall_back_on_update_post_term_cache() {
    157         $q = new WP_Query( array(
    158             'update_post_term_cache' => true,
    159         ) );
     157        $q = new WP_Query(
     158            array(
     159                'update_post_term_cache' => true,
     160            )
     161        );
    160162
    161163        $this->assertTrue( $q->get( 'lazy_load_term_meta' ) );
    162164
    163         $q = new WP_Query( array(
    164             'update_post_term_cache' => false,
    165         ) );
     165        $q = new WP_Query(
     166            array(
     167                'update_post_term_cache' => false,
     168            )
     169        );
    166170
    167171        $this->assertFalse( $q->get( 'lazy_load_term_meta' ) );
     
    183187        }
    184188
    185         $q = new WP_Query( array(
    186             'cache_results' => true,
    187             'update_post_term_cache' => true,
    188             'lazy_load_term_meta' => false,
    189         ) );
     189        $q = new WP_Query(
     190            array(
     191                'cache_results'          => true,
     192                'update_post_term_cache' => true,
     193                'lazy_load_term_meta'    => false,
     194            )
     195        );
    190196
    191197        if ( $q->have_posts() ) {
     
    212218
    213219        // Prime cache.
    214         $found = get_terms( 'wptests_tax', array(
    215             'hide_empty' => false,
    216             'fields' => 'ids',
    217             'meta_query' => array(
    218                 array(
    219                     'key' => 'foo',
    220                     'value' => 'bar',
    221                 ),
    222             ),
    223         ) );
     220        $found = get_terms(
     221            'wptests_tax', array(
     222                'hide_empty' => false,
     223                'fields'     => 'ids',
     224                'meta_query' => array(
     225                    array(
     226                        'key'   => 'foo',
     227                        'value' => 'bar',
     228                    ),
     229                ),
     230            )
     231        );
    224232
    225233        $this->assertEqualSets( array( $terms[0] ), $found );
     
    227235        add_term_meta( $terms[1], 'foo', 'bar' );
    228236
    229         $found = get_terms( 'wptests_tax', array(
    230             'hide_empty' => false,
    231             'fields' => 'ids',
    232             'meta_query' => array(
    233                 array(
    234                     'key' => 'foo',
    235                     'value' => 'bar',
    236                 ),
    237             ),
    238         ) );
     237        $found = get_terms(
     238            'wptests_tax', array(
     239                'hide_empty' => false,
     240                'fields'     => 'ids',
     241                'meta_query' => array(
     242                    array(
     243                        'key'   => 'foo',
     244                        'value' => 'bar',
     245                    ),
     246                ),
     247            )
     248        );
    239249
    240250        $this->assertEqualSets( array( $terms[0], $terms[1] ), $found );
     
    248258
    249259        // Prime cache.
    250         $found = get_terms( 'wptests_tax', array(
    251             'hide_empty' => false,
    252             'fields' => 'ids',
    253             'meta_query' => array(
    254                 array(
    255                     'key' => 'foo',
    256                     'value' => 'bar',
    257                 ),
    258             ),
    259         ) );
     260        $found = get_terms(
     261            'wptests_tax', array(
     262                'hide_empty' => false,
     263                'fields'     => 'ids',
     264                'meta_query' => array(
     265                    array(
     266                        'key'   => 'foo',
     267                        'value' => 'bar',
     268                    ),
     269                ),
     270            )
     271        );
    260272
    261273        $this->assertEqualSets( array( $terms[0] ), $found );
     
    263275        update_term_meta( $terms[1], 'foo', 'bar' );
    264276
    265         $found = get_terms( 'wptests_tax', array(
    266             'hide_empty' => false,
    267             'fields' => 'ids',
    268             'meta_query' => array(
    269                 array(
    270                     'key' => 'foo',
    271                     'value' => 'bar',
    272                 ),
    273             ),
    274         ) );
     277        $found = get_terms(
     278            'wptests_tax', array(
     279                'hide_empty' => false,
     280                'fields'     => 'ids',
     281                'meta_query' => array(
     282                    array(
     283                        'key'   => 'foo',
     284                        'value' => 'bar',
     285                    ),
     286                ),
     287            )
     288        );
    275289
    276290        $this->assertEqualSets( array( $terms[0], $terms[1] ), $found );
     
    284298
    285299        // Prime cache.
    286         $found = get_terms( 'wptests_tax', array(
    287             'hide_empty' => false,
    288             'fields' => 'ids',
    289             'meta_query' => array(
    290                 array(
    291                     'key' => 'foo',
    292                     'value' => 'bar',
    293                 ),
    294             ),
    295         ) );
     300        $found = get_terms(
     301            'wptests_tax', array(
     302                'hide_empty' => false,
     303                'fields'     => 'ids',
     304                'meta_query' => array(
     305                    array(
     306                        'key'   => 'foo',
     307                        'value' => 'bar',
     308                    ),
     309                ),
     310            )
     311        );
    296312
    297313        $this->assertEqualSets( array( $terms[0], $terms[1] ), $found );
     
    299315        delete_term_meta( $terms[1], 'foo', 'bar' );
    300316
    301         $found = get_terms( 'wptests_tax', array(
    302             'hide_empty' => false,
    303             'fields' => 'ids',
    304             'meta_query' => array(
    305                 array(
    306                     'key' => 'foo',
    307                     'value' => 'bar',
    308                 ),
    309             ),
    310         ) );
     317        $found = get_terms(
     318            'wptests_tax', array(
     319                'hide_empty' => false,
     320                'fields'     => 'ids',
     321                'meta_query' => array(
     322                    array(
     323                        'key'   => 'foo',
     324                        'value' => 'bar',
     325                    ),
     326                ),
     327            )
     328        );
    311329
    312330        $this->assertEqualSets( array( $terms[0] ), $found );
     
    330348
    331349        // Manually modify because shared terms shouldn't naturally occur.
    332         $wpdb->update( $wpdb->term_taxonomy,
     350        $wpdb->update(
     351            $wpdb->term_taxonomy,
    333352            array( 'term_id' => $t1['term_id'] ),
    334353            array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ),
     
    337356        );
    338357
    339         $wpdb->update( $wpdb->term_taxonomy,
     358        $wpdb->update(
     359            $wpdb->term_taxonomy,
    340360            array( 'term_id' => $t1['term_id'] ),
    341361            array( 'term_taxonomy_id' => $t3['term_taxonomy_id'] ),
     
    368388
    369389        // Manually modify because shared terms shouldn't naturally occur.
    370         $wpdb->update( $wpdb->term_taxonomy,
     390        $wpdb->update(
     391            $wpdb->term_taxonomy,
    371392            array( 'term_id' => $t1['term_id'] ),
    372393            array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ),
     
    375396        );
    376397
    377         $wpdb->update( $wpdb->term_taxonomy,
     398        $wpdb->update(
     399            $wpdb->term_taxonomy,
    378400            array( 'term_id' => $t1['term_id'] ),
    379401            array( 'term_taxonomy_id' => $t3['term_taxonomy_id'] ),
     
    412434
    413435        $term_meta_id = add_term_meta( $t, 'foo', 'bar' );
    414         $meta = has_term_meta( $t );
     436        $meta         = has_term_meta( $t );
    415437
    416438        $this->assertSame( 1, count( $meta ) );
    417439
    418440        $expected = array(
    419             'meta_key' => 'foo',
     441            'meta_key'   => 'foo',
    420442            'meta_value' => 'bar',
    421             'meta_id' => $term_meta_id,
    422             'term_id' => $t,
     443            'meta_id'    => $term_meta_id,
     444            'term_id'    => $t,
    423445        );
    424446
Note: See TracChangeset for help on using the changeset viewer.