[ Index ] |
PHP Cross Reference of BBPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Tests for the topics component link template functions. 5 * 6 * @group topics 7 * @group template 8 * @group links 9 */ 10 class BBP_Tests_Topics_Template_Links extends BBP_UnitTestCase { 11 12 /** 13 * @covers ::bbp_topic_subscription_link 14 * @covers ::bbp_get_topic_subscription_link 15 * @todo Implement test_bbp_get_topic_subscription_link(). 16 */ 17 public function test_bbp_get_topic_subscription_link() { 18 // Remove the following lines when you implement this test. 19 $this->markTestIncomplete( 20 'This test has not been implemented yet.' 21 ); 22 } 23 24 /** 25 * @covers ::bbp_topic_favorite_link 26 * @covers ::bbp_get_topic_favorite_link 27 * @todo Implement test_bbp_get_topic_favorite_link(). 28 */ 29 public function test_bbp_get_topic_favorite_link() { 30 // Remove the following lines when you implement this test. 31 $this->markTestIncomplete( 32 'This test has not been implemented yet.' 33 ); 34 } 35 36 /** 37 * @covers ::bbp_topic_freshness_link 38 * @covers ::bbp_get_topic_freshness_link 39 */ 40 public function test_bbp_get_topic_freshness_link() { 41 42 if ( is_multisite() ) { 43 $this->markTestSkipped( 'Skipping URL tests in multiste for now.' ); 44 } 45 46 $now = time(); 47 $post_date = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 ); 48 $post_date_r1 = date( 'Y-m-d H:i:s', $now - 60 * 60 * 80 ); 49 $post_date_r2 = date( 'Y-m-d H:i:s', $now - 60 * 60 * 60 ); 50 51 $f = $this->factory->forum->create(); 52 $t = $this->factory->topic->create( array( 53 'post_title' => 'Topic 1', 54 'post_parent' => $f, 55 'post_date' => $post_date, 56 'topic_meta' => array( 57 'forum_id' => $f, 58 ), 59 ) ); 60 61 $link = bbp_get_topic_freshness_link( $t ); 62 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1" title="">4 days, 4 hours ago</a>', $link ); 63 64 $r1 = $this->factory->reply->create( array( 65 'post_parent' => $t, 66 'post_date' => $post_date_r1, 67 'reply_meta' => array( 68 'forum_id' => $f, 69 'topic_id' => $t, 70 ), 71 ) ); 72 73 $link = bbp_get_topic_freshness_link( $t ); 74 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r1 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">3 days, 8 hours ago</a>', $link ); 75 76 $r2 = $this->factory->reply->create( array( 77 'post_parent' => $t, 78 'post_date' => $post_date_r2, 79 'reply_meta' => array( 80 'forum_id' => $f, 81 'topic_id' => $t, 82 ), 83 ) ); 84 85 $link = bbp_get_topic_freshness_link( $t ); 86 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r2 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">2 days, 12 hours ago</a>', $link ); 87 } 88 89 /** 90 * @covers ::bbp_get_topic_freshness_link 91 */ 92 public function test_bbp_get_topic_freshness_link_with_unpublished_replies() { 93 94 if ( is_multisite() ) { 95 $this->markTestSkipped( 'Skipping URL tests in multiste for now.' ); 96 } 97 98 $now = time(); 99 $post_date = date( 'Y-m-d H:i:s', $now - 60 * 60 * 20 ); // 2o hours ago 100 $post_date_r1 = date( 'Y-m-d H:i:s', $now - 60 * 60 * 18 ); // 18 hours ago 101 $post_date_r2 = date( 'Y-m-d H:i:s', $now - 60 * 60 * 16 ); // 16 hours ago 102 $post_date_r3 = date( 'Y-m-d H:i:s', $now - 60 * 60 * 14 ); // 14 hours ago 103 $post_date_r4 = date( 'Y-m-d H:i:s', $now - 60 * 60 * 12 ); // 12 hours ago 104 $post_date_r5 = date( 'Y-m-d H:i:s', $now - 60 * 60 * 10 ); // 1o hours ago 105 106 $f = $this->factory->forum->create(); 107 $t = $this->factory->topic->create( array( 108 'post_title' => 'Topic 1', 109 'post_parent' => $f, 110 'post_date' => $post_date, 111 'topic_meta' => array( 112 'forum_id' => $f, 113 ), 114 ) ); 115 116 $link = bbp_get_topic_freshness_link( $t ); 117 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1" title="">20 hours ago</a>', $link ); 118 119 $r1 = $this->factory->reply->create( array( 120 'post_parent' => $t, 121 'post_date' => $post_date_r1, 122 'reply_meta' => array( 123 'forum_id' => $f, 124 'topic_id' => $t, 125 ), 126 ) ); 127 128 $link = bbp_get_topic_freshness_link( $t ); 129 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r1 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">18 hours ago</a>', $link ); 130 131 $r2 = $this->factory->reply->create( array( 132 'post_parent' => $t, 133 'post_date' => $post_date_r2, 134 'reply_meta' => array( 135 'forum_id' => $f, 136 'topic_id' => $t, 137 ), 138 ) ); 139 140 $link = bbp_get_topic_freshness_link( $t ); 141 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r2 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">16 hours ago</a>', $link ); 142 143 bbp_spam_reply( $r2 ); 144 145 $link = bbp_get_topic_freshness_link( $t ); 146 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r1 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">18 hours ago</a>', $link ); 147 148 $r3 = $this->factory->reply->create( array( 149 'post_parent' => $t, 150 'post_date' => $post_date_r3, 151 'reply_meta' => array( 152 'forum_id' => $f, 153 'topic_id' => $t, 154 ), 155 ) ); 156 157 $link = bbp_get_topic_freshness_link( $t ); 158 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r3 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">14 hours ago</a>', $link ); 159 160 // Todo: Use bbp_trash_reply() and not wp_trash_post() 161 wp_trash_post( $r3 ); 162 163 $link = bbp_get_topic_freshness_link( $t ); 164 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r1 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">18 hours ago</a>', $link ); 165 166 $r4 = $this->factory->reply->create( array( 167 'post_parent' => $t, 168 'post_date' => $post_date_r4, 169 'reply_meta' => array( 170 'forum_id' => $f, 171 'topic_id' => $t, 172 ), 173 ) ); 174 175 $link = bbp_get_topic_freshness_link( $t ); 176 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r4 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">12 hours ago</a>', $link ); 177 178 bbp_unapprove_reply( $r4 ); 179 180 $link = bbp_get_topic_freshness_link( $t ); 181 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r1 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">18 hours ago</a>', $link ); 182 183 bbp_unspam_reply( $r2 ); 184 185 $link = bbp_get_topic_freshness_link( $t ); 186 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r2 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">16 hours ago</a>', $link ); 187 188 // Todo: Use bbp_untrash_reply() and not wp_untrash_post() 189 wp_untrash_post( $r3 ); 190 191 $link = bbp_get_topic_freshness_link( $t ); 192 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r3 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">14 hours ago</a>', $link ); 193 194 bbp_approve_reply( $r4 ); 195 196 $link = bbp_get_topic_freshness_link( $t ); 197 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r4 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">12 hours ago</a>', $link ); 198 199 $r5 = $this->factory->reply->create( array( 200 'post_parent' => $t, 201 'post_date' => $post_date_r5, 202 'reply_meta' => array( 203 'forum_id' => $f, 204 'topic_id' => $t, 205 ), 206 ) ); 207 208 $link = bbp_get_topic_freshness_link( $t ); 209 $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1#post-' . bbp_get_reply_id( $r5 ) . '" title="Reply To: ' . bbp_get_topic_title( $t ) . '">10 hours ago</a>', $link ); 210 } 211 212 /** 213 * @covers ::bbp_topic_replies_link 214 * @covers ::bbp_get_topic_replies_link 215 * @todo Implement test_bbp_get_topic_replies_link(). 216 */ 217 public function test_bbp_get_topic_replies_link() { 218 // Remove the following lines when you implement this test. 219 $this->markTestIncomplete( 220 'This test has not been implemented yet.' 221 ); 222 } 223 224 /** 225 * @covers ::bbp_topic_admin_links 226 * @covers ::bbp_get_topic_admin_links 227 * @todo Implement test_bbp_get_topic_admin_links(). 228 */ 229 public function test_bbp_get_topic_admin_links() { 230 // Remove the following lines when you implement this test. 231 $this->markTestIncomplete( 232 'This test has not been implemented yet.' 233 ); 234 } 235 236 /** 237 * @covers ::bbp_topic_edit_link 238 * @covers ::bbp_get_topic_edit_link 239 * @todo Implement test_bbp_get_topic_edit_link(). 240 */ 241 public function test_bbp_get_topic_edit_link() { 242 // Remove the following lines when you implement this test. 243 $this->markTestIncomplete( 244 'This test has not been implemented yet.' 245 ); 246 } 247 248 /** 249 * @covers ::bbp_topic_edit_url 250 * @covers ::bbp_get_topic_edit_url 251 * @todo Implement test_bbp_get_topic_edit_url(). 252 */ 253 public function test_bbp_get_topic_edit_url() { 254 // Remove the following lines when you implement this test. 255 $this->markTestIncomplete( 256 'This test has not been implemented yet.' 257 ); 258 } 259 260 /** 261 * @covers ::bbp_topic_trash_link 262 * @covers ::bbp_get_topic_trash_link 263 * @todo Implement test_bbp_get_topic_trash_link(). 264 */ 265 public function test_bbp_get_topic_trash_link() { 266 // Remove the following lines when you implement this test. 267 $this->markTestIncomplete( 268 'This test has not been implemented yet.' 269 ); 270 } 271 272 /** 273 * @covers ::bbp_topic_close_link 274 * @covers ::bbp_get_topic_close_link 275 * @todo Implement test_bbp_get_topic_close_link(). 276 */ 277 public function test_bbp_get_topic_close_link() { 278 // Remove the following lines when you implement this test. 279 $this->markTestIncomplete( 280 'This test has not been implemented yet.' 281 ); 282 } 283 284 /** 285 * @covers ::bbp_topic_approve_link 286 * @covers ::bbp_get_topic_approve_link 287 * @todo Implement test_bbp_get_topic_approve_link(). 288 */ 289 public function test_bbp_get_topic_approve_link() { 290 // Remove the following lines when you implement this test. 291 $this->markTestIncomplete( 292 'This test has not been implemented yet.' 293 ); 294 } 295 296 /** 297 * @covers ::bbp_topic_stick_link 298 * @covers ::bbp_get_topic_stick_link 299 * @todo Implement test_bbp_get_topic_stick_link(). 300 */ 301 public function test_bbp_get_topic_stick_link() { 302 // Remove the following lines when you implement this test. 303 $this->markTestIncomplete( 304 'This test has not been implemented yet.' 305 ); 306 } 307 308 /** 309 * @covers ::bbp_topic_merge_link 310 * @covers ::bbp_get_topic_merge_link 311 * @todo Implement test_bbp_get_topic_merge_link(). 312 */ 313 public function test_bbp_get_topic_merge_link() { 314 // Remove the following lines when you implement this test. 315 $this->markTestIncomplete( 316 'This test has not been implemented yet.' 317 ); 318 } 319 320 /** 321 * @covers ::bbp_topic_spam_link 322 * @covers ::bbp_get_topic_spam_link 323 * @todo Implement test_bbp_get_topic_spam_link(). 324 */ 325 public function test_bbp_get_topic_spam_link() { 326 // Remove the following lines when you implement this test. 327 $this->markTestIncomplete( 328 'This test has not been implemented yet.' 329 ); 330 } 331 332 /** 333 * @covers ::bbp_topic_reply_link 334 * @covers ::bbp_get_topic_reply_link 335 * @todo Implement test_bbp_get_topic_reply_link(). 336 */ 337 public function test_bbp_get_topic_reply_link() { 338 // Remove the following lines when you implement this test. 339 $this->markTestIncomplete( 340 'This test has not been implemented yet.' 341 ); 342 } 343 344 /** 345 * @covers ::bbp_forum_pagination_links 346 * @covers ::bbp_get_forum_pagination_links 347 * @todo Implement test_bbp_get_forum_pagination_links(). 348 */ 349 public function test_bbp_get_forum_pagination_links() { 350 // Remove the following lines when you implement this test. 351 $this->markTestIncomplete( 352 'This test has not been implemented yet.' 353 ); 354 } 355 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Dec 21 01:00:52 2024 | Cross-referenced by PHPXref 0.7.1 |