Make WordPress Core

Changeset 45795


Ignore:
Timestamp:
08/14/2019 03:35:19 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Users: Make wp_list_authors() unit tests more readable.

See #23498.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/listAuthors.php

    r43571 r45795  
    7676
    7777    function test_wp_list_authors_default() {
    78         $expected['default'] = '<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>';
     78        $expected['default'] =
     79            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li>' .
     80            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li>' .
     81            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
     82
    7983        $this->AssertEquals( $expected['default'], wp_list_authors( array( 'echo' => false ) ) );
    8084    }
    8185
    8286    function test_wp_list_authors_orderby() {
    83         $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>';
     87        $expected['post_count'] =
     88            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>' .
     89            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li>' .
     90            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li>';
     91
    8492        $this->AssertEquals(
    8593            $expected['post_count'],
     
    94102
    95103    function test_wp_list_authors_order() {
    96         $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>';
     104        $expected['id'] =
     105            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li>' .
     106            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li>' .
     107            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
     108
    97109        $this->AssertEquals(
    98110            $expected['id'],
     
    108120
    109121    function test_wp_list_authors_optioncount() {
    110         $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>';
     122        $expected['optioncount'] =
     123            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (2)</li>' .
     124            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (3)</li>' .
     125            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (1)</li>';
     126
    111127        $this->AssertEquals(
    112128            $expected['optioncount'],
     
    127143            )
    128144        );
    129         $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>';
     145
     146        $expected['exclude_admin'] =
     147            '<li><a href="' . get_author_posts_url( 1 ) . '" title="Posts by admin">admin</a></li>' .
     148            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li>' .
     149            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li>' .
     150            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
     151
    130152        $this->AssertEquals(
    131153            $expected['exclude_admin'],
     
    140162
    141163    function test_wp_list_authors_show_fullname() {
    142         $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>';
     164        $expected['show_fullname'] =
     165            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob reno</a></li>' .
     166            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul norris</a></li>' .
     167            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack moon</a></li>';
     168
    143169        $this->AssertEquals(
    144170            $expected['show_fullname'],
     
    153179
    154180    function test_wp_list_authors_hide_empty() {
    155         $fred_id                = self::$fred_id;
    156         $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>';
     181        $fred_id = self::$fred_id;
     182
     183        $expected['hide_empty'] =
     184            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li>' .
     185            '<li><a href="' . get_author_posts_url( $fred_id ) . '" title="Posts by fred">fred</a></li>' .
     186            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li>' .
     187            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
     188
    157189        $this->AssertEquals(
    158190            $expected['hide_empty'],
     
    167199
    168200    function test_wp_list_authors_echo() {
    169         $expected['echo'] = '<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>';
     201        $expected['echo'] =
     202            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li>' .
     203            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li>' .
     204            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
     205
    170206        $this->expectOutputString( $expected['echo'] );
    171207        wp_list_authors( array( 'echo' => true ) );
     
    173209
    174210    function test_wp_list_authors_feed() {
    175         $url0             = get_author_feed_link( self::$user_ids[0] );
    176         $url1             = get_author_feed_link( self::$user_ids[1] );
    177         $url2             = get_author_feed_link( self::$user_ids[2] );
    178         $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>';
     211        $url0 = get_author_feed_link( self::$user_ids[0] );
     212        $url1 = get_author_feed_link( self::$user_ids[1] );
     213        $url2 = get_author_feed_link( self::$user_ids[2] );
     214
     215        $expected['feed'] =
     216            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (<a href="' . $url1 . '">link to feed</a>)</li>' .
     217            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (<a href="' . $url2 . '">link to feed</a>)</li>' .
     218            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (<a href="' . $url0 . '">link to feed</a>)</li>';
     219
    179220        $this->AssertEquals(
    180221            $expected['feed'],
     
    189230
    190231    function test_wp_list_authors_feed_image() {
    191         $url0                   = get_author_feed_link( self::$user_ids[0] );
    192         $url1                   = get_author_feed_link( self::$user_ids[1] );
    193         $url2                   = get_author_feed_link( self::$user_ids[2] );
    194         $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>';
     232        $url0 = get_author_feed_link( self::$user_ids[0] );
     233        $url1 = get_author_feed_link( self::$user_ids[1] );
     234        $url2 = get_author_feed_link( self::$user_ids[2] );
     235
     236        $expected['feed_image'] =
     237            '<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>' .
     238            '<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>' .
     239            '<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>';
     240
    195241        $this->AssertEquals(
    196242            $expected['feed_image'],
     
    208254     */
    209255    function test_wp_list_authors_feed_type() {
    210         $url0                  = get_author_feed_link( self::$user_ids[0], 'atom' );
    211         $url1                  = get_author_feed_link( self::$user_ids[1], 'atom' );
    212         $url2                  = get_author_feed_link( self::$user_ids[2], 'atom' );
    213         $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>';
     256        $url0 = get_author_feed_link( self::$user_ids[0], 'atom' );
     257        $url1 = get_author_feed_link( self::$user_ids[1], 'atom' );
     258        $url2 = get_author_feed_link( self::$user_ids[2], 'atom' );
     259
     260        $expected['feed_type'] =
     261            '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (<a href="' . $url1 . '">link to feed</a>)</li>' .
     262            '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (<a href="' . $url2 . '">link to feed</a>)</li>' .
     263            '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (<a href="' . $url0 . '">link to feed</a>)</li>';
     264
    214265        $this->AssertEquals(
    215266            $expected['feed_type'],
     
    225276
    226277    function test_wp_list_authors_style() {
    227         $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>';
     278        $expected['style'] =
     279            '<a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a>, ' .
     280            '<a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a>, ' .
     281            '<a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a>';
     282
    228283        $this->AssertEquals(
    229284            $expected['style'],
     
    239294    function test_wp_list_authors_html() {
    240295        $expected['html'] = 'bob, paul, zack';
     296
    241297        $this->AssertEquals(
    242298            $expected['html'],
Note: See TracChangeset for help on using the changeset viewer.