Changeset 7770
- Timestamp:
- 10/02/2026 04:48:39 PM (3 weeks ago)
- Location:
- trunk/tests/phpunit/testcases/forums/template
- Files:
-
- 2 edited
-
get-last-thing.php (modified) (2 diffs)
-
post_type.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/forums/template/get-last-thing.php
r6423 r7770 615 615 * @covers ::bbp_forum_last_reply_permalink 616 616 * @covers ::bbp_get_forum_last_reply_permalink 617 * @todo Implement test_bbp_get_forum_last_reply_permalink().618 617 */ 619 618 public function test_bbp_get_forum_last_reply_permalink() { 620 // Remove the following lines when you implement this test. 621 $this->markTestIncomplete( 622 'This test has not been implemented yet.' 623 ); 619 $category_id = $this->factory->forum->create(); 620 bbp_categorize_forum( $category_id ); 621 $forum_id = $this->factory->forum->create( array( 'post_parent' => $category_id ) ); 622 $topic_id = $this->factory->topic->create( array( 623 'post_parent' => $forum_id, 624 'topic_meta' => array( 'forum_id' => $forum_id ), 625 ) ); 626 $reply_id = $this->factory->reply->create( array( 627 'post_parent' => $topic_id, 628 'reply_meta' => array( 'forum_id' => $forum_id, 'topic_id' => $topic_id ), 629 ) ); 630 $permalink = bbp_get_reply_permalink( $reply_id ); 631 632 $this->assertSame( $reply_id, bbp_get_forum_last_reply_id( $forum_id ) ); 633 $this->assertSame( $permalink, bbp_get_forum_last_reply_permalink( $forum_id ) ); 634 $this->assertSame( $permalink, bbp_get_forum_last_reply_permalink( $category_id ) ); 635 $this->expectOutputString( esc_url( $permalink ) ); 636 bbp_forum_last_reply_permalink( $forum_id ); 637 } 638 639 /** 640 * @covers ::bbp_get_forum_last_reply_permalink 641 */ 642 public function test_bbp_get_forum_last_reply_permalink_filter() { 643 $forum_id = $this->factory->forum->create(); 644 $topic_id = $this->factory->topic->create( array( 645 'post_parent' => $forum_id, 646 'topic_meta' => array( 'forum_id' => $forum_id ), 647 ) ); 648 $reply_id = $this->factory->reply->create( array( 649 'post_parent' => $topic_id, 650 'reply_meta' => array( 'forum_id' => $forum_id, 'topic_id' => $topic_id ), 651 ) ); 652 $filter = function( $permalink, $filtered_forum_id, $filtered_reply_id ) use ( $forum_id, $reply_id ) { 653 $this->assertSame( bbp_get_reply_permalink( $reply_id ), $permalink ); 654 $this->assertSame( $forum_id, $filtered_forum_id ); 655 $this->assertSame( $reply_id, $filtered_reply_id ); 656 return 'https://example.org/last-reply/'; 657 }; 658 add_filter( 'bbp_get_forum_last_reply_permalink', $filter, 10, 3 ); 659 try { 660 $this->assertSame( 'https://example.org/last-reply/', bbp_get_forum_last_reply_permalink( $forum_id ) ); 661 } finally { 662 remove_filter( 'bbp_get_forum_last_reply_permalink', $filter ); 663 } 624 664 } 625 665 … … 627 667 * @covers ::bbp_forum_last_reply_url 628 668 * @covers ::bbp_get_forum_last_reply_url 629 * @todo Implement test_bbp_get_forum_last_reply_url().630 669 */ 631 670 public function test_bbp_get_forum_last_reply_url() { 632 // Remove the following lines when you implement this test. 633 $this->markTestIncomplete( 634 'This test has not been implemented yet.' 635 ); 671 $forum_id = $this->factory->forum->create(); 672 $this->assertSame( '', bbp_get_forum_last_reply_url( $forum_id ) ); 673 674 $topic_id = $this->factory->topic->create( array( 675 'post_parent' => $forum_id, 676 'topic_meta' => array( 'forum_id' => $forum_id ), 677 ) ); 678 $this->assertSame( $topic_id, bbp_get_forum_last_reply_id( $forum_id ) ); 679 $this->assertSame( bbp_get_reply_url( $topic_id ), bbp_get_forum_last_reply_url( $forum_id ) ); 680 681 delete_post_meta( $forum_id, '_bbp_last_reply_id' ); 682 $this->assertSame( 0, bbp_get_forum_last_reply_id( $forum_id ) ); 683 $this->assertSame( bbp_get_topic_permalink( $topic_id ), bbp_get_forum_last_reply_url( $forum_id ) ); 684 685 $reply_id = $this->factory->reply->create( array( 686 'post_parent' => $topic_id, 687 'reply_meta' => array( 'forum_id' => $forum_id, 'topic_id' => $topic_id ), 688 ) ); 689 $url = bbp_get_reply_url( $reply_id ); 690 $this->assertSame( $reply_id, bbp_get_forum_last_reply_id( $forum_id ) ); 691 $this->assertSame( $url, bbp_get_forum_last_reply_url( $forum_id ) ); 692 $this->expectOutputString( esc_url( $url ) ); 693 bbp_forum_last_reply_url( $forum_id ); 694 } 695 696 /** 697 * @covers ::bbp_get_forum_last_reply_url 698 */ 699 public function test_bbp_get_forum_last_reply_url_filter() { 700 $forum_id = $this->factory->forum->create(); 701 $filter = function( $url, $filtered_forum_id, $reply_id ) use ( $forum_id ) { 702 $this->assertSame( '', $url ); 703 $this->assertSame( $forum_id, $filtered_forum_id ); 704 $this->assertSame( 0, $reply_id ); 705 return 'https://example.org/forum/last/'; 706 }; 707 add_filter( 'bbp_get_forum_last_reply_url', $filter, 10, 3 ); 708 try { 709 $this->assertSame( 'https://example.org/forum/last/', bbp_get_forum_last_reply_url( $forum_id ) ); 710 } finally { 711 remove_filter( 'bbp_get_forum_last_reply_url', $filter ); 712 } 636 713 } 637 714 -
trunk/tests/phpunit/testcases/forums/template/post_type.php
r6071 r7770 15 15 */ 16 16 public function test_bbp_get_forum_post_type() { 17 $f = $this->factory->forum->create();18 19 17 $fobj = get_post_type_object( 'forum' ); 20 18 … … 31 29 $this->assertTrue( is_post_type_hierarchical( 'forum' ) ); 32 30 33 $forum_type = bbp_forum_post_type( $f ); 34 $this->expectOutputString( 'forum', $forum_type ); 31 $this->assertSame( 'forum', bbp_get_forum_post_type() ); 32 $this->expectOutputString( 'forum' ); 33 bbp_forum_post_type(); 34 } 35 35 36 $forum_type = bbp_get_forum_post_type( $f ); 37 $this->assertSame( 'forum', $forum_type ); 36 /** 37 * @covers ::bbp_get_forum_post_type 38 */ 39 public function test_bbp_get_forum_post_type_filter() { 40 $filter = function( $post_type ) { 41 $this->assertSame( 'forum', $post_type ); 42 return 'custom-forum'; 43 }; 44 add_filter( 'bbp_get_forum_post_type', $filter ); 45 try { 46 $this->assertSame( 'custom-forum', bbp_get_forum_post_type() ); 47 } finally { 48 remove_filter( 'bbp_get_forum_post_type', $filter ); 49 } 38 50 } 39 51 40 52 /** 41 53 * @covers ::bbp_get_forum_post_type_labels 42 * @todo Implement test_bbp_get_forum_post_type_labels().43 54 */ 44 55 public function test_bbp_get_forum_post_type_labels() { 45 // Remove the following lines when you implement this test. 46 $this->markTestIncomplete( 47 'This test has not been implemented yet.' 56 $labels = bbp_get_forum_post_type_labels(); 57 58 $this->assertSame( 59 array( 60 'name', 'menu_name', 'singular_name', 'all_items', 'add_new', 61 'add_new_item', 'edit', 'edit_item', 'new_item', 'view', 62 'view_item', 'view_items', 'search_items', 'not_found', 63 'not_found_in_trash', 'filter_items_list', 'items_list', 64 'items_list_navigation', 'parent_item_colon', 'archives', 65 'attributes', 'insert_into_item', 'uploaded_to_this_item', 66 'featured_image', 'set_featured_image', 'remove_featured_image', 67 'use_featured_image', 'item_published', 'item_published_privately', 68 'item_reverted_to_draft', 'item_scheduled', 'item_updated' 69 ), 70 array_keys( $labels ) 48 71 ); 72 $this->assertSame( 'Forums', $labels['name'] ); 73 $this->assertSame( 'Forum', $labels['singular_name'] ); 74 $this->assertSame( 'No forums found', $labels['not_found'] ); 75 $this->assertSame( 'Forum updated.', $labels['item_updated'] ); 76 77 $filter = function( $default ) use ( $labels ) { 78 $this->assertSame( $labels, $default ); 79 return array( 'name' => 'Discussion areas' ); 80 }; 81 add_filter( 'bbp_get_forum_post_type_labels', $filter ); 82 try { 83 $this->assertSame( array( 'name' => 'Discussion areas' ), bbp_get_forum_post_type_labels() ); 84 } finally { 85 remove_filter( 'bbp_get_forum_post_type_labels', $filter ); 86 } 49 87 } 50 88 51 89 /** 52 90 * @covers ::bbp_get_forum_post_type_rewrite 53 * @todo Implement test_bbp_get_forum_post_type_rewrite().54 91 */ 55 92 public function test_bbp_get_forum_post_type_rewrite() { 56 // Remove the following lines when you implement this test.57 $this->markTestIncomplete(58 'This test has not been implemented yet.'93 $this->assertSame( 94 array( 'slug' => bbp_get_forum_slug(), 'with_front' => false ), 95 bbp_get_forum_post_type_rewrite() 59 96 ); 97 98 $filter = function( $rewrite ) { 99 $this->assertSame( bbp_get_forum_slug(), $rewrite['slug'] ); 100 $this->assertFalse( $rewrite['with_front'] ); 101 $rewrite['slug'] = 'discussion-area'; 102 return $rewrite; 103 }; 104 add_filter( 'bbp_get_forum_post_type_rewrite', $filter ); 105 try { 106 $this->assertSame( 107 array( 'slug' => 'discussion-area', 'with_front' => false ), 108 bbp_get_forum_post_type_rewrite() 109 ); 110 } finally { 111 remove_filter( 'bbp_get_forum_post_type_rewrite', $filter ); 112 } 60 113 } 61 114 62 115 /** 63 116 * @covers ::bbp_get_forum_post_type_supports 64 * @todo Implement test_bbp_get_forum_post_type_supports().65 117 */ 66 118 public function test_bbp_get_forum_post_type_supports() { 67 // Remove the following lines when you implement this test. 68 $this->markTestIncomplete( 69 'This test has not been implemented yet.' 70 ); 119 $this->assertSame( array( 'title', 'editor', 'revisions' ), bbp_get_forum_post_type_supports() ); 120 121 $filter = function( $supports ) { 122 $this->assertSame( array( 'title', 'editor', 'revisions' ), $supports ); 123 return array( 'title', 'comments' ); 124 }; 125 add_filter( 'bbp_get_forum_post_type_supports', $filter ); 126 try { 127 $this->assertSame( array( 'title', 'comments' ), bbp_get_forum_post_type_supports() ); 128 } finally { 129 remove_filter( 'bbp_get_forum_post_type_supports', $filter ); 130 } 71 131 } 72 132 }
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)