Changeset 5917
- Timestamp:
- 08/16/2015 06:43:03 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/topics/functions.php
r5908 r5917 2588 2588 * Update the topics last active date/time (aka freshness) 2589 2589 * 2590 * @since bbPress (r2680) 2591 * 2592 * @param int $topic_id Optional. Topic id 2593 * @param string $new_time Optional. New time in mysql format 2590 * @since 2.0.0 bbPress (r2680) 2591 * 2592 * @param int $topic_id Optional. Topic id. 2593 * @param string $new_time Optional. New time in mysql format. 2594 * @uses bbp_is_reply() To check if the passed topic id is a reply 2594 2595 * @uses bbp_get_topic_id() To get the topic id 2595 2596 * @uses bbp_get_reply_topic_id() To get the reply topic id 2596 * @uses current_time() To get the current time 2597 * @uses update_post_meta() To update the topic last active meta 2598 * @return bool True on success, false on failure 2597 * @uses get_post_field() To get the timestamp of the newest topic reply 2598 * @uses bbp_get_public_child_last_id() To get the newest topic reply id 2599 * @uses bbp_get_reply_post_type() To get the reply post type 2600 * @uses update_post_meta() To update the topic last active time meta 2601 * @return string MySQL timestamp of last active reply 2599 2602 */ 2600 2603 function bbp_update_topic_last_active_time( $topic_id = 0, $new_time = '' ) { -
trunk/tests/phpunit/testcases/topics/functions/update-last-thing.php
r5760 r5917 1 1 <?php 2 3 2 /** 4 3 * Tests for the `bbp_update_topic_last_*()` functions. … … 8 7 * @group update_last_thing 9 8 */ 9 10 10 class BBP_Tests_Topics_Functions_Update_Topic_Last_Thing extends BBP_UnitTestCase { 11 11 12 12 /** 13 13 * @covers ::bbp_update_topic_last_active_id 14 * @todo Implement test_bbp_update_topic_last_active_id().15 14 */ 16 15 public function test_bbp_update_topic_last_active_id() { 17 // Remove the following lines when you implement this test. 18 $this->markTestIncomplete( 19 'This test has not been implemented yet.' 20 ); 16 $f = $this->factory->forum->create(); 17 $t = $this->factory->topic->create( array( 18 'post_parent' => $f, 19 'topic_meta' => array( 20 'forum_id' => $f, 21 ), 22 ) ); 23 $r1 = $this->factory->reply->create( array( 24 'post_parent' => $t, 25 'reply_meta' => array( 26 'forum_id' => $f, 27 'topic_id' => $t, 28 ), 29 ) ); 30 31 $id = bbp_update_topic_last_active_id( $t, $r1 ); 32 $this->assertSame( $r1, $id ); 33 34 $id = bbp_get_topic_last_active_id( $t ); 35 $this->assertSame( $r1, $id ); 36 37 $r2 = $this->factory->reply->create_many( 2, array( 38 'post_parent' => $t, 39 'reply_meta' => array( 40 'forum_id' => $f, 41 'topic_id' => $t, 42 ), 43 ) ); 44 45 bbp_update_topic_last_active_id( $t ); 46 $id = bbp_get_topic_last_active_id( $t ); 47 $this->assertSame( $r2[1], $id ); 21 48 } 22 49 23 50 /** 24 51 * @covers ::bbp_update_topic_last_active_time 25 * @todo Implement test_bbp_update_topic_last_active_time().26 52 */ 27 53 public function test_bbp_update_topic_last_active_time() { 28 // Remove the following lines when you implement this test. 29 $this->markTestIncomplete( 30 'This test has not been implemented yet.' 31 ); 54 $f = $this->factory->forum->create(); 55 $t = $this->factory->topic->create( array( 56 'post_parent' => $f, 57 'topic_meta' => array( 58 'forum_id' => $f, 59 ), 60 ) ); 61 $r1 = $this->factory->reply->create( array( 62 'post_parent' => $t, 63 'reply_meta' => array( 64 'forum_id' => $f, 65 'topic_id' => $t, 66 ), 67 ) ); 68 69 $r1_time_raw = get_post_field( 'post_date', $r1 ); 70 $r1_time_formatted = bbp_get_time_since( bbp_convert_date( $r1_time_raw ) ); 71 72 $time = bbp_update_topic_last_active_time( $t, $r1_time_raw ); 73 $this->assertSame( $r1_time_raw, $time ); 74 75 $time = bbp_get_topic_last_active_time( $t ); 76 $this->assertSame( $r1_time_formatted, $time ); 77 78 $r2 = $this->factory->reply->create_many( 2, array( 79 'post_parent' => $t, 80 'reply_meta' => array( 81 'forum_id' => $f, 82 'topic_id' => $t, 83 ), 84 ) ); 85 86 $r2_time_raw = get_post_field( 'post_date', $r2[1] ); 87 $r2_time_formatted = bbp_get_time_since( bbp_convert_date( $r2_time_raw ) ); 88 89 bbp_update_topic_last_active_time( $t ); 90 $time = bbp_get_topic_last_active_time( $t ); 91 $this->assertSame( $r2_time_formatted, $time ); 32 92 } 33 93 34 94 /** 35 95 * @covers ::bbp_update_topic_last_reply_id 36 * @todo Implement test_bbp_update_topic_last_reply_id().37 96 */ 38 97 public function test_bbp_update_topic_last_reply_id() { 39 // Remove the following lines when you implement this test. 40 $this->markTestIncomplete( 41 'This test has not been implemented yet.' 42 ); 98 $f = $this->factory->forum->create(); 99 $t = $this->factory->topic->create( array( 100 'post_parent' => $f, 101 'topic_meta' => array( 102 'forum_id' => $f, 103 ), 104 ) ); 105 $r1 = $this->factory->reply->create( array( 106 'post_parent' => $t, 107 'reply_meta' => array( 108 'forum_id' => $f, 109 'topic_id' => $t, 110 ), 111 ) ); 112 113 $id = bbp_update_topic_last_reply_id( $t, $r1 ); 114 $this->assertSame( $r1, $id ); 115 116 $id = bbp_get_topic_last_reply_id( $t ); 117 $this->assertSame( $r1, $id ); 118 119 $r2 = $this->factory->reply->create_many( 2, array( 120 'post_parent' => $t, 121 'reply_meta' => array( 122 'forum_id' => $f, 123 'topic_id' => $t, 124 ), 125 ) ); 126 127 bbp_update_topic_last_reply_id( $t ); 128 $id = bbp_get_topic_last_reply_id( $t ); 129 $this->assertSame( $r2[1], $id ); 43 130 } 44 131 }
Note: See TracChangeset
for help on using the changeset viewer.