Changeset 7791
- Timestamp:
- 10/04/2026 08:39:42 AM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/topics/template/topic-tag.php
r7465 r7791 15 15 * @covers ::bbp_topic_tag_list 16 16 * @covers ::bbp_get_topic_tag_list 17 * @todo Implement test_bbp_get_topic_tag_list().18 17 */ 19 18 public function test_bbp_get_topic_tag_list() { 20 // Remove the following lines when you implement this test. 21 $this->markTestIncomplete( 22 'This test has not been implemented yet.' 23 ); 19 $topic_id = $this->factory->topic->create(); 20 $args = array( 'before' => '<p>', 'sep' => ' | ', 'after' => '</p>', 'none' => 'No tags' ); 21 $this->assertSame( 'No tags', bbp_get_topic_tag_list( $topic_id, $args ) ); 22 23 wp_set_object_terms( $topic_id, array( 'alpha', 'beta' ), bbp_get_topic_tag_tax_id() ); 24 $html = bbp_get_topic_tag_list( $topic_id, $args ); 25 $this->assertStringStartsWith( '<p>', $html ); 26 $this->assertStringContainsString( '>alpha</a> | <a ', $html ); 27 $this->assertStringEndsWith( '</p>', $html ); 28 $this->expectOutputString( $html ); 29 bbp_topic_tag_list( $topic_id, $args ); 30 31 add_filter( 'bbp_allow_topic_tags', '__return_false' ); 32 try { 33 $this->assertSame( '', bbp_get_topic_tag_list( $topic_id, $args ) ); 34 } finally { 35 remove_filter( 'bbp_allow_topic_tags', '__return_false' ); 36 } 24 37 } 25 38 … … 27 40 * @covers ::bbp_topic_tag_tax_id 28 41 * @covers ::bbp_get_topic_tag_tax_id 29 * @todo Implement test_bbp_get_topic_tag_tax_id().30 42 */ 31 43 public function test_bbp_get_topic_tag_tax_id() { 32 // Remove the following lines when you implement this test. 33 $this->markTestIncomplete( 34 'This test has not been implemented yet.' 35 ); 44 $this->assertSame( bbpress()->topic_tag_tax_id, bbp_get_topic_tag_tax_id() ); 45 $this->expectOutputString( bbpress()->topic_tag_tax_id ); 46 bbp_topic_tag_tax_id(); 36 47 } 37 48 38 49 /** 39 50 * @covers ::bbp_get_topic_tag_tax_labels 40 * @todo Implement test_bbp_get_topic_tag_tax_labels().41 51 */ 42 52 public function test_bbp_get_topic_tag_tax_labels() { 43 // Remove the following lines when you implement this test.44 $this-> markTestIncomplete(45 'This test has not been implemented yet.'46 );53 $labels = bbp_get_topic_tag_tax_labels(); 54 $this->assertSame( 'Topic Tags', $labels['name'] ); 55 $this->assertSame( 'Topic Tag', $labels['singular_name'] ); 56 $this->assertArrayHasKey( 'not_found', $labels ); 47 57 } 48 58 49 59 /** 50 60 * @covers ::bbp_get_topic_tag_tax_rewrite 51 * @todo Implement test_bbp_get_topic_tag_tax_rewrite().52 61 */ 53 62 public function test_bbp_get_topic_tag_tax_rewrite() { 54 // Remove the following lines when you implement this test. 55 $this->markTestIncomplete( 56 'This test has not been implemented yet.' 57 ); 63 $this->assertSame( array( 'slug' => bbp_get_topic_tag_tax_slug(), 'with_front' => false ), bbp_get_topic_tag_tax_rewrite() ); 58 64 } 59 65 … … 61 67 * @covers ::bbp_topic_tag_id 62 68 * @covers ::bbp_get_topic_tag_id 63 * @todo Implement test_bbp_get_topic_tag_id().64 69 */ 65 70 public function test_bbp_get_topic_tag_id() { 66 // Remove the following lines when you implement this test. 67 $this->markTestIncomplete( 68 'This test has not been implemented yet.' 69 ); 71 $term = wp_insert_term( 'Alpha', bbp_get_topic_tag_tax_id(), array( 'slug' => 'alpha' ) ); 72 $this->assertFalse( is_wp_error( $term ) ); 73 $this->assertSame( $term['term_id'], bbp_get_topic_tag_id( 'alpha' ) ); 74 $this->assertSame( 0, bbp_get_topic_tag_id( 'missing-tag' ) ); 75 $this->expectOutputString( (string) $term['term_id'] ); 76 bbp_topic_tag_id( 'alpha' ); 70 77 } 71 78 … … 101 108 * @covers ::bbp_topic_tag_slug 102 109 * @covers ::bbp_get_topic_tag_slug 103 * @todo Implement test_bbp_get_topic_tag_slug().104 110 */ 105 111 public function test_bbp_get_topic_tag_slug() { 106 // Remove the following lines when you implement this test. 107 $this->markTestIncomplete( 108 'This test has not been implemented yet.' 109 ); 112 $term = wp_insert_term( 'Alpha', bbp_get_topic_tag_tax_id(), array( 'slug' => 'alpha' ) ); 113 $this->assertFalse( is_wp_error( $term ) ); 114 $this->assertSame( 'alpha', bbp_get_topic_tag_slug( 'alpha' ) ); 115 $this->assertSame( '', bbp_get_topic_tag_slug( 'missing-tag' ) ); 116 $this->expectOutputString( 'alpha' ); 117 bbp_topic_tag_slug( 'alpha' ); 110 118 } 111 119 … … 113 121 * @covers ::bbp_topic_tag_link 114 122 * @covers ::bbp_get_topic_tag_link 115 * @todo Implement test_bbp_get_topic_tag_link().116 123 */ 117 124 public function test_bbp_get_topic_tag_link() { 118 // Remove the following lines when you implement this test. 119 $this->markTestIncomplete( 120 'This test has not been implemented yet.' 121 ); 125 $term = wp_insert_term( 'Alpha', bbp_get_topic_tag_tax_id(), array( 'slug' => 'alpha' ) ); 126 $this->assertFalse( is_wp_error( $term ) ); 127 $url = get_term_link( $term['term_id'], bbp_get_topic_tag_tax_id() ); 128 $this->assertSame( $url, bbp_get_topic_tag_link( 'alpha' ) ); 129 $this->assertSame( '', bbp_get_topic_tag_link( 'missing-tag' ) ); 130 $this->expectOutputString( esc_url( $url ) ); 131 bbp_topic_tag_link( 'alpha' ); 122 132 } 123 133
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)