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/term/splitSharedTerm.php

    r33611 r42343  
    2626
    2727                register_taxonomy( 'wptests_tax', 'post' );
    28                 register_taxonomy( 'wptests_tax_2', 'post', array(
    29                         'hierarchical' => true,
    30                 ) );
     28                register_taxonomy(
     29                        'wptests_tax_2', 'post', array(
     30                                'hierarchical' => true,
     31                        )
     32                );
    3133                register_taxonomy( 'wptests_tax_3', 'post' );
    3234
    … …  
    3638
    3739                // Manually modify because shared terms shouldn't naturally occur.
    38                 $wpdb->update( $wpdb->term_taxonomy,
     40                $wpdb->update(
     41                        $wpdb->term_taxonomy,
    3942                        array( 'term_id' => $t1['term_id'] ),
    4043                        array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ),
    … …  
    4346                );
    4447
    45                 $wpdb->update( $wpdb->term_taxonomy,
     48                $wpdb->update(
     49                        $wpdb->term_taxonomy,
    4650                        array( 'term_id' => $t1['term_id'] ),
    4751                        array( 'term_taxonomy_id' => $t3['term_taxonomy_id'] ),
    … …  
    5054                );
    5155
    52                 $t2_child = wp_insert_term( 'Foo Child', 'wptests_tax_2', array(
    53                         'parent' => $t1['term_id'],
    54                 ) );
     56                $t2_child = wp_insert_term(
     57                        'Foo Child', 'wptests_tax_2', array(
     58                                'parent' => $t1['term_id'],
     59                        )
     60                );
    5561
    5662                // Split the terms and store the new term IDs.
    … …  
    5965
    6066                $this->terms = array(
    61                         't1' => $t1,
    62                         't2' => $t2,
    63                         't3' => $t3,
     67                        't1'       => $t1,
     68                        't2'       => $t2,
     69                        't3'       => $t3,
    6470                        't2_child' => $t2_child,
    6571                );
    … …  
    8389         */
    8490        public function test_should_retain_child_terms_when_using_get_terms_parent() {
    85                 $children = get_terms( 'wptests_tax_2', array(
    86                         'parent' => $this->terms['t2']['term_id'],
    87                         'hide_empty' => false,
    88                 ) );
     91                $children = get_terms(
     92                        'wptests_tax_2', array(
     93                                'parent'     => $this->terms['t2']['term_id'],
     94                                'hide_empty' => false,
     95                        )
     96                );
    8997
    9098                $this->assertEquals( $this->terms['t2_child']['term_taxonomy_id'], $children[0]->term_taxonomy_id );
    … …  
    95103         */
    96104        public function test_should_retain_child_terms_when_using_get_terms_child_of() {
    97                 $children = get_terms( 'wptests_tax_2', array(
    98                         'child_of' => $this->terms['t2']['term_id'],
    99                         'hide_empty' => false,
    100                 ) );
     105                $children = get_terms(
     106                        'wptests_tax_2', array(
     107                                'child_of'   => $this->terms['t2']['term_id'],
     108                                'hide_empty' => false,
     109                        )
     110                );
    101111
    102112                $this->assertEquals( $this->terms['t2_child']['term_taxonomy_id'], $children[0]->term_taxonomy_id );
    … …  
    110120
    111121                register_taxonomy( 'wptests_tax_3', 'post' );
    112                 register_taxonomy( 'wptests_tax_4', 'post', array(
    113                         'hierarchical' => true,
    114                 ) );
     122                register_taxonomy(
     123                        'wptests_tax_4', 'post', array(
     124                                'hierarchical' => true,
     125                        )
     126                );
    115127
    116128                $t1 = wp_insert_term( 'Foo1', 'wptests_tax_3' );
    117129                $t2 = wp_insert_term( 'Foo1 Parent', 'wptests_tax_4' );
    118                 $t3 = wp_insert_term( 'Foo1', 'wptests_tax_4', array(
    119                         'parent' => $t2['term_id'],
    120                 ) );
    121 
    122                 // Manually modify because shared terms shouldn't naturally occur.
    123                 $wpdb->update( $wpdb->term_taxonomy,
     130                $t3 = wp_insert_term(
     131                        'Foo1', 'wptests_tax_4', array(
     132                                'parent' => $t2['term_id'],
     133                        )
     134                );
     135
     136                // Manually modify because shared terms shouldn't naturally occur.
     137                $wpdb->update(
     138                        $wpdb->term_taxonomy,
    124139                        array( 'term_id' => $t1['term_id'] ),
    125140                        array( 'term_taxonomy_id' => $t3['term_taxonomy_id'] ),
    … …  
    148163
    149164                // Manually modify because shared terms shouldn't naturally occur.
    150                 $wpdb->update( $wpdb->term_taxonomy,
     165                $wpdb->update(
     166                        $wpdb->term_taxonomy,
    151167                        array( 'term_id' => $t1['term_id'] ),
    152168                        array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ),
    … …  
    175191
    176192                // Manually modify because shared terms shouldn't naturally occur.
    177                 $wpdb->update( $wpdb->term_taxonomy,
     193                $wpdb->update(
     194                        $wpdb->term_taxonomy,
    178195                        array( 'term_id' => $t1['term_id'] ),
    179196                        array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ),
    … …  
    182199                );
    183200
    184                 $menu_id = wp_create_nav_menu( rand_str() );
    185                 $cat_menu_item = wp_update_nav_menu_item( $menu_id, 0, array(
    186                         'menu-item-type' => 'taxonomy',
    187                         'menu-item-object' => 'category',
    188                         'menu-item-object-id' => $t1['term_id'],
    189                         'menu-item-status' => 'publish'
    190                 ) );
     201                $menu_id       = wp_create_nav_menu( rand_str() );
     202                $cat_menu_item = wp_update_nav_menu_item(
     203                        $menu_id, 0, array(
     204                                'menu-item-type'      => 'taxonomy',
     205                                'menu-item-object'    => 'category',
     206                                'menu-item-object-id' => $t1['term_id'],
     207                                'menu-item-status'    => 'publish',
     208                        )
     209                );
    191210                $this->assertEquals( $t1['term_id'], get_post_meta( $cat_menu_item, '_menu_item_object_id', true ) );
    192211
    … …  
    203222                global $wpdb;
    204223
    205                 $cat_term = wp_insert_term( 'Foo Menu', 'category' );
     224                $cat_term       = wp_insert_term( 'Foo Menu', 'category' );
    206225                $shared_term_id = $cat_term['term_id'];
    207226
    208227                $nav_term_id = wp_create_nav_menu( 'Foo Menu' );
    209                 $nav_term = get_term( $nav_term_id, 'nav_menu' );
    210 
    211                 // Manually modify because shared terms shouldn't naturally occur.
    212                 $wpdb->update( $wpdb->term_taxonomy,
     228                $nav_term    = get_term( $nav_term_id, 'nav_menu' );
     229
     230                // Manually modify because shared terms shouldn't naturally occur.
     231                $wpdb->update(
     232                        $wpdb->term_taxonomy,
    213233                        array( 'term_id' => $shared_term_id ),
    214234                        array( 'term_taxonomy_id' => $nav_term->term_taxonomy_id )
    … …  
    231251                global $wpdb;
    232252
    233                 $cat_term = wp_insert_term( 'Foo Menu', 'category' );
     253                $cat_term       = wp_insert_term( 'Foo Menu', 'category' );
    234254                $shared_term_id = $cat_term['term_id'];
    235255
    236256                $nav_term_id = wp_create_nav_menu( 'Foo Menu' );
    237                 $nav_term = get_term( $nav_term_id, 'nav_menu' );
    238 
    239                 // Manually modify because shared terms shouldn't naturally occur.
    240                 $wpdb->update( $wpdb->term_taxonomy,
     257                $nav_term    = get_term( $nav_term_id, 'nav_menu' );
     258
     259                // Manually modify because shared terms shouldn't naturally occur.
     260                $wpdb->update(
     261                        $wpdb->term_taxonomy,
    241262                        array( 'term_id' => $shared_term_id ),
    242263                        array( 'term_taxonomy_id' => $nav_term->term_taxonomy_id )
    243264                );
    244265
    245                 $t1 = wp_insert_term( 'Random term', 'category' );
    246                 $cat_menu_item = wp_update_nav_menu_item( $shared_term_id, 0, array(
    247                         'menu-item-type' => 'taxonomy',
    248                         'menu-item-object' => 'category',
    249                         'menu-item-object-id' => $t1['term_id'],
    250                         'menu-item-status' => 'publish'
    251                 ) );
     266                $t1            = wp_insert_term( 'Random term', 'category' );
     267                $cat_menu_item = wp_update_nav_menu_item(
     268                        $shared_term_id, 0, array(
     269                                'menu-item-type'      => 'taxonomy',
     270                                'menu-item-object'    => 'category',
     271                                'menu-item-object-id' => $t1['term_id'],
     272                                'menu-item-status'    => 'publish',
     273                        )
     274                );
    252275
    253276                // Updating the menu will split the shared term.
    254                 $new_nav_menu_id = wp_update_nav_menu_object( $shared_term_id, array(
    255                         'description' => 'Updated Foo Menu',
    256                         'menu-name' => 'Updated Foo Menu',
    257                 ) );
     277                $new_nav_menu_id = wp_update_nav_menu_object(
     278                        $shared_term_id, array(
     279                                'description' => 'Updated Foo Menu',
     280                                'menu-name'   => 'Updated Foo Menu',
     281                        )
     282                );
    258283
    259284                $menu = wp_get_nav_menu_object( $new_nav_menu_id );
Note: See TracChangeset for help on using the changeset viewer.