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/query/date.php

    r38398 r42343  
    5353
    5454    public function _get_query_result( $args = array() ) {
    55         $args = wp_parse_args( $args, array(
    56             'post_status'    => 'any', // For the future post
    57             'posts_per_page' => '-1',  // To make sure results are accurate
    58             'orderby'        => 'ID',  // Same order they were created
    59             'order'          => 'ASC',
    60         ) );
     55        $args = wp_parse_args(
     56            $args, array(
     57                'post_status'    => 'any', // For the future post
     58                'posts_per_page' => '-1',  // To make sure results are accurate
     59                'orderby'        => 'ID',  // Same order they were created
     60                'order'          => 'ASC',
     61            )
     62        );
    6163
    6264        return $this->q->query( $args );
     
    6466
    6567    public function test_simple_year_expecting_results() {
    66         $posts = $this->_get_query_result( array(
    67             'year' => 2008,
    68         ) );
     68        $posts = $this->_get_query_result(
     69            array(
     70                'year' => 2008,
     71            )
     72        );
    6973
    7074        $expected_dates = array(
     
    7882
    7983    public function test_simple_year_expecting_noresults() {
    80         $posts = $this->_get_query_result( array(
    81             'year' => 2000,
    82         ) );
     84        $posts = $this->_get_query_result(
     85            array(
     86                'year' => 2000,
     87            )
     88        );
    8389
    8490        $this->assertCount( 0, $posts );
     
    8692
    8793    public function test_simple_m_with_year_expecting_results() {
    88         $posts = $this->_get_query_result( array(
    89             'm' => '2007',
    90         ) );
     94        $posts = $this->_get_query_result(
     95            array(
     96                'm' => '2007',
     97            )
     98        );
    9199
    92100        $expected_dates = array(
     
    100108
    101109    public function test_simple_m_with_year_expecting_noresults() {
    102         $posts = $this->_get_query_result( array(
    103             'm' => '1999',
    104         ) );
     110        $posts = $this->_get_query_result(
     111            array(
     112                'm' => '1999',
     113            )
     114        );
    105115
    106116        $this->assertCount( 0, $posts );
     
    108118
    109119    public function test_simple_m_with_yearmonth_expecting_results() {
    110         $posts = $this->_get_query_result( array(
    111             'm' => '202504',
    112         ) );
     120        $posts = $this->_get_query_result(
     121            array(
     122                'm' => '202504',
     123            )
     124        );
    113125
    114126        $expected_dates = array(
     
    121133
    122134    public function test_simple_m_with_yearmonth_expecting_noresults() {
    123         $posts = $this->_get_query_result( array(
    124             'm' => '202502',
    125         ) );
     135        $posts = $this->_get_query_result(
     136            array(
     137                'm' => '202502',
     138            )
     139        );
    126140
    127141        $this->assertCount( 0, $posts );
     
    129143
    130144    public function test_simple_m_with_yearmonthday_expecting_results() {
    131         $posts = $this->_get_query_result( array(
    132             'm' => '20250420',
    133         ) );
     145        $posts = $this->_get_query_result(
     146            array(
     147                'm' => '20250420',
     148            )
     149        );
    134150
    135151        $expected_dates = array(
     
    142158
    143159    public function test_simple_m_with_yearmonthday_expecting_noresults() {
    144         $posts = $this->_get_query_result( array(
    145             'm' => '20250419',
    146         ) );
     160        $posts = $this->_get_query_result(
     161            array(
     162                'm' => '20250419',
     163            )
     164        );
    147165
    148166        $this->assertCount( 0, $posts );
     
    150168
    151169    public function test_simple_m_with_yearmonthdayhour_expecting_results() {
    152         $posts = $this->_get_query_result( array(
    153             'm' => '2025042010',
    154         ) );
     170        $posts = $this->_get_query_result(
     171            array(
     172                'm' => '2025042010',
     173            )
     174        );
    155175
    156176        $expected_dates = array(
     
    163183
    164184    public function test_simple_m_with_yearmonthdayhour_expecting_noresults() {
    165         $posts = $this->_get_query_result( array(
    166             'm' => '2025042009',
    167         ) );
     185        $posts = $this->_get_query_result(
     186            array(
     187                'm' => '2025042009',
     188            )
     189        );
    168190
    169191        $this->assertCount( 0, $posts );
     
    174196     */
    175197    public function test_simple_m_with_yearmonthdayhourminute_expecting_results() {
    176         $posts = $this->_get_query_result( array(
    177             'm' => '202504201013',
    178         ) );
     198        $posts = $this->_get_query_result(
     199            array(
     200                'm' => '202504201013',
     201            )
     202        );
    179203
    180204        $expected_dates = array(
     
    190214     */
    191215    public function test_simple_m_with_yearmonthdayhourminute_expecting_noresults() {
    192         $posts = $this->_get_query_result( array(
    193             'm' => '202504201012',
    194         ) );
     216        $posts = $this->_get_query_result(
     217            array(
     218                'm' => '202504201012',
     219            )
     220        );
    195221
    196222        $this->assertCount( 0, $posts );
     
    201227     */
    202228    public function test_simple_m_with_yearmonthdayhourminutesecond_expecting_results() {
    203         $posts = $this->_get_query_result( array(
    204             'm' => '20250420101301',
    205         ) );
     229        $posts = $this->_get_query_result(
     230            array(
     231                'm' => '20250420101301',
     232            )
     233        );
    206234
    207235        $expected_dates = array(
     
    216244     */
    217245    public function test_simple_m_with_yearmonthdayhourminutesecond_expecting_noresults() {
    218         $posts = $this->_get_query_result( array(
    219             'm' => '20250420101302',
    220         ) );
     246        $posts = $this->_get_query_result(
     247            array(
     248                'm' => '20250420101302',
     249            )
     250        );
    221251
    222252        $this->assertCount( 0, $posts );
     
    227257     */
    228258    public function test_simple_m_with_yearmonthdayhourminutesecond_and_dashes_expecting_results() {
    229         $posts = $this->_get_query_result( array(
    230             'm' => '2025-04-20 10:13:00',
    231         ) );
     259        $posts = $this->_get_query_result(
     260            array(
     261                'm' => '2025-04-20 10:13:00',
     262            )
     263        );
    232264
    233265        $expected_dates = array(
     
    242274     */
    243275    public function test_simple_m_with_yearmonthdayhourminutesecond_and_dashesletters_expecting_results() {
    244         $posts = $this->_get_query_result( array(
    245             'm' => 'alpha2025-04-20 10:13:00',
    246         ) );
     276        $posts = $this->_get_query_result(
     277            array(
     278                'm' => 'alpha2025-04-20 10:13:00',
     279            )
     280        );
    247281
    248282        $expected_dates = array(
     
    257291     */
    258292    public function test_non_scalar_m_should_be_discarded() {
    259         $expected = $this->_get_query_result( );
    260         $posts    = $this->_get_query_result( array(
    261             'm' => array( '1234' ), // ignored
    262         ) );
     293        $expected = $this->_get_query_result();
     294        $posts    = $this->_get_query_result(
     295            array(
     296                'm' => array( '1234' ), // ignored
     297            )
     298        );
    263299
    264300        $this->assertEquals( $expected, $posts );
     
    266302
    267303    public function test_simple_monthnum_expecting_results() {
    268         $posts = $this->_get_query_result( array(
    269             'monthnum' => 5,
    270         ) );
     304        $posts = $this->_get_query_result(
     305            array(
     306                'monthnum' => 5,
     307            )
     308        );
    271309
    272310        $expected_dates = array(
     
    282320
    283321    public function test_simple_monthnum_expecting_noresults() {
    284         $posts = $this->_get_query_result( array(
    285             'monthnum' => 8,
    286         ) );
     322        $posts = $this->_get_query_result(
     323            array(
     324                'monthnum' => 8,
     325            )
     326        );
    287327
    288328        $this->assertCount( 0, $posts );
     
    290330
    291331    public function test_simple_w_as_in_week_expecting_results() {
    292         $posts = $this->_get_query_result( array(
    293             'w' => 24,
    294         ) );
     332        $posts = $this->_get_query_result(
     333            array(
     334                'w' => 24,
     335            )
     336        );
    295337
    296338        $expected_dates = array(
     
    304346
    305347    public function test_simple_w_as_in_week_expecting_noresults() {
    306         $posts = $this->_get_query_result( array(
    307             'w' => 2,
    308         ) );
     348        $posts = $this->_get_query_result(
     349            array(
     350                'w' => 2,
     351            )
     352        );
    309353
    310354        $this->assertCount( 0, $posts );
     
    312356
    313357    public function test_simple_day_expecting_results() {
    314         $posts = $this->_get_query_result( array(
    315             'day' => 22,
    316         ) );
     358        $posts = $this->_get_query_result(
     359            array(
     360                'day' => 22,
     361            )
     362        );
    317363
    318364        $expected_dates = array(
     
    325371
    326372    public function test_simple_day_expecting_noresults() {
    327         $posts = $this->_get_query_result( array(
    328             'day' => 30,
    329         ) );
     373        $posts = $this->_get_query_result(
     374            array(
     375                'day' => 30,
     376            )
     377        );
    330378
    331379        $this->assertCount( 0, $posts );
     
    333381
    334382    public function test_simple_hour_expecting_results() {
    335         $posts = $this->_get_query_result( array(
    336             'hour' => 21,
    337         ) );
     383        $posts = $this->_get_query_result(
     384            array(
     385                'hour' => 21,
     386            )
     387        );
    338388
    339389        $expected_dates = array(
     
    345395
    346396    public function test_simple_hour_expecting_noresults() {
    347         $posts = $this->_get_query_result( array(
    348             'hour' => 2,
    349         ) );
     397        $posts = $this->_get_query_result(
     398            array(
     399                'hour' => 2,
     400            )
     401        );
    350402
    351403        $this->assertCount( 0, $posts );
     
    353405
    354406    public function test_simple_minute_expecting_results() {
    355         $posts = $this->_get_query_result( array(
    356             'minute' => 32,
    357         ) );
     407        $posts = $this->_get_query_result(
     408            array(
     409                'minute' => 32,
     410            )
     411        );
    358412
    359413        $expected_dates = array(
     
    366420
    367421    public function test_simple_minute_expecting_noresults() {
    368         $posts = $this->_get_query_result( array(
    369             'minute' => 1,
    370         ) );
     422        $posts = $this->_get_query_result(
     423            array(
     424                'minute' => 1,
     425            )
     426        );
    371427
    372428        $this->assertCount( 0, $posts );
     
    374430
    375431    public function test_simple_second_expecting_results() {
    376         $posts = $this->_get_query_result( array(
    377             'second' => 30,
    378         ) );
     432        $posts = $this->_get_query_result(
     433            array(
     434                'second' => 30,
     435            )
     436        );
    379437
    380438        $expected_dates = array(
     
    386444
    387445    public function test_simple_second_expecting_noresults() {
    388         $posts = $this->_get_query_result( array(
    389             'second' => 50,
    390         ) );
     446        $posts = $this->_get_query_result(
     447            array(
     448                'second' => 50,
     449            )
     450        );
    391451
    392452        $this->assertCount( 0, $posts );
Note: See TracChangeset for help on using the changeset viewer.