Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (8 years ago)
Author:
pento
Message:

Coding Standards: Upgrade WPCS to 1.0.0

WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:

  • Multiline function calls must now put each parameter on a new line.
  • Auto-formatting files is now part of the grunt precommit script.
  • Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getPostTypeLabels.php

    r42490 r43571  
    66class Tests_Get_Post_Type_Labels extends WP_UnitTestCase {
    77        public function test_returns_an_object() {
    8                 $this->assertInternalType( 'object', get_post_type_labels( (object) array(
    9                         'name'         => 'foo',
    10                         'labels'       => array(),
    11                         'hierarchical' => false,
    12                 ) ) );
     8                $this->assertInternalType(
     9                        'object',
     10                        get_post_type_labels(
     11                                (object) array(
     12                                        'name'         => 'foo',
     13                                        'labels'       => array(),
     14                                        'hierarchical' => false,
     15                                )
     16                        )
     17                );
    1318        }
    1419
    1520        public function test_returns_hierachical_labels() {
    16                 $labels = get_post_type_labels( (object) array(
    17                         'name'         => 'foo',
    18                         'labels'       => array(),
    19                         'hierarchical' => true,
    20                 ) );
     21                $labels = get_post_type_labels(
     22                        (object) array(
     23                                'name'         => 'foo',
     24                                'labels'       => array(),
     25                                'hierarchical' => true,
     26                        )
     27                );
    2128
    2229                $this->assertSame( 'Pages', $labels->name );
     
    2431
    2532        public function test_existing_labels_are_not_overridden() {
    26                 $labels = get_post_type_labels( (object) array(
    27                         'name'         => 'foo',
    28                         'labels'       => array(
    29                                 'singular_name' => 'Foo',
    30                         ),
    31                         'hierarchical' => false,
    32                 ) );
     33                $labels = get_post_type_labels(
     34                        (object) array(
     35                                'name'         => 'foo',
     36                                'labels'       => array(
     37                                        'singular_name' => 'Foo',
     38                                ),
     39                                'hierarchical' => false,
     40                        )
     41                );
    3342
    3443                $this->assertSame( 'Foo', $labels->singular_name );
     
    3645
    3746        public function test_name_admin_bar_label_should_fall_back_to_singular_name() {
    38                 $labels = get_post_type_labels( (object) array(
    39                         'name'         => 'foo',
    40                         'labels'       => array(
    41                                 'singular_name' => 'Foo',
    42                         ),
    43                         'hierarchical' => false,
    44                 ) );
     47                $labels = get_post_type_labels(
     48                        (object) array(
     49                                'name'         => 'foo',
     50                                'labels'       => array(
     51                                        'singular_name' => 'Foo',
     52                                ),
     53                                'hierarchical' => false,
     54                        )
     55                );
    4556
    4657                $this->assertSame( 'Foo', $labels->name_admin_bar );
     
    4960
    5061        public function test_name_admin_bar_label_should_fall_back_to_post_type_name() {
    51                 $labels = get_post_type_labels( (object) array(
    52                         'name'         => 'bar',
    53                         'labels'       => array(),
    54                         'hierarchical' => false,
    55                 ) );
     62                $labels = get_post_type_labels(
     63                        (object) array(
     64                                'name'         => 'bar',
     65                                'labels'       => array(),
     66                                'hierarchical' => false,
     67                        )
     68                );
    5669
    5770                $this->assertSame( 'bar', $labels->name_admin_bar );
     
    5972
    6073        public function test_menu_name_should_fall_back_to_name() {
    61                 $labels = get_post_type_labels( (object) array(
    62                         'name'         => 'foo',
    63                         'labels'       => array(
    64                                 'name' => 'Bar',
    65                         ),
    66                         'hierarchical' => false,
    67                 ) );
     74                $labels = get_post_type_labels(
     75                        (object) array(
     76                                'name'         => 'foo',
     77                                'labels'       => array(
     78                                        'name' => 'Bar',
     79                                ),
     80                                'hierarchical' => false,
     81                        )
     82                );
    6883
    6984                $this->assertSame( 'Bar', $labels->menu_name );
     
    7186
    7287        public function test_labels_should_be_added_when_registering_a_post_type() {
    73                 $post_type_object = register_post_type( 'foo', array(
    74                         'labels' => array(
    75                                 'singular_name' => 'bar',
    76                         ),
    77                 ) );
     88                $post_type_object = register_post_type(
     89                        'foo',
     90                        array(
     91                                'labels' => array(
     92                                        'singular_name' => 'bar',
     93                                ),
     94                        )
     95                );
    7896
    7997                unregister_post_type( 'foo' );
     
    85103
    86104        public function test_label_should_be_derived_from_labels_when_registering_a_post_type() {
    87                 $post_type_object = register_post_type( 'foo', array(
    88                         'labels' => array(
    89                                 'name' => 'bar',
    90                         ),
    91                 ) );
     105                $post_type_object = register_post_type(
     106                        'foo',
     107                        array(
     108                                'labels' => array(
     109                                        'name' => 'bar',
     110                                ),
     111                        )
     112                );
    92113
    93114                $this->assertSame( 'bar', $post_type_object->label );
Note: See TracChangeset for help on using the changeset viewer.