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/canonical.php

    r38398 r42343  
    2222
    2323        if ( false !== strpos( $test_url, '%d' ) ) {
    24             if ( false !== strpos( $test_url, '/?author=%d' ) )
     24            if ( false !== strpos( $test_url, '/?author=%d' ) ) {
    2525                $test_url = sprintf( $test_url, self::$author_id );
    26             if ( false !== strpos( $test_url, '?cat=%d' ) )
     26            }
     27            if ( false !== strpos( $test_url, '?cat=%d' ) ) {
    2728                $test_url = sprintf( $test_url, self::$terms[ $expected['url'] ] );
     29            }
    2830        }
    2931
     
    4951            array( '?cat=%d', array( 'url' => '/category/parent/child-1/' ), 15256 ),
    5052            array( '?cat=%d', array( 'url' => '/category/parent/child-1/child-2/' ) ), // no children
    51             array( '/category/uncategorized/', array( 'url' => '/category/uncategorized/', 'qv' => array( 'category_name' => 'uncategorized' ) ) ),
    52             array( '/category/uncategorized/page/2/', array( 'url' => '/category/uncategorized/page/2/', 'qv' => array( 'category_name' => 'uncategorized', 'paged' => 2) ) ),
    53             array( '/category/uncategorized/?paged=2', array( 'url' => '/category/uncategorized/page/2/', 'qv' => array( 'category_name' => 'uncategorized', 'paged' => 2) ) ),
    54             array( '/category/uncategorized/?paged=2&category_name=uncategorized', array( 'url' => '/category/uncategorized/page/2/', 'qv' => array( 'category_name' => 'uncategorized', 'paged' => 2) ), 17174 ),
     53            array(
     54                '/category/uncategorized/',
     55                array(
     56                    'url' => '/category/uncategorized/',
     57                    'qv'  => array( 'category_name' => 'uncategorized' ),
     58                ),
     59            ),
     60            array(
     61                '/category/uncategorized/page/2/',
     62                array(
     63                    'url' => '/category/uncategorized/page/2/',
     64                    'qv'  => array(
     65                        'category_name' => 'uncategorized',
     66                        'paged'         => 2,
     67                    ),
     68                ),
     69            ),
     70            array(
     71                '/category/uncategorized/?paged=2',
     72                array(
     73                    'url' => '/category/uncategorized/page/2/',
     74                    'qv'  => array(
     75                        'category_name' => 'uncategorized',
     76                        'paged'         => 2,
     77                    ),
     78                ),
     79            ),
     80            array(
     81                '/category/uncategorized/?paged=2&category_name=uncategorized',
     82                array(
     83                    'url' => '/category/uncategorized/page/2/',
     84                    'qv'  => array(
     85                        'category_name' => 'uncategorized',
     86                        'paged'         => 2,
     87                    ),
     88                ),
     89                17174,
     90            ),
    5591
    5692            // Categories & Intersections with other vars
    57             array( '/category/uncategorized/?tag=post-formats', array( 'url' => '/category/uncategorized/?tag=post-formats', 'qv' => array('category_name' => 'uncategorized', 'tag' => 'post-formats') ) ),
    58             array( '/?category_name=cat-a,cat-b', array( 'url' => '/?category_name=cat-a,cat-b', 'qv' => array( 'category_name' => 'cat-a,cat-b' ) ) ),
     93            array(
     94                '/category/uncategorized/?tag=post-formats',
     95                array(
     96                    'url' => '/category/uncategorized/?tag=post-formats',
     97                    'qv'  => array(
     98                        'category_name' => 'uncategorized',
     99                        'tag'           => 'post-formats',
     100                    ),
     101                ),
     102            ),
     103            array(
     104                '/?category_name=cat-a,cat-b',
     105                array(
     106                    'url' => '/?category_name=cat-a,cat-b',
     107                    'qv'  => array( 'category_name' => 'cat-a,cat-b' ),
     108                ),
     109            ),
    59110
    60111            // Taxonomies with extra Query Vars
    61             array( '/category/cat-a/page/1/?test=one%20two', '/category/cat-a/?test=one%20two', 18086), // Extra query vars should stay encoded
     112            array( '/category/cat-a/page/1/?test=one%20two', '/category/cat-a/?test=one%20two', 18086 ), // Extra query vars should stay encoded
    62113
    63114            // Categories with Dates
    64             array( '/2008/04/?cat=1', array( 'url' => '/2008/04/?cat=1', 'qv' => array('cat' => '1', 'year' => '2008', 'monthnum' => '04' ) ), 17661 ),
    65 //          array( '/2008/?category_name=cat-a', array( 'url' => '/2008/?category_name=cat-a', 'qv' => array('category_name' => 'cat-a', 'year' => '2008' ) ) ),
    66 
    67             // Pages
    68             array( '/child-page-1/', '/parent-page/child-page-1/'),
    69             array( '/?page_id=144', '/parent-page/child-page-1/'),
     115            array(
     116                '/2008/04/?cat=1',
     117                array(
     118                    'url' => '/2008/04/?cat=1',
     119                    'qv'  => array(
     120                        'cat'      => '1',
     121                        'year'     => '2008',
     122                        'monthnum' => '04',
     123                    ),
     124                ),
     125                17661,
     126            ),
     127            //          array( '/2008/?category_name=cat-a', array( 'url' => '/2008/?category_name=cat-a', 'qv' => array('category_name' => 'cat-a', 'year' => '2008' ) ) ),
     128
     129                            // Pages
     130                            array( '/child-page-1/', '/parent-page/child-page-1/' ),
     131            array( '/?page_id=144', '/parent-page/child-page-1/' ),
    70132            array( '/abo', '/about/' ),
    71133            array( '/parent/child1/grandchild/', '/parent/child1/grandchild/' ),
     
    73135
    74136            // Posts
    75             array( '?p=587', '/2008/06/02/post-format-test-audio/'),
    76             array( '/?name=images-test', '/2008/09/03/images-test/'),
     137            array( '?p=587', '/2008/06/02/post-format-test-audio/' ),
     138            array( '/?name=images-test', '/2008/09/03/images-test/' ),
    77139            // Incomplete slug should resolve and remove the ?name= parameter
    78             array( '/?name=images-te', '/2008/09/03/images-test/', 20374),
     140            array( '/?name=images-te', '/2008/09/03/images-test/', 20374 ),
    79141            // Page slug should resolve to post slug and remove the ?pagename= parameter
    80             array( '/?pagename=images-test', '/2008/09/03/images-test/', 20374),
    81 
    82             array( '/2008/06/02/post-format-test-au/', '/2008/06/02/post-format-test-audio/'),
    83             array( '/2008/06/post-format-test-au/', '/2008/06/02/post-format-test-audio/'),
    84             array( '/2008/post-format-test-au/', '/2008/06/02/post-format-test-audio/'),
    85             array( '/2010/post-format-test-au/', '/2008/06/02/post-format-test-audio/'), // A Year the post is not in
    86             array( '/post-format-test-au/', '/2008/06/02/post-format-test-audio/'),
    87 
    88             array( '/2008/09/03/images-test/3/', array( 'url' => '/2008/09/03/images-test/3/', 'qv' => array( 'name' => 'images-test', 'year' => '2008', 'monthnum' => '09', 'day' => '03', 'page' => '3' ) ) ),
     142            array( '/?pagename=images-test', '/2008/09/03/images-test/', 20374 ),
     143
     144            array( '/2008/06/02/post-format-test-au/', '/2008/06/02/post-format-test-audio/' ),
     145            array( '/2008/06/post-format-test-au/', '/2008/06/02/post-format-test-audio/' ),
     146            array( '/2008/post-format-test-au/', '/2008/06/02/post-format-test-audio/' ),
     147            array( '/2010/post-format-test-au/', '/2008/06/02/post-format-test-audio/' ), // A Year the post is not in
     148            array( '/post-format-test-au/', '/2008/06/02/post-format-test-audio/' ),
     149
     150            array(
     151                '/2008/09/03/images-test/3/',
     152                array(
     153                    'url' => '/2008/09/03/images-test/3/',
     154                    'qv'  => array(
     155                        'name'     => 'images-test',
     156                        'year'     => '2008',
     157                        'monthnum' => '09',
     158                        'day'      => '03',
     159                        'page'     => '3',
     160                    ),
     161                ),
     162            ),
    89163            array( '/2008/09/03/images-test/?page=3', '/2008/09/03/images-test/3/' ),
    90164            array( '/2008/09/03/images-te?page=3', '/2008/09/03/images-test/3/' ),
     
    99173            // Dates
    100174            array( '/?m=2008', '/2008/' ),
    101             array( '/?m=200809', '/2008/09/'),
    102             array( '/?m=20080905', '/2008/09/05/'),
    103 
    104             array( '/2008/?day=05', '/2008/?day=05'), // no redirect
    105             array( '/2008/09/?day=05', '/2008/09/05/'),
    106             array( '/2008/?monthnum=9', '/2008/09/'),
    107 
    108             array( '/?year=2008', '/2008/'),
    109 
    110             array( '/2012/13/', '/2012/'),
     175            array( '/?m=200809', '/2008/09/' ),
     176            array( '/?m=20080905', '/2008/09/05/' ),
     177
     178            array( '/2008/?day=05', '/2008/?day=05' ), // no redirect
     179            array( '/2008/09/?day=05', '/2008/09/05/' ),
     180            array( '/2008/?monthnum=9', '/2008/09/' ),
     181
     182            array( '/?year=2008', '/2008/' ),
     183
     184            array( '/2012/13/', '/2012/' ),
    111185            array( '/2012/11/51/', '/2012/11/', 0, array( 'WP_Date_Query' ) ),
    112186
    113187            // Authors
    114188            array( '/?author=%d', '/author/canonical-author/' ),
    115 //          array( '/?author=%d&year=2008', '/2008/?author=3'),
    116 //          array( '/author/canonical-author/?year=2008', '/2008/?author=3'), //Either or, see previous testcase.
    117 
    118             // Feeds
    119             array( '/?feed=atom', '/feed/atom/' ),
     189            //          array( '/?author=%d&year=2008', '/2008/?author=3'),
     190            //          array( '/author/canonical-author/?year=2008', '/2008/?author=3'), //Either or, see previous testcase.
     191
     192                // Feeds
     193                array( '/?feed=atom', '/feed/atom/' ),
    120194            array( '/?feed=rss2', '/feed/' ),
    121             array( '/?feed=comments-rss2', '/comments/feed/'),
    122             array( '/?feed=comments-atom', '/comments/feed/atom/'),
     195            array( '/?feed=comments-rss2', '/comments/feed/' ),
     196            array( '/?feed=comments-atom', '/comments/feed/atom/' ),
    123197
    124198            // Feeds (per-post)
    125             array( '/2008/03/03/comment-test/?feed=comments-atom', '/2008/03/03/comment-test/feed/atom/'),
    126             array( '/?p=149&feed=comments-atom', '/2008/03/03/comment-test/feed/atom/'),
     199            array( '/2008/03/03/comment-test/?feed=comments-atom', '/2008/03/03/comment-test/feed/atom/' ),
     200            array( '/?p=149&feed=comments-atom', '/2008/03/03/comment-test/feed/atom/' ),
    127201
    128202            // Index
Note: See TracChangeset for help on using the changeset viewer.