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/user/listAuthors.php

    r38398 r42343  
    77    static $user_ids = array();
    88    static $fred_id;
    9     static $posts = array();
     9    static $posts     = array();
    1010    static $user_urls = array();
    1111        /* Defaults
     
    2525        */
    2626    public static function wpSetUpBeforeClass( $factory ) {
    27         self::$user_ids[] = $factory->user->create( array( 'user_login' => 'zack', 'display_name' => 'zack', 'role' => 'author', 'first_name' => 'zack', 'last_name' => 'moon' ) );
    28         self::$user_ids[] = $factory->user->create( array( 'user_login' => 'bob', 'display_name' => 'bob', 'role' => 'author', 'first_name' => 'bob', 'last_name' => 'reno' ) );
    29         self::$user_ids[] = $factory->user->create( array( 'user_login' => 'paul', 'display_name' => 'paul', 'role' => 'author', 'first_name' => 'paul', 'last_name' => 'norris' ) );
    30         self::$fred_id = $factory->user->create( array( 'user_login' => 'fred', 'role' => 'author' ) );
     27        self::$user_ids[] = $factory->user->create(
     28            array(
     29                'user_login'   => 'zack',
     30                'display_name' => 'zack',
     31                'role'         => 'author',
     32                'first_name'   => 'zack',
     33                'last_name'    => 'moon',
     34            )
     35        );
     36        self::$user_ids[] = $factory->user->create(
     37            array(
     38                'user_login'   => 'bob',
     39                'display_name' => 'bob',
     40                'role'         => 'author',
     41                'first_name'   => 'bob',
     42                'last_name'    => 'reno',
     43            )
     44        );
     45        self::$user_ids[] = $factory->user->create(
     46            array(
     47                'user_login'   => 'paul',
     48                'display_name' => 'paul',
     49                'role'         => 'author',
     50                'first_name'   => 'paul',
     51                'last_name'    => 'norris',
     52            )
     53        );
     54        self::$fred_id    = $factory->user->create(
     55            array(
     56                'user_login' => 'fred',
     57                'role'       => 'author',
     58            )
     59        );
    3160
    3261        $count = 0;
     
    3463            $count = $count + 1;
    3564            for ( $i = 0; $i < $count; $i++ ) {
    36                 self::$posts[] = $factory->post->create( array( 'post_type' => 'post', 'post_author' => $userid ) );
     65                self::$posts[] = $factory->post->create(
     66                    array(
     67                        'post_type'   => 'post',
     68                        'post_author' => $userid,
     69                    )
     70                );
    3771            }
    3872
     
    4882    function test_wp_list_authors_orderby() {
    4983        $expected['post_count'] = '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li><li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li>';
    50         $this->AssertEquals( $expected['post_count'], wp_list_authors( array( 'echo' => false, 'orderby' => 'post_count' ) ) );
     84        $this->AssertEquals(
     85            $expected['post_count'], wp_list_authors(
     86                array(
     87                    'echo'    => false,
     88                    'orderby' => 'post_count',
     89                )
     90            )
     91        );
    5192    }
    5293
    5394    function test_wp_list_authors_order() {
    5495        $expected['id'] = '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
    55         $this->AssertEquals( $expected['id'], wp_list_authors( array( 'echo' => false, 'orderby' => 'id', 'order' => 'DESC' ) ) );
     96        $this->AssertEquals(
     97            $expected['id'], wp_list_authors(
     98                array(
     99                    'echo'    => false,
     100                    'orderby' => 'id',
     101                    'order'   => 'DESC',
     102                )
     103            )
     104        );
    56105    }
    57106
    58107    function test_wp_list_authors_optioncount() {
    59108        $expected['optioncount'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (2)</li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (3)</li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (1)</li>';
    60         $this->AssertEquals( $expected['optioncount'], wp_list_authors( array( 'echo' => false, 'optioncount' => 1 ) ) );
     109        $this->AssertEquals(
     110            $expected['optioncount'], wp_list_authors(
     111                array(
     112                    'echo'        => false,
     113                    'optioncount' => 1,
     114                )
     115            )
     116        );
    61117    }
    62118
    63119    function test_wp_list_authors_exclude_admin() {
    64         self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => 1 ) );
     120        self::factory()->post->create(
     121            array(
     122                'post_type'   => 'post',
     123                'post_author' => 1,
     124            )
     125        );
    65126        $expected['exclude_admin'] = '<li><a href="' . get_author_posts_url( 1 ) . '" title="Posts by admin">admin</a></li><li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
    66         $this->AssertEquals( $expected['exclude_admin'], wp_list_authors( array( 'echo' => false, 'exclude_admin' => 0 ) ) );
     127        $this->AssertEquals(
     128            $expected['exclude_admin'], wp_list_authors(
     129                array(
     130                    'echo'          => false,
     131                    'exclude_admin' => 0,
     132                )
     133            )
     134        );
    67135    }
    68136
    69137    function test_wp_list_authors_show_fullname() {
    70138        $expected['show_fullname'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob reno</a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul norris</a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack moon</a></li>';
    71         $this->AssertEquals( $expected['show_fullname'], wp_list_authors( array( 'echo' => false, 'show_fullname' => 1 ) ) );
     139        $this->AssertEquals(
     140            $expected['show_fullname'], wp_list_authors(
     141                array(
     142                    'echo'          => false,
     143                    'show_fullname' => 1,
     144                )
     145            )
     146        );
    72147    }
    73148
    74149    function test_wp_list_authors_hide_empty() {
    75         $fred_id = self::$fred_id;
     150        $fred_id                = self::$fred_id;
    76151        $expected['hide_empty'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . get_author_posts_url( $fred_id ) . '" title="Posts by fred">fred</a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
    77         $this->AssertEquals( $expected['hide_empty'], wp_list_authors( array( 'echo' => false, 'hide_empty' => 0 ) ) );
     152        $this->AssertEquals(
     153            $expected['hide_empty'], wp_list_authors(
     154                array(
     155                    'echo'       => false,
     156                    'hide_empty' => 0,
     157                )
     158            )
     159        );
    78160    }
    79161
     
    87169
    88170    function test_wp_list_authors_feed() {
    89         $url0 = get_author_feed_link( self::$user_ids[0] );
    90         $url1 = get_author_feed_link( self::$user_ids[1] );
    91         $url2 = get_author_feed_link( self::$user_ids[2] );
    92         $expected['feed'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (<a href="' . $url1 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (<a href="' .  $url2 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (<a href="' . $url0 . '">link to feed</a>)</li>';
    93         $this->AssertEquals( $expected['feed'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed' ) ) );
     171        $url0             = get_author_feed_link( self::$user_ids[0] );
     172        $url1             = get_author_feed_link( self::$user_ids[1] );
     173        $url2             = get_author_feed_link( self::$user_ids[2] );
     174        $expected['feed'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (<a href="' . $url1 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (<a href="' . $url2 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (<a href="' . $url0 . '">link to feed</a>)</li>';
     175        $this->AssertEquals(
     176            $expected['feed'], wp_list_authors(
     177                array(
     178                    'echo' => false,
     179                    'feed' => 'link to feed',
     180                )
     181            )
     182        );
    94183    }
    95184
    96185    function test_wp_list_authors_feed_image() {
    97         $url0 = get_author_feed_link( self::$user_ids[0] );
    98         $url1 = get_author_feed_link( self::$user_ids[1] );
    99         $url2 = get_author_feed_link( self::$user_ids[2] );
    100         $expected['feed_image'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> <a href="' . $url1 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> <a href="' .  $url2 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> <a href="' .  $url0 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li>';
    101         $this->AssertEquals( $expected['feed_image'], wp_list_authors( array( 'echo' => false, 'feed_image' => WP_TESTS_DOMAIN . '/path/to/a/graphic.png' ) ) );
     186        $url0                   = get_author_feed_link( self::$user_ids[0] );
     187        $url1                   = get_author_feed_link( self::$user_ids[1] );
     188        $url2                   = get_author_feed_link( self::$user_ids[2] );
     189        $expected['feed_image'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> <a href="' . $url1 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> <a href="' . $url2 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> <a href="' . $url0 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li>';
     190        $this->AssertEquals(
     191            $expected['feed_image'], wp_list_authors(
     192                array(
     193                    'echo'       => false,
     194                    'feed_image' => WP_TESTS_DOMAIN . '/path/to/a/graphic.png',
     195                )
     196            )
     197        );
    102198    }
    103199
     
    106202     */
    107203    function test_wp_list_authors_feed_type() {
    108         $url0 = get_author_feed_link( self::$user_ids[0], 'atom' );
    109         $url1 = get_author_feed_link( self::$user_ids[1], 'atom' );
    110         $url2 = get_author_feed_link( self::$user_ids[2], 'atom' );
     204        $url0                  = get_author_feed_link( self::$user_ids[0], 'atom' );
     205        $url1                  = get_author_feed_link( self::$user_ids[1], 'atom' );
     206        $url2                  = get_author_feed_link( self::$user_ids[2], 'atom' );
    111207        $expected['feed_type'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (<a href="' . $url1 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (<a href="' . $url2 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (<a href="' . $url0 . '">link to feed</a>)</li>';
    112         $this->AssertEquals( $expected['feed_type'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed', 'feed_type' => 'atom' ) ) );
     208        $this->AssertEquals(
     209            $expected['feed_type'], wp_list_authors(
     210                array(
     211                    'echo'      => false,
     212                    'feed'      => 'link to feed',
     213                    'feed_type' => 'atom',
     214                )
     215            )
     216        );
    113217    }
    114218
    115219    function test_wp_list_authors_style() {
    116220        $expected['style'] = '<a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a>, <a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a>, <a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a>';
    117         $this->AssertEquals( $expected['style'], wp_list_authors( array( 'echo' => false, 'style' => 'none' ) ) );
     221        $this->AssertEquals(
     222            $expected['style'], wp_list_authors(
     223                array(
     224                    'echo'  => false,
     225                    'style' => 'none',
     226                )
     227            )
     228        );
    118229    }
    119230
    120231    function test_wp_list_authors_html() {
    121232        $expected['html'] = 'bob, paul, zack';
    122         $this->AssertEquals( $expected['html'], wp_list_authors( array( 'echo' => false, 'html' => 0 ) ) );
     233        $this->AssertEquals(
     234            $expected['html'], wp_list_authors(
     235                array(
     236                    'echo' => false,
     237                    'html' => 0,
     238                )
     239            )
     240        );
    123241    }
    124242}
Note: See TracChangeset for help on using the changeset viewer.