Changeset 5902
- Timestamp:
- 08/10/2015 01:30:56 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/users/template/user.php
r5897 r5902 25 25 } 26 26 27 private function set_permalink_structure( $permalink_structure = '/%year%/%monthnum%/%day%/%postname%/' ) { 28 global $wp_rewrite; 29 $wp_rewrite->set_permalink_structure( $permalink_structure ); 30 } 31 27 32 /** 28 33 * @covers ::bbp_user_id … … 104 109 */ 105 110 public function test_bbp_get_current_user_avatar() { 106 $current_user = wp_get_current_user();111 $current_user = get_current_user_id(); 107 112 $size = 40; 108 113 $wp_avatar = get_avatar( $current_user, $size ); … … 123 128 public function test_bbp_get_user_profile_link() { 124 129 $display_name = $this->keymaster_userdata->display_name; 125 $profile_link = '<a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '" rel="nofollow">' . $display_name . '</a>'; 126 130 131 // Pretty permalinks 132 $this->set_permalink_structure(); 133 134 $profile_link = '<a href="http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/" rel="nofollow">' . $display_name . '</a>'; 127 135 $user_profile_link = bbp_get_user_profile_link( $this->keymaster_id ); 128 136 … … 133 141 $this->expectOutputString( $profile_link ); 134 142 bbp_user_profile_link( $this->keymaster_id ); 143 144 ob_clean(); 145 146 // Ugly permalinks 147 $this->set_permalink_structure( '' ); 148 149 $profile_link = '<a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '" rel="nofollow">' . $display_name . '</a>'; 150 $user_profile_link = bbp_get_user_profile_link( $this->keymaster_id ); 151 152 // String. 153 $this->assertSame( $profile_link, $user_profile_link ); 154 155 // Output. 156 $this->expectOutputString( $profile_link ); 157 bbp_user_profile_link( $this->keymaster_id ); 135 158 } 136 159 … … 155 178 */ 156 179 public function test_bbp_get_user_profile_url() { 157 $profile_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id; 158 180 181 // Pretty permalinks 182 $this->set_permalink_structure(); 183 $profile_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/'; 159 184 $user_profile_url = bbp_get_user_profile_url( $this->keymaster_id ); 160 185 … … 165 190 $this->expectOutputString( $profile_url ); 166 191 bbp_user_profile_url( $this->keymaster_id ); 192 193 ob_clean(); 194 195 // Ugly permalinks 196 $this->set_permalink_structure( '' ); 197 198 $profile_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id; 199 $user_profile_url = bbp_get_user_profile_url( $this->keymaster_id ); 200 201 // String. 202 $this->assertSame( $profile_url, $user_profile_url ); 203 204 // Output. 205 $this->expectOutputString( $profile_url ); 206 bbp_user_profile_url( $this->keymaster_id ); 167 207 } 168 208 … … 173 213 public function test_bbp_get_user_profile_edit_link() { 174 214 $display_name = $this->keymaster_userdata->display_name; 175 $profile_edit_link = '<a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '" rel="nofollow">' . $display_name . '</a>'; 176 215 216 // Pretty permalinks 217 $this->set_permalink_structure(); 218 $profile_edit_link = '<a href="http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/edit/" rel="nofollow">' . $display_name . '</a>'; 177 219 $user_profile_edit_link = bbp_get_user_profile_edit_link( $this->keymaster_id ); 178 220 … … 183 225 $this->expectOutputString( $profile_edit_link ); 184 226 bbp_user_profile_edit_link( $this->keymaster_id ); 227 228 ob_clean(); 229 230 // Ugly permalinks 231 $this->set_permalink_structure( '' ); 232 $profile_edit_link = '<a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&edit=1" rel="nofollow">' . $display_name . '</a>'; 233 $user_profile_edit_link = bbp_get_user_profile_edit_link( $this->keymaster_id ); 234 235 // String. 236 $this->assertSame( $profile_edit_link, $user_profile_edit_link ); 237 238 // Output. 239 $this->expectOutputString( $profile_edit_link ); 240 bbp_user_profile_edit_link( $this->keymaster_id ); 185 241 } 186 242 … … 189 245 */ 190 246 public function test_bbp_user_profile_edit_url() { 191 $profile_edit_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&edit=1'; 247 248 // Pretty permalinks 249 $this->set_permalink_structure(); 250 $profile_edit_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/edit/'; 192 251 193 252 // Output. 194 253 $this->expectOutputString( $profile_edit_url ); 195 254 bbp_user_profile_edit_url( $this->keymaster_id ); 255 256 ob_clean(); 257 258 // Ugly permalinks 259 $this->set_permalink_structure( '' ); 260 $profile_edit_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&edit=1'; 261 262 // Output. 263 $this->expectOutputString( $profile_edit_url ); 264 bbp_user_profile_edit_url( $this->keymaster_id ); 196 265 } 197 266 … … 200 269 */ 201 270 public function test_bbp_get_user_profile_edit_url() { 271 272 // Pretty permalinks 273 $this->set_permalink_structure(); 274 $profile_edit_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/edit/'; 275 276 // String. 277 $this->assertSame( $profile_edit_url, bbp_get_user_profile_edit_url( $this->keymaster_id ) ); 278 279 // Ugly permalinks 280 $this->set_permalink_structure( '' ); 202 281 $profile_edit_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&edit=1'; 203 282 … … 291 370 } 292 371 293 /** 294 * @covers ::bbp_favorites_permalink 295 * @covers ::bbp_get_favorites_permalink 296 * @todo Implement test_bbp_get_favorites_permalink(). 297 */ 298 public function test_bbp_get_favorites_permalink() { 299 // Remove the following lines when you implement this test. 300 $this->markTestIncomplete( 301 'This test has not been implemented yet.' 302 ); 303 } 372 /** 373 * @covers ::bbp_favorites_permalink 374 */ 375 public function test_bbp_favorites_permalink() { 376 377 // Pretty permalinks 378 $this->set_permalink_structure(); 379 $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/favorites/'; 380 381 // Output. 382 $this->expectOutputString( $favorites_url ); 383 bbp_favorites_permalink( $this->keymaster_id ); 384 385 ob_clean(); 386 387 // Ugly permalinks 388 $this->set_permalink_structure( '' ); 389 $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_favs=favorites'; 390 391 // Output. 392 $this->expectOutputString( $favorites_url ); 393 bbp_favorites_permalink( $this->keymaster_id ); 394 } 395 396 /** 397 * @covers ::bbp_get_favorites_permalink 398 */ 399 public function test_bbp_get_favorites_permalink() { 400 401 // Pretty permalinks 402 $this->set_permalink_structure(); 403 $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/favorites/'; 404 405 // String. 406 $this->assertSame( $favorites_url, bbp_get_favorites_permalink( $this->keymaster_id ) ); 407 408 // Ugly permalinks 409 $this->set_permalink_structure( '' ); 410 $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_favs=favorites'; 411 412 // String. 413 $this->assertSame( $favorites_url, bbp_get_favorites_permalink( $this->keymaster_id ) ); 414 } 304 415 305 416 /** … … 315 426 } 316 427 317 /** 318 * @covers ::bbp_subscriptions_permalink 319 * @covers ::bbp_get_subscriptions_permalink 320 * @todo Implement test_bbp_get_subscriptions_permalink(). 321 */ 322 public function test_bbp_get_subscriptions_permalink() { 323 // Remove the following lines when you implement this test. 324 $this->markTestIncomplete( 325 'This test has not been implemented yet.' 326 ); 327 } 428 /** 429 * @covers ::bbp_subscriptions_permalink 430 */ 431 public function test_bbp_subscriptions_permalink() { 432 433 // Pretty permalinks 434 $this->set_permalink_structure(); 435 $subscriptions_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/subscriptions/'; 436 437 // Output. 438 $this->expectOutputString( $subscriptions_url ); 439 bbp_subscriptions_permalink( $this->keymaster_id ); 440 441 ob_clean(); 442 443 // Ugly permalinks 444 $this->set_permalink_structure( '' ); 445 $subscriptions_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_subs=subscriptions'; 446 447 // Output. 448 $this->expectOutputString( $subscriptions_url ); 449 bbp_subscriptions_permalink( $this->keymaster_id ); 450 } 451 452 /** 453 * @covers ::bbp_get_subscriptions_permalink 454 */ 455 public function test_bbp_get_subscriptions_permalink() { 456 457 // Pretty permalinks 458 $this->set_permalink_structure(); 459 $subscriptions_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/subscriptions/'; 460 461 // String. 462 $this->assertSame( $subscriptions_url, bbp_get_subscriptions_permalink( $this->keymaster_id ) ); 463 464 // Ugly permalinks 465 $this->set_permalink_structure( '' ); 466 $subscriptions_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_subs=subscriptions'; 467 468 // String. 469 $this->assertSame( $subscriptions_url, bbp_get_subscriptions_permalink( $this->keymaster_id ) ); 470 } 328 471 329 472 /** … … 420 563 */ 421 564 public function test_bbp_user_topics_created_url() { 422 $topics_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_tops=1'; 565 566 // Pretty permalinks 567 $this->set_permalink_structure(); 568 $topics_created_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/topics/'; 423 569 424 570 // Output. 425 571 $this->expectOutputString( $topics_created_url ); 426 572 bbp_user_topics_created_url( $this->keymaster_id ); 573 574 ob_clean(); 575 576 // Ugly permalinks 577 $this->set_permalink_structure( '' ); 578 $topics_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_tops=1'; 579 580 // Output. 581 $this->expectOutputString( $topics_created_url ); 582 bbp_user_topics_created_url( $this->keymaster_id ); 427 583 } 428 584 … … 431 587 */ 432 588 public function test_bbp_get_user_topics_created_url() { 589 590 // Pretty permalinks 591 $this->set_permalink_structure(); 592 $topics_created_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/topics/'; 593 594 // String. 595 $this->assertSame( $topics_created_url, bbp_get_user_topics_created_url( $this->keymaster_id ) ); 596 597 // Ugly permalinks 598 $this->set_permalink_structure( '' ); 433 599 $topics_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_tops=1'; 434 600 … … 441 607 */ 442 608 public function test_bbp_user_replies_created_url() { 443 $replies_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user='. $this->keymaster_id . '&bbp_reps=1'; 609 610 // Pretty permalinks 611 $this->set_permalink_structure(); 612 $replies_created_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/replies/'; 444 613 445 614 // Output. 446 615 $this->expectOutputString( $replies_created_url ); 447 616 bbp_user_replies_created_url( $this->keymaster_id ); 617 618 ob_clean(); 619 620 // Ugly permalinks 621 $this->set_permalink_structure( '' ); 622 $replies_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user='. $this->keymaster_id . '&bbp_reps=1'; 623 624 // Output. 625 $this->expectOutputString( $replies_created_url ); 626 bbp_user_replies_created_url( $this->keymaster_id ); 448 627 } 449 628 … … 452 631 */ 453 632 public function test_bbp_get_user_replies_created_url() { 633 634 // Pretty permalinks 635 $this->set_permalink_structure(); 636 $replies_created_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/replies/'; 637 638 // String. 639 $this->assertSame( $replies_created_url, bbp_get_user_replies_created_url( $this->keymaster_id ) ); 640 641 // Ugly permalinks 642 $this->set_permalink_structure( '' ); 454 643 $replies_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user='. $this->keymaster_id . '&bbp_reps=1'; 455 644 … … 521 710 522 711 $display_name = $this->keymaster_userdata->display_name; 523 $current_user = wp_get_current_user();712 $current_user = get_current_user_id(); 524 713 $size = 80; 525 714 $wp_avatar = get_avatar( $current_user, $size ); 526 715 716 // Pretty permalinks 717 $this->set_permalink_structure(); 718 $author_link = '<a href="http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/" title="View ' . $display_name . 719 ''s profile" class="bbp-author-avatar" rel="nofollow">' . $wp_avatar . 720 '</a> <a href="http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/" title="View ' . $display_name . 721 ''s profile" class="bbp-author-name" rel="nofollow">' . $display_name . '</a>'; 722 723 // String. 724 $this->assertSame( $author_link, bbp_get_author_link( $t ) ); 725 726 // Output. 727 $this->expectOutputString( $author_link ); 728 bbp_author_link( $t ); 729 730 ob_clean(); 731 732 // Ugly permalinks 733 $this->set_permalink_structure( '' ); 527 734 $author_link = '<a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '" title="View ' . $display_name . 528 735 ''s profile" class="bbp-author-avatar" rel="nofollow">' . $wp_avatar .
Note: See TracChangeset
for help on using the changeset viewer.