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/admin/includesListTable.php

    r41929 r42343  
    55 */
    66class Tests_Admin_includesListTable extends WP_UnitTestCase {
    7         protected static $top = array();
    8         protected static $children = array();
     7        protected static $top           = array();
     8        protected static $children      = array();
    99        protected static $grandchildren = array();
    10         protected static $post_ids = array();
     10        protected static $post_ids      = array();
    1111
    1212        /**
    … …  
    2626                $num_posts = 5;
    2727                foreach ( range( 1, $num_posts ) as $i ) {
    28                         $p = $factory->post->create_and_get( array(
    29                                 'post_type'  => 'page',
    30                                 'post_title' => sprintf( 'Top Level Page %d', $i ),
    31                         ) );
    32 
    33                         self::$top[ $i ] = $p;
     28                        $p = $factory->post->create_and_get(
     29                                array(
     30                                        'post_type'  => 'page',
     31                                        'post_title' => sprintf( 'Top Level Page %d', $i ),
     32                                )
     33                        );
     34
     35                        self::$top[ $i ]  = $p;
    3436                        self::$post_ids[] = $p->ID;
    3537                }
    … …  
    3941                foreach ( self::$top as $top => $top_page ) {
    4042                        foreach ( range( 1, $num_children ) as $i ) {
    41                                 $p = $factory->post->create_and_get( array(
    42                                         'post_type'   => 'page',
    43                                         'post_parent' => $top_page->ID,
    44                                         'post_title'  => sprintf( 'Child %d', $i ),
    45                                 ) );
     43                                $p = $factory->post->create_and_get(
     44                                        array(
     45                                                'post_type'   => 'page',
     46                                                'post_parent' => $top_page->ID,
     47                                                'post_title'  => sprintf( 'Child %d', $i ),
     48                                        )
     49                                );
    4650
    4751                                self::$children[ $top ][ $i ] = $p;
    48                                 self::$post_ids[] = $p->ID;
     52                                self::$post_ids[]             = $p->ID;
    4953                        }
    5054                }
    … …  
    5559                        foreach ( self::$children[ $top ] as $child => $child_page ) {
    5660                                foreach ( range( 1, $num_grandchildren ) as $i ) {
    57                                         $p = $factory->post->create_and_get( array(
    58                                                 'post_type'   => 'page',
    59                                                 'post_parent' => $child_page->ID,
    60                                                 'post_title'  => sprintf( 'Grandchild %d', $i ),
    61                                         ) );
     61                                        $p = $factory->post->create_and_get(
     62                                                array(
     63                                                        'post_type'   => 'page',
     64                                                        'post_parent' => $child_page->ID,
     65                                                        'post_title'  => sprintf( 'Grandchild %d', $i ),
     66                                                )
     67                                        );
    6268
    6369                                        self::$grandchildren[ $top ][ $child ][ $i ] = $p;
    64                                         self::$post_ids[] = $p->ID;
     70                                        self::$post_ids[]                            = $p->ID;
    6571                                }
    6672                        }
    … …  
    7278         */
    7379        function test_list_hierarchical_pages_first_page() {
    74                 $this->_test_list_hierarchical_page( array(
    75                         'paged'          => 1,
    76                         'posts_per_page' => 2,
    77                 ), array(
    78                         self::$top[1]->ID,
    79                         self::$children[1][1]->ID,
    80                 ) );
     80                $this->_test_list_hierarchical_page(
     81                        array(
     82                                'paged'          => 1,
     83                                'posts_per_page' => 2,
     84                        ), array(
     85                                self::$top[1]->ID,
     86                                self::$children[1][1]->ID,
     87                        )
     88                );
    8189        }
    8290
    … …  
    8593         */
    8694        function test_list_hierarchical_pages_second_page() {
    87                 $this->_test_list_hierarchical_page( array(
    88                         'paged'          => 2,
    89                         'posts_per_page' => 2,
    90                 ), array(
    91                         self::$top[1]->ID,
    92                         self::$children[1][2]->ID,
    93                         self::$children[1][3]->ID,
    94                 ) );
     95                $this->_test_list_hierarchical_page(
     96                        array(
     97                                'paged'          => 2,
     98                                'posts_per_page' => 2,
     99                        ), array(
     100                                self::$top[1]->ID,
     101                                self::$children[1][2]->ID,
     102                                self::$children[1][3]->ID,
     103                        )
     104                );
    95105        }
    96106
    … …  
    99109         */
    100110        function test_search_hierarchical_pages_first_page() {
    101                 $this->_test_list_hierarchical_page( array(
    102                         'paged'          => 1,
    103                         'posts_per_page' => 2,
    104                         's'              => 'Child',
    105                 ), array(
    106                         self::$children[1][1]->ID,
    107                         self::$children[1][2]->ID,
    108                 ) );
     111                $this->_test_list_hierarchical_page(
     112                        array(
     113                                'paged'          => 1,
     114                                'posts_per_page' => 2,
     115                                's'              => 'Child',
     116                        ), array(
     117                                self::$children[1][1]->ID,
     118                                self::$children[1][2]->ID,
     119                        )
     120                );
    109121        }
    110122
    … …  
    113125         */
    114126        function test_search_hierarchical_pages_second_page() {
    115                 $this->_test_list_hierarchical_page( array(
    116                         'paged'          => 2,
    117                         'posts_per_page' => 2,
    118                         's'              => 'Top',
    119                 ), array(
    120                         self::$top[3]->ID,
    121                         self::$top[4]->ID,
    122                 ) );
     127                $this->_test_list_hierarchical_page(
     128                        array(
     129                                'paged'          => 2,
     130                                'posts_per_page' => 2,
     131                                's'              => 'Top',
     132                        ), array(
     133                                self::$top[3]->ID,
     134                                self::$top[4]->ID,
     135                        )
     136                );
    123137        }
    124138
    … …  
    128142        function test_grandchildren_hierarchical_pages_first_page() {
    129143                // page 6 is the first page with grandchildren
    130                 $this->_test_list_hierarchical_page( array(
    131                         'paged'          => 6,
    132                         'posts_per_page' => 2,
    133                 ), array(
    134                         self::$top[3]->ID,
    135                         self::$children[3][1]->ID,
    136                         self::$grandchildren[3][1][1]->ID,
    137                         self::$grandchildren[3][1][2]->ID,
    138                 ) );
     144                $this->_test_list_hierarchical_page(
     145                        array(
     146                                'paged'          => 6,
     147                                'posts_per_page' => 2,
     148                        ), array(
     149                                self::$top[3]->ID,
     150                                self::$children[3][1]->ID,
     151                                self::$grandchildren[3][1][1]->ID,
     152                                self::$grandchildren[3][1][2]->ID,
     153                        )
     154                );
    139155        }
    140156
    … …  
    144160        function test_grandchildren_hierarchical_pages_second_page() {
    145161                // page 7 is the second page with grandchildren
    146                 $this->_test_list_hierarchical_page( array(
    147                         'paged'          => 7,
    148                         'posts_per_page' => 2,
    149                 ), array(
    150                         self::$top[3]->ID,
    151                         self::$children[3][1]->ID,
    152                         self::$grandchildren[3][1][3]->ID,
    153                         self::$children[3][2]->ID,
    154                 ) );
     162                $this->_test_list_hierarchical_page(
     163                        array(
     164                                'paged'          => 7,
     165                                'posts_per_page' => 2,
     166                        ), array(
     167                                self::$top[3]->ID,
     168                                self::$children[3][1]->ID,
     169                                self::$grandchildren[3][1][3]->ID,
     170                                self::$children[3][2]->ID,
     171                        )
     172                );
    155173        }
    156174
    … …  
    167185                $GLOBALS['per_page'] = $args['posts_per_page'];
    168186
    169                 $args = array_merge( array(
    170                         'post_type' => 'page',
    171                 ), $args );
     187                $args = array_merge(
     188                        array(
     189                                'post_type' => 'page',
     190                        ), $args
     191                );
    172192
    173193                // Mimic the behaviour of `wp_edit_posts_query()`:
Note: See TracChangeset for help on using the changeset viewer.