Changeset 42343 for trunk/tests/phpunit/tests/user/listAuthors.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/listAuthors.php
r38398 r42343 7 7 static $user_ids = array(); 8 8 static $fred_id; 9 static $posts = array();9 static $posts = array(); 10 10 static $user_urls = array(); 11 11 /* Defaults … … 25 25 */ 26 26 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 ); 31 60 32 61 $count = 0; … … 34 63 $count = $count + 1; 35 64 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 ); 37 71 } 38 72 … … 48 82 function test_wp_list_authors_orderby() { 49 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>'; 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 ); 51 92 } 52 93 53 94 function test_wp_list_authors_order() { 54 95 $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 ); 56 105 } 57 106 58 107 function test_wp_list_authors_optioncount() { 59 108 $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 ); 61 117 } 62 118 63 119 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 ); 65 126 $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 ); 67 135 } 68 136 69 137 function test_wp_list_authors_show_fullname() { 70 138 $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 ); 72 147 } 73 148 74 149 function test_wp_list_authors_hide_empty() { 75 $fred_id = self::$fred_id;150 $fred_id = self::$fred_id; 76 151 $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 ); 78 160 } 79 161 … … 87 169 88 170 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 ); 94 183 } 95 184 96 185 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 ); 102 198 } 103 199 … … 106 202 */ 107 203 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' ); 111 207 $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 ); 113 217 } 114 218 115 219 function test_wp_list_authors_style() { 116 220 $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 ); 118 229 } 119 230 120 231 function test_wp_list_authors_html() { 121 232 $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 ); 123 241 } 124 242 }
Note: See TracChangeset
for help on using the changeset viewer.