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/xmlrpc/wp/editTerm.php

    r41684 r42343  
    1010
    1111    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
    12         self::$parent_term = $factory->term->create( array(
    13             'taxonomy' => 'category',
    14         ) );
    15         self::$child_term = $factory->term->create( array(
    16             'taxonomy' => 'category',
    17         ) );
    18         self::$post_tag = $factory->term->create( array(
    19             'taxonomy' => 'post_tag',
    20         ) );
     12        self::$parent_term = $factory->term->create(
     13            array(
     14                'taxonomy' => 'category',
     15            )
     16        );
     17        self::$child_term  = $factory->term->create(
     18            array(
     19                'taxonomy' => 'category',
     20            )
     21        );
     22        self::$post_tag    = $factory->term->create(
     23            array(
     24                'taxonomy' => 'post_tag',
     25            )
     26        );
    2127    }
    2228
     
    6066        $this->assertIXRError( $result );
    6167        $this->assertEquals( 404, $result->code );
    62         $this->assertEquals(  __( 'Invalid term ID.' ), $result->message );
     68        $this->assertEquals( __( 'Invalid term ID.' ), $result->message );
    6369    }
    6470
     
    6975        $this->assertIXRError( $result );
    7076        $this->assertEquals( 500, $result->code );
    71         $this->assertEquals( __('Empty Term.'), $result->message );
     77        $this->assertEquals( __( 'Empty Term.' ), $result->message );
    7278    }
    7379
     
    7581        $this->make_user_by_role( 'editor' );
    7682
    77         $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$parent_term, array( 'taxonomy' => 'category', 'name' => '' ) ) );
     83        $result = $this->myxmlrpcserver->wp_editTerm(
     84            array(
     85                1,
     86                'editor',
     87                'editor',
     88                self::$parent_term,
     89                array(
     90                    'taxonomy' => 'category',
     91                    'name'     => '',
     92                ),
     93            )
     94        );
    7895        $this->assertIXRError( $result );
    7996        $this->assertEquals( 403, $result->code );
     
    84101        $this->make_user_by_role( 'editor' );
    85102
    86         $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$post_tag, array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term ) ) );
     103        $result = $this->myxmlrpcserver->wp_editTerm(
     104            array(
     105                1,
     106                'editor',
     107                'editor',
     108                self::$post_tag,
     109                array(
     110                    'taxonomy' => 'post_tag',
     111                    'parent'   => self::$parent_term,
     112                ),
     113            )
     114        );
    87115        $this->assertIXRError( $result );
    88116        $this->assertEquals( 403, $result->code );
     
    93121        $this->make_user_by_role( 'editor' );
    94122
    95         $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) );
     123        $result = $this->myxmlrpcserver->wp_editTerm(
     124            array(
     125                1,
     126                'editor',
     127                'editor',
     128                self::$child_term,
     129                array(
     130                    'taxonomy' => 'category',
     131                    'parent'   => '',
     132                    'name'     => 'test',
     133                ),
     134            )
     135        );
    96136        $this->assertNotIXRError( $result );
    97137        $this->assertTrue( $result );
     
    101141        $this->make_user_by_role( 'editor' );
    102142
    103         $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) );
     143        $result = $this->myxmlrpcserver->wp_editTerm(
     144            array(
     145                1,
     146                'editor',
     147                'editor',
     148                self::$child_term,
     149                array(
     150                    'taxonomy' => 'category',
     151                    'parent'   => null,
     152                    'name'     => 'test',
     153                ),
     154            )
     155        );
    104156
    105157        $this->assertNotIXRError( $result );
     
    113165        $this->make_user_by_role( 'editor' );
    114166
    115         $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) );
     167        $result = $this->myxmlrpcserver->wp_editTerm(
     168            array(
     169                1,
     170                'editor',
     171                'editor',
     172                self::$child_term,
     173                array(
     174                    'taxonomy' => 'category',
     175                    'parent'   => 'dasda',
     176                    'name'     => 'test',
     177                ),
     178            )
     179        );
    116180        $this->assertIXRError( $result );
    117181        $this->assertEquals( 500, $result->code );
     
    121185        $this->make_user_by_role( 'editor' );
    122186
    123         $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) );
     187        $result = $this->myxmlrpcserver->wp_editTerm(
     188            array(
     189                1,
     190                'editor',
     191                'editor',
     192                self::$child_term,
     193                array(
     194                    'taxonomy' => 'category',
     195                    'parent'   => 9999,
     196                    'name'     => 'test',
     197                ),
     198            )
     199        );
    124200        $this->assertIXRError( $result );
    125201        $this->assertEquals( 403, $result->code );
     
    131207
    132208        $parent_term = get_term_by( 'id', self::$parent_term, 'category' );
    133         $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) );
     209        $result      = $this->myxmlrpcserver->wp_editTerm(
     210            array(
     211                1,
     212                'editor',
     213                'editor',
     214                self::$child_term,
     215                array(
     216                    'taxonomy' => 'category',
     217                    'slug'     => $parent_term->slug,
     218                ),
     219            )
     220        );
    134221        $this->assertIXRError( $result );
    135222        $this->assertEquals( 500, $result->code );
    136         $this->assertEquals( htmlspecialchars( sprintf( __('The slug “%s” is already in use by another term.'), $parent_term->slug ) ), $result->message );
     223        $this->assertEquals( htmlspecialchars( sprintf( __( 'The slug “%s” is already in use by another term.' ), $parent_term->slug ) ), $result->message );
    137224    }
    138225
     
    140227        $this->make_user_by_role( 'editor' );
    141228
    142         $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => self::$parent_term, 'description' => 'Child term', 'slug' => 'child_2' );
     229        $fields = array(
     230            'taxonomy'    => 'category',
     231            'name'        => 'Child 2',
     232            'parent'      => self::$parent_term,
     233            'description' => 'Child term',
     234            'slug'        => 'child_2',
     235        );
    143236        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, $fields ) );
    144237
     
    153246        register_taxonomy( 'wptests_tax', 'post' );
    154247
    155         $t = self::factory()->term->create( array(
    156             'taxonomy' => 'wptests_tax',
    157         ) );
     248        $t       = self::factory()->term->create(
     249            array(
     250                'taxonomy' => 'wptests_tax',
     251            )
     252        );
    158253        $meta_id = add_term_meta( $t, 'foo', 'bar' );
    159254
    160255        $this->make_user_by_role( 'editor' );
    161256
    162         $result = $this->myxmlrpcserver->wp_editTerm( array(
    163             1,
    164             'editor',
    165             'editor',
    166             $t,
    167             array(
    168                 'taxonomy' => 'wptests_tax',
    169                 'custom_fields' => array(
    170                     array(
    171                         'id' => $meta_id,
    172                         'key' => 'foo',
    173                         'value' => 'baz',
     257        $result = $this->myxmlrpcserver->wp_editTerm(
     258            array(
     259                1,
     260                'editor',
     261                'editor',
     262                $t,
     263                array(
     264                    'taxonomy'      => 'wptests_tax',
     265                    'custom_fields' => array(
     266                        array(
     267                            'id'    => $meta_id,
     268                            'key'   => 'foo',
     269                            'value' => 'baz',
     270                        ),
    174271                    ),
    175272                ),
    176             ),
    177         ) );
     273            )
     274        );
    178275
    179276        $this->assertNotIXRError( $result );
     
    189286        register_taxonomy( 'wptests_tax', 'post' );
    190287
    191         $t = self::factory()->term->create( array(
    192             'taxonomy' => 'wptests_tax',
    193         ) );
     288        $t       = self::factory()->term->create(
     289            array(
     290                'taxonomy' => 'wptests_tax',
     291            )
     292        );
    194293        $meta_id = add_term_meta( $t, 'foo', 'bar' );
    195294
    196295        $this->make_user_by_role( 'editor' );
    197296
    198         $result = $this->myxmlrpcserver->wp_editTerm( array(
    199             1,
    200             'editor',
    201             'editor',
    202             $t,
    203             array(
    204                 'taxonomy' => 'wptests_tax',
    205                 'custom_fields' => array(
    206                     array(
    207                         'id' => $meta_id,
     297        $result = $this->myxmlrpcserver->wp_editTerm(
     298            array(
     299                1,
     300                'editor',
     301                'editor',
     302                $t,
     303                array(
     304                    'taxonomy'      => 'wptests_tax',
     305                    'custom_fields' => array(
     306                        array(
     307                            'id' => $meta_id,
     308                        ),
    208309                    ),
    209310                ),
    210             ),
    211         ) );
     311            )
     312        );
    212313
    213314        $this->assertNotIXRError( $result );
Note: See TracChangeset for help on using the changeset viewer.