Make WordPress Core


Ignore:
Timestamp:
03/24/2014 04:52:38 PM (12 years ago)
Author:
wonderboymusic
Message:

Fix a swath of broken unit tests from Tests_User_ListAuthors.

File:
1 edited

Legend:

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

    r27550 r27684  
    55 */
    66class Tests_User_ListAuthors extends WP_UnitTestCase {
    7         var $users;
    8                 /* Defaults
    9                 'orderby'       => 'name',
    10                 'order'         => 'ASC',
     7        var $users = array();
     8        var $user_urls = array();
     9                /* Defaults
     10                'orderby'       => 'name',
     11                'order'         => 'ASC',
    1112                'number'        => null,
    12                 'optioncount'   => false, 
    13                 'exclude_admin' => true, 
     13                'optioncount'   => false,
     14                'exclude_admin' => true,
    1415                'show_fullname' => false,
    1516                'hide_empty'    => true,
    1617                'echo'          => true,
    17                 'feed'          => [empty string], 
     18                'feed'          => [empty string],
    1819                'feed_image'    => [empty string],
    1920                'feed_type'     => [empty string],
     
    2324        function setUp() {
    2425                parent::setUp();
    25                 $users = array();
    2626                $this->users[] = $this->factory->user->create( array( 'user_login' => 'zack', 'display_name' => 'zack', 'role' => 'author', 'first_name' => 'zack', 'last_name' => 'moon' ) );
    2727                $this->users[] = $this->factory->user->create( array( 'user_login' => 'bob', 'display_name' => 'bob', 'role' => 'author', 'first_name' => 'bob', 'last_name' => 'reno' ) );
     
    3030                foreach ( $this->users as $userid ) {
    3131                        $count = $count + 5;
    32                         for ( $i=0; $i < $count; $i++ ) {
    33                                 $post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => $userid ) );
     32                        for ( $i = 0; $i < $count; $i++ ) {
     33                                $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => $userid ) );
    3434                        }
     35
     36                        $this->user_urls[] = get_author_posts_url( $userid );
    3537                }
    3638        }
    3739
    3840        function test_wp_list_authors_default() {
    39                 $expected['default'] = '<li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a></li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a></li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a></li>';
     41                $expected['default'] = '<li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a></li>';
    4042                $this->AssertEquals( $expected['default'], wp_list_authors( array( 'echo' => false ) ) );
    4143        }
    4244
    4345        function test_wp_list_authors_orderby() {
    44                 $expected['post_count'] = '<li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a></li><li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a></li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a></li>';
     46                $expected['post_count'] = '<li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a></li><li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a></li>';
    4547                $this->AssertEquals( $expected['post_count'], wp_list_authors( array( 'echo' => false, 'orderby' => 'post_count' ) ) );
    4648        }
    4749
    4850        function test_wp_list_authors_order() {
    49                 $expected['id'] = '<li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a></li><li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a></li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a></li>';
     51                $expected['id'] = '<li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a></li>';
    5052                $this->AssertEquals( $expected['id'], wp_list_authors( array( 'echo' => false, 'orderby' => 'id', 'order' => 'DESC' ) ) );
    5153        }
    5254
    5355        function test_wp_list_authors_optioncount() {
    54                 $expected['optioncount'] = '<li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a> (10)</li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a> (15)</li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a> (5)</li>';
     56                $expected['optioncount'] = '<li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a> (10)</li><li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a> (15)</li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a> (5)</li>';
    5557                $this->AssertEquals( $expected['optioncount'], wp_list_authors( array( 'echo' => false, 'optioncount' => 1 ) ) );
    5658        }
     
    5860        function test_wp_list_authors_exclude_admin() {
    5961                $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => 1 ) );
    60                 $expected['exclude_admin'] = '<li><a href="http://example.org/?author=1" title="Posts by admin">admin</a></li><li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a></li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a></li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a></li>';
     62                $expected['exclude_admin'] = '<li><a href="' . get_author_posts_url( 1 ) . '" title="Posts by admin">admin</a></li><li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a></li>';
    6163                $this->AssertEquals( $expected['exclude_admin'], wp_list_authors( array( 'echo' => false, 'exclude_admin' => 0 ) ) );
    6264        }
    6365
    6466        function test_wp_list_authors_show_fullname() {
    65                 $expected['show_fullname'] = '<li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob reno</a></li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul norris</a></li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack moon</a></li>';
     67                $expected['show_fullname'] = '<li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob reno</a></li><li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul norris</a></li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack moon</a></li>';
    6668                $this->AssertEquals( $expected['show_fullname'], wp_list_authors( array( 'echo' => false, 'show_fullname' => 1 ) ) );
    6769        }
     
    6971        function test_wp_list_authors_hide_empty() {
    7072                $fred_id = $this->factory->user->create( array( 'user_login' => 'fred', 'role' => 'author' ) );
    71                 $expected['hide_empty'] = '<li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a></li><li><a href="http://example.org/?author=' . $fred_id . '" title="Posts by fred">fred</a></li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a></li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a></li>';
     73                $expected['hide_empty'] = '<li><a href="' . $this->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="' . $this->user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a></li>';
    7274                $this->AssertEquals( $expected['hide_empty'], wp_list_authors( array( 'echo' => false, 'hide_empty' => 0 ) ) );
    7375        }
    7476
    7577        function test_wp_list_authors_echo() {
    76                 $expected['echo'] = '<li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a></li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a></li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a></li>';
     78                $expected['echo'] = '<li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a></li>';
    7779                ob_start();
    7880                wp_list_authors( array( 'echo' => true ) );
     
    8082                $this->AssertEquals( $expected['echo'], $actual );
    8183        }
    82        
     84
    8385        function test_wp_list_authors_feed() {
    84                 $expected['feed'] = '<li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a> (<a href="http://example.org/?feed=rss2&amp;author=' . $this->users[1] . '" title="link to feed">link to feed</a>)</li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a> (<a href="http://example.org/?feed=rss2&amp;author=' . $this->users[2] . '" title="link to feed">link to feed</a>)</li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a> (<a href="http://example.org/?feed=rss2&amp;author=' . $this->users[0] . '" title="link to feed">link to feed</a>)</li>';
     86                $expected['feed'] = '<li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a> (<a href="http://example.org/?feed=rss2&amp;author=' . $this->users[1] . '">link to feed</a>)</li><li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a> (<a href="http://example.org/?feed=rss2&amp;author=' . $this->users[2] . '">link to feed</a>)</li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a> (<a href="http://example.org/?feed=rss2&amp;author=' . $this->users[0] . '">link to feed</a>)</li>';
    8587                $this->AssertEquals( $expected['feed'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed' ) ) );
    8688        }
    8789
    8890        function test_wp_list_authors_feed_image() {
    89                 $expected['feed_image'] = '<li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a> <a href="http://example.org/?feed=rss2&amp;author=' . $this->users[1] . '"><img src="http://example.com/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a> <a href="http://example.org/?feed=rss2&amp;author=' . $this->users[2] . '"><img src="http://example.com/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a> <a href="http://example.org/?feed=rss2&amp;author=' . $this->users[0] . '"><img src="http://example.com/path/to/a/graphic.png" style="border: none;" /></a></li>';
     91                $expected['feed_image'] = '<li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a> <a href="http://example.org/?feed=rss2&amp;author=' . $this->users[1] . '"><img src="http://example.com/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a> <a href="http://example.org/?feed=rss2&amp;author=' . $this->users[2] . '"><img src="http://example.com/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a> <a href="http://example.org/?feed=rss2&amp;author=' . $this->users[0] . '"><img src="http://example.com/path/to/a/graphic.png" style="border: none;" /></a></li>';
    9092                $this->AssertEquals( $expected['feed_image'], wp_list_authors( array( 'echo' => false, 'feed_image' => 'example.com/path/to/a/graphic.png' ) ) );
    9193        }
     
    9597         */
    9698        function test_wp_list_authors_feed_type() {
    97                 $expected['feed_type'] = '<li><a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a> (<a href="http://example.org/?feed=atom&amp;author=' . $this->users[1] . '" title="link to feed">link to feed</a>)</li><li><a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a> (<a href="http://example.org/?feed=atom&amp;author=' . $this->users[2] . '" title="link to feed">link to feed</a>)</li><li><a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a> (<a href="http://example.org/?feed=atom&amp;author=' . $this->users[0] . '" title="link to feed">link to feed</a>)</li>';
     99                $expected['feed_type'] = '<li><a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a> (<a href="http://example.org/?feed=atom&amp;author=' . $this->users[1] . '">link to feed</a>)</li><li><a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a> (<a href="http://example.org/?feed=atom&amp;author=' . $this->users[2] . '">link to feed</a>)</li><li><a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a> (<a href="http://example.org/?feed=atom&amp;author=' . $this->users[0] . '">link to feed</a>)</li>';
    98100                $this->AssertEquals( $expected['feed_type'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed', 'feed_type' => 'atom' ) ) );
    99101        }
    100102
    101103        function test_wp_list_authors_style() {
    102                 $expected['style'] = '<a href="http://example.org/?author=' . $this->users[1] . '" title="Posts by bob">bob</a>, <a href="http://example.org/?author=' . $this->users[2] . '" title="Posts by paul">paul</a>, <a href="http://example.org/?author=' . $this->users[0] . '" title="Posts by zack">zack</a>';
     104                $expected['style'] = '<a href="' . $this->user_urls[1] . '" title="Posts by bob">bob</a>, <a href="' . $this->user_urls[2] . '" title="Posts by paul">paul</a>, <a href="' . $this->user_urls[0] . '" title="Posts by zack">zack</a>';
    103105                $this->AssertEquals( $expected['style'], wp_list_authors( array( 'echo' => false, 'style' => 'none' ) ) );
    104106        }
Note: See TracChangeset for help on using the changeset viewer.