Changeset 7790
- Timestamp:
- 10/04/2026 08:36:16 AM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/topics/functions/topic-tag.php
r5757 r7790 14 14 /** 15 15 * @covers ::bbp_edit_topic_tag_handler 16 * @todo Implement test_bbp_edit_topic_tag_handler().16 * @todo Cover successful edits in an integration test because bbp_redirect() exits. 17 17 */ 18 18 public function test_bbp_edit_topic_tag_handler() { 19 // Remove the following lines when you implement this test. 20 $this->markTestIncomplete( 21 'This test has not been implemented yet.' 22 ); 19 $old_post = $_POST; 20 $old_request = $_REQUEST; 21 $term = wp_insert_term( 'Original', bbp_get_topic_tag_tax_id() ); 22 $this->assertFalse( is_wp_error( $term ) ); 23 24 try { 25 unset( $_POST['tag-id'] ); 26 $this->assertNull( bbp_edit_topic_tag_handler( 'bbp-update-topic-tag' ) ); 27 28 $_POST['tag-id'] = $term['term_id']; 29 $this->assertNull( bbp_edit_topic_tag_handler( 'unsupported' ) ); 30 31 $_REQUEST['_wpnonce'] = 'invalid'; 32 $this->assertNull( bbp_edit_topic_tag_handler( 'bbp-update-topic-tag' ) ); 33 $this->assertSame( 'bbp_manage_topic_tag_update_nonce', bbpress()->errors->get_error_code() ); 34 bbpress()->errors->remove( 'bbp_manage_topic_tag_update_nonce' ); 35 36 $this->assertNull( bbp_edit_topic_tag_handler( 'bbp-merge-topic-tag' ) ); 37 $this->assertSame( 'bbp_manage_topic_tag_merge_nonce', bbpress()->errors->get_error_code() ); 38 bbpress()->errors->remove( 'bbp_manage_topic_tag_merge_nonce' ); 39 40 $this->assertNull( bbp_edit_topic_tag_handler( 'bbp-delete-topic-tag' ) ); 41 $this->assertSame( 'bbp_manage_topic_tag_delete_nonce', bbpress()->errors->get_error_code() ); 42 $this->assertSame( 'Original', get_term( $term['term_id'], bbp_get_topic_tag_tax_id() )->name ); 43 } finally { 44 bbpress()->errors->remove( 'bbp_manage_topic_tag_update_nonce' ); 45 bbpress()->errors->remove( 'bbp_manage_topic_tag_merge_nonce' ); 46 bbpress()->errors->remove( 'bbp_manage_topic_tag_delete_nonce' ); 47 $_POST = $old_post; 48 $_REQUEST = $old_request; 49 } 23 50 } 24 51 25 52 /** 26 53 * @covers ::bbp_spam_topic_tags 27 * @todo Implement test_bbp_spam_topic_tags().28 54 */ 29 55 public function test_bbp_spam_topic_tags() { 30 // Remove the following lines when you implement this test. 31 $this->markTestIncomplete( 32 'This test has not been implemented yet.' 33 ); 56 $topic_id = $this->factory->topic->create(); 57 $taxonomy = bbp_get_topic_tag_tax_id(); 58 wp_set_object_terms( $topic_id, array( 'alpha', 'beta' ), $taxonomy ); 59 60 $this->assertSame( array( $taxonomy => '' ), bbp_spam_topic_tags( $topic_id ) ); 61 $this->assertSame( array( 'alpha', 'beta' ), get_post_meta( $topic_id, '_bbp_spam_topic_tags', true ) ); 62 63 $empty_topic_id = $this->factory->topic->create(); 64 $this->assertSame( array( $taxonomy => '' ), bbp_spam_topic_tags( $empty_topic_id ) ); 65 $this->assertFalse( metadata_exists( 'post', $empty_topic_id, '_bbp_spam_topic_tags' ) ); 34 66 } 35 67 36 68 /** 37 69 * @covers ::bbp_unspam_topic_tags 38 * @todo Implement test_bbp_unspam_topic_tags().39 70 */ 40 71 public function test_bbp_unspam_topic_tags() { 41 // Remove the following lines when you implement this test. 42 $this->markTestIncomplete( 43 'This test has not been implemented yet.' 44 ); 72 $topic_id = $this->factory->topic->create(); 73 $taxonomy = bbp_get_topic_tag_tax_id(); 74 update_post_meta( $topic_id, '_bbp_spam_topic_tags', array( 'alpha', 'beta' ) ); 75 76 $this->assertSame( array( $taxonomy => array( 'alpha', 'beta' ) ), bbp_unspam_topic_tags( $topic_id ) ); 77 $this->assertFalse( metadata_exists( 'post', $topic_id, '_bbp_spam_topic_tags' ) ); 78 $this->assertSame( array( $taxonomy => '' ), bbp_unspam_topic_tags( $topic_id ) ); 45 79 } 46 80 47 81 /** 48 82 * @covers ::bbp_get_topic_tag_names 49 * @todo Implement test_bbp_get_topic_tag_names().50 83 */ 51 84 public function test_bbp_get_topic_tag_names() { 52 // Remove the following lines when you implement this test. 53 $this->markTestIncomplete( 54 'This test has not been implemented yet.' 55 ); 85 $topic_id = $this->factory->topic->create(); 86 $this->assertSame( '', bbp_get_topic_tag_names( $topic_id ) ); 87 wp_set_object_terms( $topic_id, array( 'alpha', 'beta' ), bbp_get_topic_tag_tax_id() ); 88 $this->assertSame( 'alpha, beta', bbp_get_topic_tag_names( $topic_id ) ); 89 $this->assertSame( 'alpha | beta', bbp_get_topic_tag_names( $topic_id, ' | ' ) ); 56 90 } 57 91 58 92 /** 59 93 * @covers ::bbp_check_topic_tag_edit 60 * @todo Implement test_bbp_check_topic_tag_edit().94 * @todo Cover denied edits in an integration test because bbp_redirect() exits. 61 95 */ 62 96 public function test_bbp_check_topic_tag_edit() { 63 // Remove the following lines when you implement this test. 64 $this->markTestIncomplete( 65 'This test has not been implemented yet.' 66 ); 97 $this->assertNull( bbp_check_topic_tag_edit() ); 67 98 } 68 99 }
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)