From 88b610dc72166ea1ea0d25ece83f4624f5eb76e0 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 24 Mar 2014 16:52:38 +0000 Subject: [PATCH] Fix a swath of broken unit tests from `Tests_User_ListAuthors`. git-svn-id: https://develop.svn.wordpress.org/trunk@27684 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/user/listAuthors.php | 48 ++++++++++++------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/phpunit/tests/user/listAuthors.php b/tests/phpunit/tests/user/listAuthors.php index b2f6c606de..a167277785 100644 --- a/tests/phpunit/tests/user/listAuthors.php +++ b/tests/phpunit/tests/user/listAuthors.php @@ -4,17 +4,18 @@ * @group user */ class Tests_User_ListAuthors extends WP_UnitTestCase { - var $users; - /* Defaults - 'orderby' => 'name', - 'order' => 'ASC', + var $users = array(); + var $user_urls = array(); + /* Defaults + 'orderby' => 'name', + 'order' => 'ASC', 'number' => null, - 'optioncount' => false, - 'exclude_admin' => true, + 'optioncount' => false, + 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'echo' => true, - 'feed' => [empty string], + 'feed' => [empty string], 'feed_image' => [empty string], 'feed_type' => [empty string], 'style' => 'list', @@ -22,71 +23,72 @@ class Tests_User_ListAuthors extends WP_UnitTestCase { */ function setUp() { parent::setUp(); - $users = array(); $this->users[] = $this->factory->user->create( array( 'user_login' => 'zack', 'display_name' => 'zack', 'role' => 'author', 'first_name' => 'zack', 'last_name' => 'moon' ) ); $this->users[] = $this->factory->user->create( array( 'user_login' => 'bob', 'display_name' => 'bob', 'role' => 'author', 'first_name' => 'bob', 'last_name' => 'reno' ) ); $this->users[] = $this->factory->user->create( array( 'user_login' => 'paul', 'display_name' => 'paul', 'role' => 'author', 'first_name' => 'paul', 'last_name' => 'norris' ) ); $count = 0; foreach ( $this->users as $userid ) { $count = $count + 5; - for ( $i=0; $i < $count; $i++ ) { - $post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => $userid ) ); + for ( $i = 0; $i < $count; $i++ ) { + $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => $userid ) ); } + + $this->user_urls[] = get_author_posts_url( $userid ); } } function test_wp_list_authors_default() { - $expected['default'] = '
  • bob
  • paul
  • zack
  • '; + $expected['default'] = '
  • bob
  • paul
  • zack
  • '; $this->AssertEquals( $expected['default'], wp_list_authors( array( 'echo' => false ) ) ); } function test_wp_list_authors_orderby() { - $expected['post_count'] = '
  • zack
  • bob
  • paul
  • '; + $expected['post_count'] = '
  • zack
  • bob
  • paul
  • '; $this->AssertEquals( $expected['post_count'], wp_list_authors( array( 'echo' => false, 'orderby' => 'post_count' ) ) ); } function test_wp_list_authors_order() { - $expected['id'] = '
  • paul
  • bob
  • zack
  • '; + $expected['id'] = '
  • paul
  • bob
  • zack
  • '; $this->AssertEquals( $expected['id'], wp_list_authors( array( 'echo' => false, 'orderby' => 'id', 'order' => 'DESC' ) ) ); } function test_wp_list_authors_optioncount() { - $expected['optioncount'] = '
  • bob (10)
  • paul (15)
  • zack (5)
  • '; + $expected['optioncount'] = '
  • bob (10)
  • paul (15)
  • zack (5)
  • '; $this->AssertEquals( $expected['optioncount'], wp_list_authors( array( 'echo' => false, 'optioncount' => 1 ) ) ); } function test_wp_list_authors_exclude_admin() { $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => 1 ) ); - $expected['exclude_admin'] = '
  • admin
  • bob
  • paul
  • zack
  • '; + $expected['exclude_admin'] = '
  • admin
  • bob
  • paul
  • zack
  • '; $this->AssertEquals( $expected['exclude_admin'], wp_list_authors( array( 'echo' => false, 'exclude_admin' => 0 ) ) ); } function test_wp_list_authors_show_fullname() { - $expected['show_fullname'] = '
  • bob reno
  • paul norris
  • zack moon
  • '; + $expected['show_fullname'] = '
  • bob reno
  • paul norris
  • zack moon
  • '; $this->AssertEquals( $expected['show_fullname'], wp_list_authors( array( 'echo' => false, 'show_fullname' => 1 ) ) ); } function test_wp_list_authors_hide_empty() { $fred_id = $this->factory->user->create( array( 'user_login' => 'fred', 'role' => 'author' ) ); - $expected['hide_empty'] = '
  • bob
  • fred
  • paul
  • zack
  • '; + $expected['hide_empty'] = '
  • bob
  • fred
  • paul
  • zack
  • '; $this->AssertEquals( $expected['hide_empty'], wp_list_authors( array( 'echo' => false, 'hide_empty' => 0 ) ) ); } function test_wp_list_authors_echo() { - $expected['echo'] = '
  • bob
  • paul
  • zack
  • '; + $expected['echo'] = '
  • bob
  • paul
  • zack
  • '; ob_start(); wp_list_authors( array( 'echo' => true ) ); $actual = ob_get_clean(); $this->AssertEquals( $expected['echo'], $actual ); } - + function test_wp_list_authors_feed() { - $expected['feed'] = '
  • bob (link to feed)
  • paul (link to feed)
  • zack (link to feed)
  • '; + $expected['feed'] = '
  • bob (link to feed)
  • paul (link to feed)
  • zack (link to feed)
  • '; $this->AssertEquals( $expected['feed'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed' ) ) ); } function test_wp_list_authors_feed_image() { - $expected['feed_image'] = '
  • bob
  • paul
  • zack
  • '; + $expected['feed_image'] = '
  • bob
  • paul
  • zack
  • '; $this->AssertEquals( $expected['feed_image'], wp_list_authors( array( 'echo' => false, 'feed_image' => 'example.com/path/to/a/graphic.png' ) ) ); } @@ -94,12 +96,12 @@ class Tests_User_ListAuthors extends WP_UnitTestCase { * @ticket 26538 */ function test_wp_list_authors_feed_type() { - $expected['feed_type'] = '
  • bob (link to feed)
  • paul (link to feed)
  • zack (link to feed)
  • '; + $expected['feed_type'] = '
  • bob (link to feed)
  • paul (link to feed)
  • zack (link to feed)
  • '; $this->AssertEquals( $expected['feed_type'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed', 'feed_type' => 'atom' ) ) ); } function test_wp_list_authors_style() { - $expected['style'] = 'bob, paul, zack'; + $expected['style'] = 'bob, paul, zack'; $this->AssertEquals( $expected['style'], wp_list_authors( array( 'echo' => false, 'style' => 'none' ) ) ); }