Changeset 7800
- Timestamp:
- 10/04/2026 09:18:18 AM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/topics/functions/topic.php
r7467 r7800 426 426 /** 427 427 * @covers ::bbp_get_topic_statuses 428 * @todo Implement test_bbp_get_topic_statuses().429 428 */ 430 429 public function test_bbp_get_topic_statuses() { 431 // Remove the following lines when you implement this test. 432 $this->markTestIncomplete( 433 'This test has not been implemented yet.' 434 ); 430 $statuses = bbp_get_topic_statuses(); 431 $this->assertSame( array( 'Open', 'Closed', 'Spam', 'Trash', 'Pending' ), array_values( $statuses ) ); 432 $this->assertSame( array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ), array_keys( $statuses ) ); 435 433 } 436 434 437 435 /** 438 436 * @covers ::bbp_get_topic_types 439 * @todo Implement test_bbp_get_topic_types().440 437 */ 441 438 public function test_bbp_get_topic_types() { 442 // Remove the following lines when you implement this test. 443 $this->markTestIncomplete( 444 'This test has not been implemented yet.' 445 ); 439 $this->assertSame( array( 'unstick' => 'Normal', 'stick' => 'Sticky', 'super' => 'Super Sticky' ), bbp_get_topic_types() ); 446 440 } 447 441 448 442 /** 449 443 * @covers ::bbp_get_stickies 450 * @todo Implement test_bbp_get_stickies().451 444 */ 452 445 public function test_bbp_get_stickies() { 453 // Remove the following lines when you implement this test. 454 $this->markTestIncomplete( 455 'This test has not been implemented yet.' 456 ); 446 $forum_id = $this->factory->forum->create(); 447 $topic_id = $this->factory->topic->create( array( 'post_parent' => $forum_id ) ); 448 $this->assertSame( array(), bbp_get_stickies( $forum_id ) ); 449 update_post_meta( $forum_id, '_bbp_sticky_topics', array( (string) $topic_id, (string) $topic_id ) ); 450 $this->assertSame( array( $topic_id ), bbp_get_stickies( $forum_id ) ); 457 451 } 458 452 459 453 /** 460 454 * @covers ::bbp_get_super_stickies 461 * @todo Implement test_bbp_get_super_stickies().462 455 */ 463 456 public function test_bbp_get_super_stickies() { 464 // Remove the following lines when you implement this test.465 $this->markTestIncomplete(466 'This test has not been implemented yet.'467 );457 $topic_id = $this->factory->topic->create(); 458 update_option( '_bbp_super_sticky_topics', array( (string) $topic_id, (string) $topic_id ) ); 459 $this->assertSame( array( $topic_id ), bbp_get_super_stickies() ); 460 $this->assertSame( array( $topic_id ), bbp_get_stickies() ); 468 461 } 469 462 … … 481 474 /** 482 475 * @covers ::bbp_remove_topic_from_all_favorites 483 * @todo Implement test_bbp_remove_topic_from_all_favorites().484 476 */ 485 477 public function test_bbp_remove_topic_from_all_favorites() { 486 // Remove the following lines when you implement this test. 487 $this->markTestIncomplete( 488 'This test has not been implemented yet.' 489 ); 478 $topic_id = $this->factory->topic->create(); 479 $user_ids = $this->factory->user->create_many( 2 ); 480 foreach ( $user_ids as $user_id ) { 481 bbp_add_user_favorite( $user_id, $topic_id ); 482 } 483 $this->assertEqualSets( $user_ids, bbp_get_topic_favoriters( $topic_id ) ); 484 bbp_remove_topic_from_all_favorites( $topic_id ); 485 $this->assertEmpty( bbp_get_topic_favoriters( $topic_id ) ); 490 486 } 491 487 492 488 /** 493 489 * @covers ::bbp_remove_topic_from_all_subscriptions 494 * @todo Implement test_bbp_remove_topic_from_all_subscriptions().495 490 */ 496 491 public function test_bbp_remove_topic_from_all_subscriptions() { 497 // Remove the following lines when you implement this test. 498 $this->markTestIncomplete( 499 'This test has not been implemented yet.' 500 ); 492 $topic_id = $this->factory->topic->create(); 493 $user_ids = $this->factory->user->create_many( 2 ); 494 foreach ( $user_ids as $user_id ) { 495 bbp_add_user_topic_subscription( $user_id, $topic_id ); 496 } 497 $this->assertEqualSets( $user_ids, bbp_get_topic_subscribers( $topic_id ) ); 498 bbp_remove_topic_from_all_subscriptions( $topic_id ); 499 $this->assertEmpty( bbp_get_topic_subscribers( $topic_id ) ); 501 500 } 502 501 … … 529 528 /** 530 529 * @covers ::bbp_update_topic_topic_id 531 * @todo Implement test_bbp_update_topic_topic_id().532 530 */ 533 531 public function test_bbp_update_topic_topic_id() { 534 // Remove the following lines when you implement this test.535 $this->markTestIncomplete(536 'This test has not been implemented yet.'537 );532 $topic_id = $this->factory->topic->create(); 533 delete_post_meta( $topic_id, '_bbp_topic_id' ); 534 $this->assertSame( $topic_id, bbp_update_topic_topic_id( $topic_id ) ); 535 $this->assertSame( (string) $topic_id, get_post_meta( $topic_id, '_bbp_topic_id', true ) ); 538 536 } 539 537 … … 693 691 /** 694 692 * @covers ::bbp_get_topics_per_page 695 * @todo Implement test_bbp_get_topics_per_page().696 693 */ 697 694 public function test_bbp_get_topics_per_page() { 698 // Remove the following lines when you implement this test.699 $this-> markTestIncomplete(700 'This test has not been implemented yet.'701 );695 update_option( '_bbp_topics_per_page', 0 ); 696 $this->assertSame( 12, bbp_get_topics_per_page( 12 ) ); 697 update_option( '_bbp_topics_per_page', '22' ); 698 $this->assertSame( 22, bbp_get_topics_per_page() ); 702 699 } 703 700 704 701 /** 705 702 * @covers ::bbp_get_topics_per_rss_page 706 * @todo Implement test_bbp_get_topics_per_rss_page().707 703 */ 708 704 public function test_bbp_get_topics_per_rss_page() { 709 // Remove the following lines when you implement this test.710 $this-> markTestIncomplete(711 'This test has not been implemented yet.'712 );705 update_option( '_bbp_topics_per_rss_page', 0 ); 706 $this->assertSame( 18, bbp_get_topics_per_rss_page( 18 ) ); 707 update_option( '_bbp_topics_per_rss_page', '30' ); 708 $this->assertSame( 30, bbp_get_topics_per_rss_page() ); 713 709 } 714 710 715 711 /** 716 712 * @covers ::bbp_topic_content_autoembed 717 * @todo Implement test_bbp_topic_content_autoembed().718 713 */ 719 714 public function test_bbp_topic_content_autoembed() { 720 // Remove the following lines when you implement this test. 721 $this->markTestIncomplete( 722 'This test has not been implemented yet.' 723 ); 715 global $wp_embed; 716 717 $callback = array( $wp_embed, 'autoembed' ); 718 $priority = has_filter( 'bbp_get_topic_content', $callback ); 719 remove_filter( 'bbp_get_topic_content', $callback, $priority ); 720 add_filter( 'bbp_use_autoembed', '__return_false' ); 721 722 try { 723 bbp_topic_content_autoembed(); 724 $this->assertFalse( has_filter( 'bbp_get_topic_content', $callback ) ); 725 remove_filter( 'bbp_use_autoembed', '__return_false' ); 726 add_filter( 'bbp_use_autoembed', '__return_true' ); 727 bbp_topic_content_autoembed(); 728 $this->assertSame( 2, has_filter( 'bbp_get_topic_content', $callback ) ); 729 } finally { 730 remove_filter( 'bbp_use_autoembed', '__return_false' ); 731 remove_filter( 'bbp_use_autoembed', '__return_true' ); 732 remove_filter( 'bbp_get_topic_content', $callback, 2 ); 733 if ( false !== $priority ) { 734 add_filter( 'bbp_get_topic_content', $callback, $priority ); 735 } 736 } 724 737 } 725 738
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)