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/rewrite/numericSlugs.php

    r39626 r42343  
    2525                $this->set_permalink_structure( '/%postname%/' );
    2626
    27                 $id = self::factory()->post->create( array(
    28                         'post_author'  => $this->author_id,
    29                         'post_status'  => 'publish',
    30                         'post_content' => rand_str(),
    31                         'post_title'   => '',
    32                         'post_name'    => '2015',
    33                         'post_date'    => '2015-02-01 01:00:00'
    34                 ) );
     27                $id = self::factory()->post->create(
     28                        array(
     29                                'post_author'  => $this->author_id,
     30                                'post_status'  => 'publish',
     31                                'post_content' => rand_str(),
     32                                'post_title'   => '',
     33                                'post_name'    => '2015',
     34                                'post_date'    => '2015-02-01 01:00:00',
     35                        )
     36                );
    3537
    3638                // Force an ID that resembles a year format
     
    3941                        array(
    4042                                'ID'   => '2015',
    41                                 'guid' => 'http://' . WP_TESTS_DOMAIN . '/?p=2015'
     43                                'guid' => 'http://' . WP_TESTS_DOMAIN . '/?p=2015',
    4244                        ),
    4345                        array( 'ID' => $id )
     
    5355                $this->set_permalink_structure( '/%postname%/' );
    5456
    55                 $id = self::factory()->post->create( array(
    56                         'post_author'  => $this->author_id,
    57                         'post_status'  => 'publish',
    58                         'post_content' => rand_str(),
    59                         'post_title'   => '',
    60                         'post_name'    => '2015',
    61                         'post_date'    => '2015-02-01 01:00:00'
    62                 ) );
     57                $id = self::factory()->post->create(
     58                        array(
     59                                'post_author'  => $this->author_id,
     60                                'post_status'  => 'publish',
     61                                'post_content' => rand_str(),
     62                                'post_title'   => '',
     63                                'post_name'    => '2015',
     64                                'post_date'    => '2015-02-01 01:00:00',
     65                        )
     66                );
    6367
    6468                // Force an ID that resembles a year format
     
    6771                        array(
    6872                                'ID'   => '2015',
    69                                 'guid' => 'http://' . WP_TESTS_DOMAIN . '/?p=2015'
     73                                'guid' => 'http://' . WP_TESTS_DOMAIN . '/?p=2015',
    7074                        ),
    7175                        array( 'ID' => $id )
     
    7882                $this->set_permalink_structure( '/%postname%/' );
    7983
    80                 $id = self::factory()->post->create( array(
    81                         'post_author'  => $this->author_id,
    82                         'post_status'  => 'publish',
    83                         'post_content' => rand_str(),
    84                         'post_title'   => '2015',
    85                         'post_date'    => '2015-02-01 01:00:00',
    86                 ) );
     84                $id = self::factory()->post->create(
     85                        array(
     86                                'post_author'  => $this->author_id,
     87                                'post_status'  => 'publish',
     88                                'post_content' => rand_str(),
     89                                'post_title'   => '2015',
     90                                'post_date'    => '2015-02-01 01:00:00',
     91                        )
     92                );
    8793
    8894                $this->go_to( get_permalink( $id ) );
     
    94100                $this->set_permalink_structure( '/%postname%/' );
    95101
    96                 $id = self::factory()->post->create( array(
    97                         'post_author'  => $this->author_id,
    98                         'post_status'  => 'publish',
    99                         'post_content' => rand_str(),
    100                         'post_title'   => '2015',
    101                         'post_date'    => '2015-02-01 01:00:00',
    102                 ) );
     102                $id = self::factory()->post->create(
     103                        array(
     104                                'post_author'  => $this->author_id,
     105                                'post_status'  => 'publish',
     106                                'post_content' => rand_str(),
     107                                'post_title'   => '2015',
     108                                'post_date'    => '2015-02-01 01:00:00',
     109                        )
     110                );
    103111
    104112                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     
    108116                $this->set_permalink_structure( '/%year%/%postname%/' );
    109117
    110                 $id = self::factory()->post->create( array(
    111                         'post_author'  => $this->author_id,
    112                         'post_status'  => 'publish',
    113                         'post_content' => rand_str(),
    114                         'post_title'   => '',
    115                         'post_name'    => '02',
    116                         'post_date'    => '2015-02-01 01:00:00',
    117                 ) );
     118                $id = self::factory()->post->create(
     119                        array(
     120                                'post_author'  => $this->author_id,
     121                                'post_status'  => 'publish',
     122                                'post_content' => rand_str(),
     123                                'post_title'   => '',
     124                                'post_name'    => '02',
     125                                'post_date'    => '2015-02-01 01:00:00',
     126                        )
     127                );
    118128
    119129                $this->go_to( get_permalink( $id ) );
     
    125135                $this->set_permalink_structure( '/%year%/%postname%/' );
    126136
    127                 $id = self::factory()->post->create( array(
    128                         'post_author'  => $this->author_id,
    129                         'post_status'  => 'publish',
    130                         'post_content' => rand_str(),
    131                         'post_title'   => '',
    132                         'post_name'    => '02',
    133                         'post_date'    => '2015-02-01 01:00:00',
    134                 ) );
     137                $id = self::factory()->post->create(
     138                        array(
     139                                'post_author'  => $this->author_id,
     140                                'post_status'  => 'publish',
     141                                'post_content' => rand_str(),
     142                                'post_title'   => '',
     143                                'post_name'    => '02',
     144                                'post_date'    => '2015-02-01 01:00:00',
     145                        )
     146                );
    135147
    136148                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     
    140152                $this->set_permalink_structure( '/%year%/%postname%/' );
    141153
    142                 $id = self::factory()->post->create( array(
    143                         'post_author'  => $this->author_id,
    144                         'post_status'  => 'publish',
    145                         'post_content' => rand_str(),
    146                         'post_title'   => '',
    147                         'post_name'    => '2',
    148                         'post_date'    => '2015-02-01 01:00:00',
    149                 ) );
     154                $id = self::factory()->post->create(
     155                        array(
     156                                'post_author'  => $this->author_id,
     157                                'post_status'  => 'publish',
     158                                'post_content' => rand_str(),
     159                                'post_title'   => '',
     160                                'post_name'    => '2',
     161                                'post_date'    => '2015-02-01 01:00:00',
     162                        )
     163                );
    150164
    151165                $this->go_to( get_permalink( $id ) );
     
    157171                $this->set_permalink_structure( '/%year%/%postname%/' );
    158172
    159                 $id = self::factory()->post->create( array(
    160                         'post_author'  => $this->author_id,
    161                         'post_status'  => 'publish',
    162                         'post_content' => rand_str(),
    163                         'post_title'   => '',
    164                         'post_name'    => '2',
    165                         'post_date'    => '2015-02-01 01:00:00',
    166                 ) );
     173                $id = self::factory()->post->create(
     174                        array(
     175                                'post_author'  => $this->author_id,
     176                                'post_status'  => 'publish',
     177                                'post_content' => rand_str(),
     178                                'post_title'   => '',
     179                                'post_name'    => '2',
     180                                'post_date'    => '2015-02-01 01:00:00',
     181                        )
     182                );
    167183
    168184                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     
    172188                $this->set_permalink_structure( '/%year%/%postname%/' );
    173189
    174                 $id = self::factory()->post->create( array(
    175                         'post_author'  => $this->author_id,
    176                         'post_status'  => 'publish',
    177                         'post_content' => rand_str(),
    178                         'post_title'   => '02',
    179                         'post_date'    => '2015-02-01 01:00:00',
    180                 ) );
     190                $id = self::factory()->post->create(
     191                        array(
     192                                'post_author'  => $this->author_id,
     193                                'post_status'  => 'publish',
     194                                'post_content' => rand_str(),
     195                                'post_title'   => '02',
     196                                'post_date'    => '2015-02-01 01:00:00',
     197                        )
     198                );
    181199
    182200                $this->go_to( get_permalink( $id ) );
     
    188206                $this->set_permalink_structure( '/%year%/%postname%/' );
    189207
    190                 $id = self::factory()->post->create( array(
    191                         'post_author'  => $this->author_id,
    192                         'post_status'  => 'publish',
    193                         'post_content' => rand_str(),
    194                         'post_title'   => '02',
    195                         'post_date'    => '2015-02-01 01:00:00',
    196                 ) );
     208                $id = self::factory()->post->create(
     209                        array(
     210                                'post_author'  => $this->author_id,
     211                                'post_status'  => 'publish',
     212                                'post_content' => rand_str(),
     213                                'post_title'   => '02',
     214                                'post_date'    => '2015-02-01 01:00:00',
     215                        )
     216                );
    197217
    198218                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     
    202222                $this->set_permalink_structure( '/%year%/%postname%/' );
    203223
    204                 $id = self::factory()->post->create( array(
    205                         'post_author'  => $this->author_id,
    206                         'post_status'  => 'publish',
    207                         'post_content' => rand_str(),
    208                         'post_title'   => '2',
    209                         'post_date'    => '2015-02-01 01:00:00',
    210                 ) );
     224                $id = self::factory()->post->create(
     225                        array(
     226                                'post_author'  => $this->author_id,
     227                                'post_status'  => 'publish',
     228                                'post_content' => rand_str(),
     229                                'post_title'   => '2',
     230                                'post_date'    => '2015-02-01 01:00:00',
     231                        )
     232                );
    211233
    212234                $this->go_to( get_permalink( $id ) );
     
    218240                $this->set_permalink_structure( '/%year%/%postname%/' );
    219241
    220                 $id = self::factory()->post->create( array(
    221                         'post_author'  => $this->author_id,
    222                         'post_status'  => 'publish',
    223                         'post_content' => rand_str(),
    224                         'post_title'   => '2',
    225                         'post_date'    => '2015-02-01 01:00:00',
    226                 ) );
     242                $id = self::factory()->post->create(
     243                        array(
     244                                'post_author'  => $this->author_id,
     245                                'post_status'  => 'publish',
     246                                'post_content' => rand_str(),
     247                                'post_title'   => '2',
     248                                'post_date'    => '2015-02-01 01:00:00',
     249                        )
     250                );
    227251
    228252                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     
    232256                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    233257
    234                 $id = self::factory()->post->create( array(
    235                         'post_author'  => $this->author_id,
    236                         'post_status'  => 'publish',
    237                         'post_content' => rand_str(),
    238                         'post_title'   => '',
    239                         'post_name'    => '01',
    240                         'post_date'    => '2015-02-01 01:00:00',
    241                 ) );
     258                $id = self::factory()->post->create(
     259                        array(
     260                                'post_author'  => $this->author_id,
     261                                'post_status'  => 'publish',
     262                                'post_content' => rand_str(),
     263                                'post_title'   => '',
     264                                'post_name'    => '01',
     265                                'post_date'    => '2015-02-01 01:00:00',
     266                        )
     267                );
    242268
    243269                $this->go_to( get_permalink( $id ) );
     
    249275                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    250276
    251                 $id = self::factory()->post->create( array(
    252                         'post_author'  => $this->author_id,
    253                         'post_status'  => 'publish',
    254                         'post_content' => rand_str(),
    255                         'post_title'   => '',
    256                         'post_name'    => '01',
    257                         'post_date'    => '2015-02-01 01:00:00',
    258                 ) );
     277                $id = self::factory()->post->create(
     278                        array(
     279                                'post_author'  => $this->author_id,
     280                                'post_status'  => 'publish',
     281                                'post_content' => rand_str(),
     282                                'post_title'   => '',
     283                                'post_name'    => '01',
     284                                'post_date'    => '2015-02-01 01:00:00',
     285                        )
     286                );
    259287
    260288                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     
    264292                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    265293
    266                 $id = self::factory()->post->create( array(
    267                         'post_author'  => $this->author_id,
    268                         'post_status'  => 'publish',
    269                         'post_content' => rand_str(),
    270                         'post_title'   => '01',
    271                         'post_date'    => '2015-02-01 01:00:00',
    272                 ) );
     294                $id = self::factory()->post->create(
     295                        array(
     296                                'post_author'  => $this->author_id,
     297                                'post_status'  => 'publish',
     298                                'post_content' => rand_str(),
     299                                'post_title'   => '01',
     300                                'post_date'    => '2015-02-01 01:00:00',
     301                        )
     302                );
    273303
    274304                $this->go_to( get_permalink( $id ) );
     
    280310                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    281311
    282                 $id = self::factory()->post->create( array(
    283                         'post_author'  => $this->author_id,
    284                         'post_status'  => 'publish',
    285                         'post_content' => rand_str(),
    286                         'post_title'   => '01',
    287                         'post_date'    => '2015-02-01 01:00:00',
    288                 ) );
     312                $id = self::factory()->post->create(
     313                        array(
     314                                'post_author'  => $this->author_id,
     315                                'post_status'  => 'publish',
     316                                'post_content' => rand_str(),
     317                                'post_title'   => '01',
     318                                'post_date'    => '2015-02-01 01:00:00',
     319                        )
     320                );
    289321
    290322                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     
    294326                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    295327
    296                 $id = self::factory()->post->create( array(
    297                         'post_author'  => $this->author_id,
    298                         'post_status'  => 'publish',
    299                         'post_content' => rand_str(),
    300                         'post_title'   => '01',
    301                         'post_date'    => '2015-02-01 01:00:00',
    302                 ) );
    303 
    304                 $q = new WP_Query( array(
    305                         'year'     => '2015',
    306                         'monthnum' => '02',
    307                         'day'      => '01',
    308                 ) );
     328                $id = self::factory()->post->create(
     329                        array(
     330                                'post_author'  => $this->author_id,
     331                                'post_status'  => 'publish',
     332                                'post_content' => rand_str(),
     333                                'post_title'   => '01',
     334                                'post_date'    => '2015-02-01 01:00:00',
     335                        )
     336                );
     337
     338                $q = new WP_Query(
     339                        array(
     340                                'year'     => '2015',
     341                                'monthnum' => '02',
     342                                'day'      => '01',
     343                        )
     344                );
    309345
    310346                $this->assertTrue( $q->is_day );
     
    316352
    317353                // Make sure a post is published in 2013/02, to avoid 404s.
    318                 self::factory()->post->create( array(
    319                         'post_author'  => $this->author_id,
    320                         'post_status'  => 'publish',
    321                         'post_content' => 'foo',
    322                         'post_title'   => 'bar',
    323                         'post_date'    => '2013-02-01 01:00:00',
    324                 ) );
    325 
    326                 $id = self::factory()->post->create( array(
    327                         'post_author'  => $this->author_id,
    328                         'post_status'  => 'publish',
    329                         'post_content' => 'foo',
    330                         'post_title'   => '02',
    331                         'post_date'    => '2015-02-01 01:00:00',
    332                 ) );
     354                self::factory()->post->create(
     355                        array(
     356                                'post_author'  => $this->author_id,
     357                                'post_status'  => 'publish',
     358                                'post_content' => 'foo',
     359                                'post_title'   => 'bar',
     360                                'post_date'    => '2013-02-01 01:00:00',
     361                        )
     362                );
     363
     364                $id = self::factory()->post->create(
     365                        array(
     366                                'post_author'  => $this->author_id,
     367                                'post_status'  => 'publish',
     368                                'post_content' => 'foo',
     369                                'post_title'   => '02',
     370                                'post_date'    => '2015-02-01 01:00:00',
     371                        )
     372                );
    333373
    334374                $permalink = get_permalink( $id );
     
    344384
    345385                // Make sure a post is published on 2015/01/01, to avoid 404s.
    346                 self::factory()->post->create( array(
    347                         'post_author'  => $this->author_id,
    348                         'post_status'  => 'publish',
    349                         'post_content' => 'foo',
    350                         'post_title'   => 'bar',
    351                         'post_date'    => '2015-01-02 01:00:00',
    352                 ) );
    353 
    354                 $id = self::factory()->post->create( array(
    355                         'post_author'  => $this->author_id,
    356                         'post_status'  => 'publish',
    357                         'post_content' => 'foo',
    358                         'post_title'   => '02',
    359                         'post_date'    => '2015-02-02 01:00:00',
    360                 ) );
     386                self::factory()->post->create(
     387                        array(
     388                                'post_author'  => $this->author_id,
     389                                'post_status'  => 'publish',
     390                                'post_content' => 'foo',
     391                                'post_title'   => 'bar',
     392                                'post_date'    => '2015-01-02 01:00:00',
     393                        )
     394                );
     395
     396                $id = self::factory()->post->create(
     397                        array(
     398                                'post_author'  => $this->author_id,
     399                                'post_status'  => 'publish',
     400                                'post_content' => 'foo',
     401                                'post_title'   => '02',
     402                                'post_date'    => '2015-02-02 01:00:00',
     403                        )
     404                );
    361405
    362406                $permalink = get_permalink( $id );
     
    371415                $this->set_permalink_structure( '/%year%/%postname%/' );
    372416
    373                 $id = self::factory()->post->create( array(
    374                         'post_author'  => $this->author_id,
    375                         'post_status'  => 'publish',
    376                         'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
    377                         'post_title'   => '02',
    378                         'post_date'    => '2015-02-01 01:00:00',
    379                 ) );
     417                $id = self::factory()->post->create(
     418                        array(
     419                                'post_author'  => $this->author_id,
     420                                'post_status'  => 'publish',
     421                                'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
     422                                'post_title'   => '02',
     423                                'post_date'    => '2015-02-01 01:00:00',
     424                        )
     425                );
    380426
    381427                $this->go_to( get_permalink( $id ) . '1' );
     
    387433                $this->set_permalink_structure( '/%year%/%postname%/' );
    388434
    389                 $id = self::factory()->post->create( array(
    390                         'post_author'  => $this->author_id,
    391                         'post_status'  => 'publish',
    392                         'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
    393                         'post_title'   => '02',
    394                         'post_date'    => '2015-02-05 01:00:00',
    395                 ) );
     435                $id = self::factory()->post->create(
     436                        array(
     437                                'post_author'  => $this->author_id,
     438                                'post_status'  => 'publish',
     439                                'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
     440                                'post_title'   => '02',
     441                                'post_date'    => '2015-02-05 01:00:00',
     442                        )
     443                );
    396444
    397445                $this->go_to( get_permalink( $id ) . '5' );
     
    403451                $this->set_permalink_structure( '/%year%/%postname%/' );
    404452
    405                 $id = self::factory()->post->create( array(
    406                         'post_author'  => $this->author_id,
    407                         'post_status'  => 'publish',
    408                         'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
    409                         'post_title'   => '02',
    410                         'post_date'    => '2015-02-05 01:00:00',
    411                 ) );
     453                $id = self::factory()->post->create(
     454                        array(
     455                                'post_author'  => $this->author_id,
     456                                'post_status'  => 'publish',
     457                                'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
     458                                'post_title'   => '02',
     459                                'post_date'    => '2015-02-05 01:00:00',
     460                        )
     461                );
    412462
    413463                $this->go_to( get_permalink( $id ) );
     
    420470                $this->set_permalink_structure( '/%year%/%postname%/' );
    421471
    422                 $id = self::factory()->post->create( array(
    423                         'post_author'  => $this->author_id,
    424                         'post_status'  => 'publish',
    425                         'post_content' => 'This post does not have pagination.',
    426                         'post_title'   => '02',
    427                         'post_date'    => '2015-02-05 01:00:00',
    428                 ) );
     472                $id = self::factory()->post->create(
     473                        array(
     474                                'post_author'  => $this->author_id,
     475                                'post_status'  => 'publish',
     476                                'post_content' => 'This post does not have pagination.',
     477                                'post_title'   => '02',
     478                                'post_date'    => '2015-02-05 01:00:00',
     479                        )
     480                );
    429481
    430482                $this->go_to( get_permalink( $id ) . '5' );
Note: See TracChangeset for help on using the changeset viewer.