Changeset 7801
- Timestamp:
- 10/04/2026 09:22:02 AM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/topics/functions/topic.php
r7800 r7801 12 12 protected $old_current_user; 13 13 protected $keymaster_id; 14 15 private function assert_topic_action( $function, $hook ) { 16 $topic_id = $this->factory->topic->create(); 17 $seen = array(); 18 $callback = function ( $id ) use ( &$seen ) { 19 $seen[] = $id; 20 }; 21 add_action( $hook, $callback ); 22 23 try { 24 $this->assertFalse( $function( PHP_INT_MAX ) ); 25 $function( $topic_id ); 26 $this->assertSame( array( $topic_id ), $seen ); 27 } finally { 28 remove_action( $hook, $callback ); 29 } 30 } 14 31 15 32 /** … … 538 555 /** 539 556 * @covers ::bbp_update_topic_revision_log 540 * @todo Implement test_bbp_update_topic_revision_log().541 557 */ 542 558 public function test_bbp_update_topic_revision_log() { 543 // Remove the following lines when you implement this test. 544 $this->markTestIncomplete( 545 'This test has not been implemented yet.' 546 ); 559 $topic_id = $this->factory->topic->create(); 560 $user_id = $this->factory->user->create(); 561 $args = array( 'topic_id' => $topic_id, 'author_id' => $user_id, 'revision_id' => 17, 'reason' => 'Clarify wording' ); 562 563 $this->assertNotFalse( bbp_update_topic_revision_log( $args ) ); 564 $log = bbp_get_topic_raw_revision_log( $topic_id ); 565 $this->assertSame( $user_id, $log[17]['author'] ); 566 $this->assertSame( 'Clarify wording', $log[17]['reason'] ); 547 567 } 548 568 549 569 /** 550 570 * @covers ::bbp_delete_topic 551 * @todo Implement test_bbp_delete_topic().552 571 */ 553 572 public function test_bbp_delete_topic() { 554 // Remove the following lines when you implement this test. 555 $this->markTestIncomplete( 556 'This test has not been implemented yet.' 557 ); 573 $this->assert_topic_action( 'bbp_delete_topic', 'bbp_delete_topic' ); 558 574 } 559 575 … … 587 603 /** 588 604 * @covers ::bbp_trash_topic 589 * @todo Implement test_bbp_trash_topic().590 605 */ 591 606 public function test_bbp_trash_topic() { 592 // Remove the following lines when you implement this test. 593 $this->markTestIncomplete( 594 'This test has not been implemented yet.' 595 ); 607 $this->assert_topic_action( 'bbp_trash_topic', 'bbp_trash_topic' ); 596 608 } 597 609 598 610 /** 599 611 * @covers ::bbp_trash_topic_replies 600 * @todo Implement test_bbp_trash_topic_replies().601 612 */ 602 613 public function test_bbp_trash_topic_replies() { 603 // Remove the following lines when you implement this test. 604 $this->markTestIncomplete( 605 'This test has not been implemented yet.' 606 ); 614 $topic_id = $this->factory->topic->create(); 615 $public = $this->factory->reply->create( array( 'post_parent' => $topic_id ) ); 616 $trashed = $this->factory->reply->create( array( 'post_parent' => $topic_id ) ); 617 wp_trash_post( $trashed ); 618 619 bbp_trash_topic_replies( $topic_id ); 620 $this->assertSame( bbp_get_trash_status_id(), get_post_status( $public ) ); 621 $this->assertSame( bbp_get_trash_status_id(), get_post_status( $trashed ) ); 622 $this->assertSame( array( $public ), get_post_meta( $topic_id, '_bbp_pre_trashed_replies', true ) ); 607 623 } 608 624 … … 658 674 /** 659 675 * @covers ::bbp_deleted_topic 660 * @todo Implement test_bbp_deleted_topic().661 676 */ 662 677 public function test_bbp_deleted_topic() { 663 // Remove the following lines when you implement this test. 664 $this->markTestIncomplete( 665 'This test has not been implemented yet.' 666 ); 678 $this->assert_topic_action( 'bbp_deleted_topic', 'bbp_deleted_topic' ); 667 679 } 668 680 669 681 /** 670 682 * @covers ::bbp_trashed_topic 671 * @todo Implement test_bbp_trashed_topic().672 683 */ 673 684 public function test_bbp_trashed_topic() { 674 // Remove the following lines when you implement this test. 675 $this->markTestIncomplete( 676 'This test has not been implemented yet.' 677 ); 685 $this->assert_topic_action( 'bbp_trashed_topic', 'bbp_trashed_topic' ); 678 686 } 679 687 680 688 /** 681 689 * @covers ::bbp_untrashed_topic 682 * @todo Implement test_bbp_untrashed_topic().683 690 */ 684 691 public function test_bbp_untrashed_topic() { 685 // Remove the following lines when you implement this test. 686 $this->markTestIncomplete( 687 'This test has not been implemented yet.' 688 ); 692 $this->assert_topic_action( 'bbp_untrashed_topic', 'bbp_untrashed_topic' ); 689 693 } 690 694
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)