Changeset 5918
- Timestamp:
- 08/16/2015 06:45:32 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/functions.php
r5908 r5918 1253 1253 * Update the forum last topic id 1254 1254 * 1255 * @since bbPress (r2625)1256 * 1257 * @param int $forum_id Optional. Forum id 1258 * @param int $topic_id Optional. Topic id 1255 * @since 2.0.0 bbPress (r2625) 1256 * 1257 * @param int $forum_id Optional. Forum id. 1258 * @param int $topic_id Optional. Topic id. 1259 1259 * @uses bbp_get_forum_id() To get the forum id 1260 1260 * @uses bbp_forum_query_subforum_ids() To get the subforum ids 1261 1261 * @uses bbp_update_forum_last_topic_id() To update the last topic id of child 1262 1262 * forums 1263 * @uses bbp_get_topic_post_type() To get the topic post type 1263 1264 * @uses get_posts() To get the most recent topic in the forum 1265 * @uses bbp_is_topic_published() To check if the topic is published 1264 1266 * @uses update_post_meta() To update the forum's last active id meta 1265 1267 * @uses apply_filters() Calls 'bbp_update_forum_last_topic_id' with the last 1266 * replyid and forum id1267 * @return bool True on success, false on failure1268 * topic id and forum id 1269 * @return int Id of the forums most recent topic 1268 1270 */ 1269 1271 function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { … … 1321 1323 * Update the forum last reply id 1322 1324 * 1323 * @since bbPress (r2625)1324 * 1325 * @param int $forum_id Optional. Forum id 1326 * @param int $reply_id Optional. Reply id 1325 * @since 2.0.0 bbPress (r2625) 1326 * 1327 * @param int $forum_id Optional. Forum id. 1328 * @param int $reply_id Optional. Reply id. 1327 1329 * @uses bbp_get_forum_id() To get the forum id 1328 1330 * @uses bbp_forum_query_subforum_ids() To get the subforum ids … … 1335 1337 * @uses apply_filters() Calls 'bbp_update_forum_last_reply_id' with the last 1336 1338 * reply id and forum id 1337 * @return bool True on success, false on failure1339 * @return int Id of the forums most recent reply 1338 1340 */ 1339 1341 function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { … … 1386 1388 * Update the forum last active post id 1387 1389 * 1388 * @since bbPress (r2860)1389 * 1390 * @param int $forum_id Optional. Forum id 1391 * @param int $active_id Optional. Active post id 1390 * @since 2.0.0 bbPress (r2860) 1391 * 1392 * @param int $forum_id Optional. Forum id. 1393 * @param int $active_id Optional. Active post id. 1392 1394 * @uses bbp_get_forum_id() To get the forum id 1393 1395 * @uses bbp_forum_query_subforum_ids() To get the subforum ids … … 1396 1398 * @uses bbp_forum_query_topic_ids() To get the topic ids in the forum 1397 1399 * @uses bbp_forum_query_last_reply_id() To get the forum's last reply id 1400 * @uses bbp_get_public_status_id() To get the public status id 1398 1401 * @uses get_post_status() To make sure the reply is published 1399 1402 * @uses update_post_meta() To update the forum's last active id meta 1400 1403 * @uses apply_filters() Calls 'bbp_update_forum_last_active_id' with the last 1401 1404 * active post id and forum id 1402 * @return bool True on success, false on failure1405 * @return int Id of the forums last active post 1403 1406 */ 1404 1407 function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { … … 1452 1455 * Update the forums last active date/time (aka freshness) 1453 1456 * 1454 * @since bbPress (r2680)1455 * 1456 * @param int $forum_id Optional. Topic id1457 * @param string $new_time Optional. New time in mysql format 1457 * @since 2.0.0 bbPress (r2680) 1458 * 1459 * @param int $forum_id Optional. Topic id. 1460 * @param string $new_time Optional. New time in mysql format. 1458 1461 * @uses bbp_get_forum_id() To get the forum id 1459 1462 * @uses bbp_get_forum_last_active_id() To get the forum's last post id … … 1462 1465 * @uses apply_filters() Calls 'bbp_update_forum_last_active' with the new time 1463 1466 * and forum id 1464 * @return bool True on success, false on failure1467 * @return string MySQL timestamp of last active topic or reply 1465 1468 */ 1466 1469 function bbp_update_forum_last_active_time( $forum_id = 0, $new_time = '' ) { … … 1477 1480 } 1478 1481 1479 return (int)apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id );1482 return apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id ); 1480 1483 } 1481 1484 -
trunk/tests/phpunit/testcases/forums/functions/update-last-thing.php
r5745 r5918 1 1 <?php 2 3 2 /** 4 3 * Tests for the `bbp_update_forum_last_*()` functions. … … 8 7 * @group update_last_thing 9 8 */ 9 10 10 class BBP_Tests_Forums_Functions_Update_Forum_Last_Thing extends BBP_UnitTestCase { 11 11 12 12 /** 13 13 * @covers ::bbp_update_forum_last_topic_id 14 * @todo Implement test_bbp_update_forum_last_topic_id().15 14 */ 16 15 public function test_bbp_update_forum_last_topic_id() { 17 // Remove the following lines when you implement this test. 18 $this->markTestIncomplete( 19 'This test has not been implemented yet.' 20 ); 16 $f1 = $this->factory->forum->create(); 17 $f2 = $this->factory->forum->create( array( 18 'post_parent' => $f1, 19 ) ); 20 21 $t1 = $this->factory->topic->create( array( 22 'post_parent' => $f1, 23 'topic_meta' => array( 24 'forum_id' => $f1, 25 ), 26 ) ); 27 28 $id = bbp_update_forum_last_topic_id( $f1, $t1 ); 29 $this->assertSame( $t1, $id ); 30 31 $id = bbp_get_forum_last_topic_id( $f1 ); 32 $this->assertSame( $t1, $id ); 33 34 $t2 = $this->factory->topic->create( array( 35 'post_parent' => $f2, 36 'topic_meta' => array( 37 'forum_id' => $f2, 38 ), 39 ) ); 40 41 bbp_update_forum_last_topic_id( $f2 ); 42 $id = bbp_get_forum_last_topic_id( $f2 ); 43 $this->assertSame( $t2, $id ); 44 45 bbp_update_forum_last_topic_id( $f1 ); 46 $id = bbp_get_forum_last_topic_id( $f1 ); 47 $this->assertSame( $t2, $id ); 21 48 } 22 49 23 50 /** 24 51 * @covers ::bbp_update_forum_last_reply_id 25 * @todo Implement test_bbp_update_forum_last_reply_id().26 52 */ 27 53 public function test_bbp_update_forum_last_reply_id() { 28 // Remove the following lines when you implement this test. 29 $this->markTestIncomplete( 30 'This test has not been implemented yet.' 31 ); 54 $f1 = $this->factory->forum->create(); 55 $f2 = $this->factory->forum->create( array( 56 'post_parent' => $f1, 57 ) ); 58 59 $t1 = $this->factory->topic->create( array( 60 'post_parent' => $f1, 61 'topic_meta' => array( 62 'forum_id' => $f1, 63 ), 64 ) ); 65 $t2 = $this->factory->topic->create( array( 66 'post_parent' => $f2, 67 'topic_meta' => array( 68 'forum_id' => $f2, 69 ), 70 ) ); 71 72 $r1 = $this->factory->reply->create( array( 73 'post_parent' => $t1, 74 'reply_meta' => array( 75 'forum_id' => $f1, 76 'topic_id' => $t1, 77 ), 78 ) ); 79 80 $id = bbp_update_forum_last_reply_id( $f1, $r1 ); 81 $this->assertSame( $r1, $id ); 82 83 $id = bbp_get_forum_last_reply_id( $f1 ); 84 $this->assertSame( $r1, $id ); 85 86 $r2 = $this->factory->reply->create( array( 87 'post_parent' => $t2, 88 'reply_meta' => array( 89 'forum_id' => $f2, 90 'topic_id' => $t2, 91 ), 92 ) ); 93 94 bbp_update_forum_last_reply_id( $f2 ); 95 $id = bbp_get_forum_last_reply_id( $f2 ); 96 $this->assertSame( $r2, $id ); 97 98 bbp_update_forum_last_reply_id( $f1 ); 99 $id = bbp_get_forum_last_reply_id( $f1 ); 100 $this->assertSame( $r2, $id ); 32 101 } 33 102 34 103 /** 35 104 * @covers ::bbp_update_forum_last_active_id 36 * @todo Implement test_bbp_update_forum_last_active_id().37 105 */ 38 106 public function test_bbp_update_forum_last_active_id() { 39 // Remove the following lines when you implement this test. 40 $this->markTestIncomplete( 41 'This test has not been implemented yet.' 42 ); 107 $f1 = $this->factory->forum->create(); 108 $f2 = $this->factory->forum->create( array( 109 'post_parent' => $f1, 110 ) ); 111 112 $t1 = $this->factory->topic->create( array( 113 'post_parent' => $f1, 114 'topic_meta' => array( 115 'forum_id' => $f1, 116 ), 117 ) ); 118 $r1 = $this->factory->reply->create( array( 119 'post_parent' => $t1, 120 'reply_meta' => array( 121 'forum_id' => $f1, 122 'topic_id' => $t1, 123 ), 124 ) ); 125 126 $id = bbp_update_forum_last_active_id( $f1, $r1 ); 127 $this->assertSame( $r1, $id ); 128 129 $id = bbp_get_forum_last_active_id( $f1 ); 130 $this->assertSame( $r1, $id ); 131 132 $t2 = $this->factory->topic->create( array( 133 'post_parent' => $f2, 134 'topic_meta' => array( 135 'forum_id' => $f2, 136 ), 137 ) ); 138 $r2 = $this->factory->reply->create( array( 139 'post_parent' => $t2, 140 'reply_meta' => array( 141 'forum_id' => $f2, 142 'topic_id' => $t2, 143 ), 144 ) ); 145 146 bbp_update_forum_last_active_id( $f2 ); 147 $id = bbp_get_forum_last_active_id( $f2 ); 148 $this->assertSame( $r2, $id ); 149 150 bbp_update_forum_last_active_id( $f1 ); 151 $id = bbp_get_forum_last_active_id( $f1 ); 152 $this->assertSame( $r2, $id ); 43 153 } 44 154 45 155 /** 46 156 * @covers ::bbp_update_forum_last_active_time 47 * @todo Implement test_bbp_update_forum_last_active_time().48 157 */ 49 158 public function test_bbp_update_forum_last_active_time() { 50 // Remove the following lines when you implement this test. 51 $this->markTestIncomplete( 52 'This test has not been implemented yet.' 53 ); 159 $f1 = $this->factory->forum->create(); 160 $f2 = $this->factory->forum->create( array( 161 'post_parent' => $f1, 162 ) ); 163 164 $t1 = $this->factory->topic->create( array( 165 'post_parent' => $f1, 166 'topic_meta' => array( 167 'forum_id' => $f1, 168 ), 169 ) ); 170 $r1 = $this->factory->reply->create( array( 171 'post_parent' => $t1, 172 'reply_meta' => array( 173 'forum_id' => $f1, 174 'topic_id' => $t1, 175 ), 176 ) ); 177 178 $r1_time_raw = get_post_field( 'post_date', $r1 ); 179 $r1_time_formatted = bbp_get_time_since( bbp_convert_date( $r1_time_raw ) ); 180 181 $time = bbp_update_forum_last_active_time( $f1, $r1_time_raw ); 182 $this->assertSame( $r1_time_raw, $time ); 183 184 $time = bbp_get_forum_last_active_time( $f1 ); 185 $this->assertSame( $r1_time_formatted, $time ); 186 187 $t2 = $this->factory->topic->create( array( 188 'post_parent' => $f2, 189 'topic_meta' => array( 190 'forum_id' => $f2, 191 ), 192 ) ); 193 $r2 = $this->factory->reply->create( array( 194 'post_parent' => $t2, 195 'reply_meta' => array( 196 'forum_id' => $f2, 197 'topic_id' => $t2, 198 ), 199 ) ); 200 201 $r2_time_raw = get_post_field( 'post_date', $r2 ); 202 $r2_time_formatted = bbp_get_time_since( bbp_convert_date( $r2_time_raw ) ); 203 204 bbp_update_forum_last_active_time( $f2 ); 205 $time = bbp_get_forum_last_active_time( $f2 ); 206 $this->assertSame( $r2_time_formatted, $time ); 207 208 bbp_update_forum_last_active_time( $f1 ); 209 $time = bbp_get_forum_last_active_time( $f1 ); 210 $this->assertSame( $r2_time_formatted, $time ); 54 211 } 55 212 }
Note: See TracChangeset
for help on using the changeset viewer.