Changeset 7782
- Timestamp:
- 10/04/2026 07:48:39 AM (5 weeks ago)
- Location:
- trunk/tests/phpunit/testcases
- Files:
-
- 2 edited
-
replies/template/revisions.php (modified) (2 diffs)
-
topics/template/revisions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/replies/template/revisions.php
r5726 r7782 12 12 /** 13 13 * @covers ::bbp_reply_content_append_revisions 14 * @todo Implement test_bbp_reply_content_append_revisions().15 14 */ 16 15 public function test_bbp_reply_content_append_revisions() { 17 // Remove the following lines when you implement this test. 18 $this->markTestIncomplete( 19 'This test has not been implemented yet.' 20 ); 16 $topic_id = $this->factory->topic->create(); 17 $reply_id = $this->factory->reply->create( array( 'post_parent' => $topic_id ) ); 18 19 $this->assertSame( 'Reply content', bbp_reply_content_append_revisions( 'Reply content', $reply_id ) ); 20 $revision_id = $this->create_reply_revision( $reply_id ); 21 update_post_meta( $reply_id, '_bbp_revision_log', array( 22 $revision_id => array( 'author' => 0, 'reason' => 'Updated.' ), 23 ) ); 24 $this->assertSame( 'Reply content' . bbp_get_reply_revision_log( $reply_id ), bbp_reply_content_append_revisions( 'Reply content', $reply_id ) ); 21 25 } 22 26 … … 24 28 * @covers ::bbp_reply_revision_log 25 29 * @covers ::bbp_get_reply_revision_log 26 * @todo Implement test_bbp_get_reply_revision_log().27 30 */ 28 31 public function test_bbp_get_reply_revision_log() { 29 // Remove the following lines when you implement this test. 30 $this->markTestIncomplete( 31 'This test has not been implemented yet.' 32 ); 32 $topic_id = $this->factory->topic->create(); 33 $reply_id = $this->factory->reply->create( array( 'post_parent' => $topic_id ) ); 34 $this->assertFalse( bbp_get_reply_revision_log( $reply_id ) ); 35 36 $revision_id = $this->create_reply_revision( $reply_id ); 37 update_post_meta( $reply_id, '_bbp_revision_log', array( 38 $revision_id => array( 'author' => 0, 'reason' => 'Clarified the answer.' ), 39 ) ); 40 $log = bbp_get_reply_revision_log( $reply_id ); 41 42 $this->assertStringContainsString( 'bbp-reply-revision-log-' . $reply_id, $log ); 43 $this->assertStringContainsString( 'item-' . $revision_id, $log ); 44 $this->assertStringContainsString( 'Clarified the answer.', $log ); 45 $this->expectOutputString( $log ); 46 bbp_reply_revision_log( $reply_id ); 33 47 } 34 48 35 49 /** 36 50 * @covers ::bbp_get_reply_raw_revision_log 37 * @todo Implement test_bbp_get_reply_raw_revision_log().38 51 */ 39 52 public function test_bbp_get_reply_raw_revision_log() { 40 // Remove the following lines when you implement this test. 41 $this->markTestIncomplete( 42 'This test has not been implemented yet.' 43 ); 53 $topic_id = $this->factory->topic->create(); 54 $reply_id = $this->factory->reply->create( array( 'post_parent' => $topic_id ) ); 55 $this->assertSame( array(), bbp_get_reply_raw_revision_log( $reply_id ) ); 56 57 $log = array( 123 => array( 'author' => 0, 'reason' => 'Updated.' ) ); 58 update_post_meta( $reply_id, '_bbp_revision_log', $log ); 59 $this->assertSame( $log, bbp_get_reply_raw_revision_log( $reply_id ) ); 44 60 } 45 61 46 62 /** 47 63 * @covers ::bbp_get_reply_revisions 48 * @todo Implement test_bbp_get_reply_revisions().49 64 */ 50 65 public function test_bbp_get_reply_revisions() { 51 // Remove the following lines when you implement this test. 52 $this->markTestIncomplete( 53 'This test has not been implemented yet.' 54 ); 66 $topic_id = $this->factory->topic->create(); 67 $reply_id = $this->factory->reply->create( array( 'post_parent' => $topic_id ) ); 68 $revision_id = $this->create_reply_revision( $reply_id ); 69 $revisions = bbp_get_reply_revisions( $reply_id ); 70 71 $this->assertArrayHasKey( $revision_id, $revisions ); 72 $this->assertSame( $reply_id, $revisions[ $revision_id ]->post_parent ); 55 73 } 56 74 57 75 /** 58 76 * @covers ::bbp_get_reply_revision_count 59 * @todo Implement test_bbp_get_reply_revision_count().60 77 */ 61 78 public function test_bbp_get_reply_revision_count() { 62 // Remove the following lines when you implement this test. 63 $this->markTestIncomplete( 64 'This test has not been implemented yet.' 65 ); 79 $topic_id = $this->factory->topic->create(); 80 $reply_id = $this->factory->reply->create( array( 'post_parent' => $topic_id ) ); 81 $this->assertSame( '0', bbp_get_reply_revision_count( $reply_id ) ); 82 83 $this->create_reply_revision( $reply_id ); 84 $this->assertSame( '1', bbp_get_reply_revision_count( $reply_id ) ); 85 $this->assertSame( 1, bbp_get_reply_revision_count( $reply_id, true ) ); 86 } 87 88 private function create_reply_revision( $reply_id ) { 89 wp_update_post( array( 'ID' => $reply_id, 'post_content' => 'Updated reply content.' ) ); 90 $revisions = wp_get_post_revisions( $reply_id ); 91 92 $this->assertNotEmpty( $revisions ); 93 return key( $revisions ); 66 94 } 67 95 } -
trunk/tests/phpunit/testcases/topics/template/revisions.php
r5726 r7782 12 12 /** 13 13 * @covers ::bbp_topic_content_append_revisions 14 * @todo Implement test_bbp_topic_content_append_revisions().15 14 */ 16 15 public function test_bbp_topic_content_append_revisions() { 17 // Remove the following lines when you implement this test. 18 $this->markTestIncomplete( 19 'This test has not been implemented yet.' 20 ); 16 $topic_id = $this->factory->topic->create(); 17 18 $this->assertSame( 'Topic content', bbp_topic_content_append_revisions( 'Topic content', $topic_id ) ); 19 $revision_id = $this->create_topic_revision( $topic_id ); 20 update_post_meta( $topic_id, '_bbp_revision_log', array( 21 $revision_id => array( 'author' => 0, 'reason' => 'Updated.' ), 22 ) ); 23 $this->assertSame( 'Topic content' . bbp_get_topic_revision_log( $topic_id ), bbp_topic_content_append_revisions( 'Topic content', $topic_id ) ); 21 24 } 22 25 … … 24 27 * @covers ::bbp_topic_revision_log 25 28 * @covers ::bbp_get_topic_revision_log 26 * @todo Implement test_bbp_get_topic_revision_log().27 29 */ 28 30 public function test_bbp_get_topic_revision_log() { 29 // Remove the following lines when you implement this test. 30 $this->markTestIncomplete( 31 'This test has not been implemented yet.' 32 ); 31 $topic_id = $this->factory->topic->create(); 32 $this->assertFalse( bbp_get_topic_revision_log( $topic_id ) ); 33 34 $revision_id = $this->create_topic_revision( $topic_id ); 35 update_post_meta( $topic_id, '_bbp_revision_log', array( 36 $revision_id => array( 'author' => 0, 'reason' => 'Clarified the question.' ), 37 ) ); 38 $log = bbp_get_topic_revision_log( $topic_id ); 39 40 $this->assertStringContainsString( 'bbp-topic-revision-log-' . $topic_id, $log ); 41 $this->assertStringContainsString( 'item-' . $revision_id, $log ); 42 $this->assertStringContainsString( 'Clarified the question.', $log ); 43 $this->expectOutputString( $log ); 44 bbp_topic_revision_log( $topic_id ); 33 45 } 34 46 35 47 /** 36 48 * @covers ::bbp_get_topic_raw_revision_log 37 * @todo Implement test_bbp_get_topic_raw_revision_log().38 49 */ 39 50 public function test_bbp_get_topic_raw_revision_log() { 40 // Remove the following lines when you implement this test. 41 $this->markTestIncomplete( 42 'This test has not been implemented yet.' 43 ); 51 $topic_id = $this->factory->topic->create(); 52 $this->assertSame( array(), bbp_get_topic_raw_revision_log( $topic_id ) ); 53 54 $log = array( 123 => array( 'author' => 0, 'reason' => 'Updated.' ) ); 55 update_post_meta( $topic_id, '_bbp_revision_log', $log ); 56 $this->assertSame( $log, bbp_get_topic_raw_revision_log( $topic_id ) ); 44 57 } 45 58 46 59 /** 47 60 * @covers ::bbp_get_topic_revisions 48 * @todo Implement test_bbp_get_topic_revisions().49 61 */ 50 62 public function test_bbp_get_topic_revisions() { 51 // Remove the following lines when you implement this test. 52 $this->markTestIncomplete( 53 'This test has not been implemented yet.' 54 ); 63 $topic_id = $this->factory->topic->create(); 64 $revision_id = $this->create_topic_revision( $topic_id ); 65 $revisions = bbp_get_topic_revisions( $topic_id ); 66 67 $this->assertArrayHasKey( $revision_id, $revisions ); 68 $this->assertSame( $topic_id, $revisions[ $revision_id ]->post_parent ); 55 69 } 56 70 57 71 /** 58 72 * @covers ::bbp_get_topic_revision_count 59 * @todo Implement test_bbp_get_topic_revision_count().60 73 */ 61 74 public function test_bbp_get_topic_revision_count() { 62 // Remove the following lines when you implement this test. 63 $this->markTestIncomplete( 64 'This test has not been implemented yet.' 65 ); 75 $topic_id = $this->factory->topic->create(); 76 $this->assertSame( '0', bbp_get_topic_revision_count( $topic_id ) ); 77 78 $this->create_topic_revision( $topic_id ); 79 $this->assertSame( '1', bbp_get_topic_revision_count( $topic_id ) ); 80 $this->assertSame( 1, bbp_get_topic_revision_count( $topic_id, true ) ); 81 } 82 83 private function create_topic_revision( $topic_id ) { 84 wp_update_post( array( 'ID' => $topic_id, 'post_content' => 'Updated topic content.' ) ); 85 $revisions = wp_get_post_revisions( $topic_id ); 86 87 $this->assertNotEmpty( $revisions ); 88 return key( $revisions ); 66 89 } 67 90 }
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)