- Timestamp:
- 05/30/2016 10:28:36 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/forums/functions/counts.php
r6011 r6036 14 14 */ 15 15 public function test_bbp_forum_new_topic_counts() { 16 remove_action( 'bbp_insert_topic', 'bbp_insert_topic_update_counts', 10 ); 17 16 18 $f = $this->factory->forum->create(); 17 19 $t1 = $this->factory->topic->create( array( … … 24 26 $u = $this->factory->user->create(); 25 27 26 // Cheating here, but we need $_SERVER['SERVER_NAME'] to be set.27 $this->setUp_wp_mail( false);28 // Don't attempt to send an email. This is for speed and PHP errors. 29 remove_action( 'bbp_new_topic', 'bbp_notify_forum_subscribers', 11, 4 ); 28 30 29 31 // Simulate the 'bbp_new_topic' action. 30 32 do_action( 'bbp_new_topic', $t1, $f, false, bbp_get_current_user_id(), $t1 ); 31 33 32 // Reverse our changes.33 $this->tearDown_wp_mail( false );34 35 34 $count = bbp_get_forum_topic_count( $f, true, true ); 36 35 $this->assertSame( 1, $count ); … … 46 45 ), 47 46 ) ); 48 49 // Cheating here, but we need $_SERVER['SERVER_NAME'] to be set.50 $this->setUp_wp_mail( false );51 47 52 48 // Simulate the 'bbp_new_topic' action. 53 49 do_action( 'bbp_new_topic', $t2, $f, false, $u , $t2 ); 54 50 55 // Reverse our changes. 56 $this->tearDown_wp_mail( false ); 57 58 $count = bbp_get_forum_topic_count( $f, true, true ); 59 $this->assertSame( 2, $count ); 60 61 $count = bbp_get_forum_topic_count_hidden( $f, true, true ); 62 $this->assertSame( 0, $count ); 51 $count = bbp_get_forum_topic_count( $f, true, true ); 52 $this->assertSame( 2, $count ); 53 54 $count = bbp_get_forum_topic_count_hidden( $f, true, true ); 55 $this->assertSame( 0, $count ); 56 57 // Re-add removed actions. 58 add_action( 'bbp_insert_topic', 'bbp_insert_topic_update_counts', 10, 2 ); 59 add_action( 'bbp_new_topic', 'bbp_notify_forum_subscribers', 11, 4 ); 63 60 } 64 61 … … 255 252 256 253 /** 254 * @covers ::bbp_increase_forum_topic_count 255 */ 256 public function test_bbp_increase_forum_topic_count() { 257 $f = $this->factory->forum->create(); 258 259 $count = bbp_get_forum_topic_count( $f ); 260 $this->assertSame( '0', $count ); 261 262 bbp_increase_forum_topic_count( $f ); 263 264 $count = bbp_get_forum_topic_count( $f ); 265 $this->assertSame( '1', $count ); 266 } 267 268 /** 269 * @covers ::bbp_decrease_forum_topic_count 270 */ 271 public function test_bbp_decrease_forum_topic_count() { 272 $f = $this->factory->forum->create(); 273 274 $count = bbp_get_forum_topic_count( $f ); 275 $this->assertSame( '0', $count ); 276 277 $t = $this->factory->topic->create_many( 2, array( 278 'post_parent' => $f, 279 ) ); 280 281 bbp_update_forum_topic_count( $f ); 282 283 $count = bbp_get_forum_topic_count( $f ); 284 $this->assertSame( '2', $count ); 285 286 bbp_update_forum_topic_count( $f ); 287 288 bbp_decrease_forum_topic_count( $f ); 289 290 $count = bbp_get_forum_topic_count( $f ); 291 $this->assertSame( '1', $count ); 292 } 293 294 /** 257 295 * @covers ::bbp_bump_forum_topic_count_hidden 258 296 */ … … 270 308 271 309 /** 310 * @covers ::bbp_increase_forum_topic_count_hidden 311 */ 312 public function test_bbp_increase_forum_topic_count_hidden() { 313 $f = $this->factory->forum->create(); 314 315 $count = bbp_get_forum_topic_count_hidden( $f ); 316 $this->assertSame( '0', $count ); 317 318 bbp_increase_forum_topic_count_hidden( $f ); 319 320 $count = bbp_get_forum_topic_count_hidden( $f ); 321 $this->assertSame( '1', $count ); 322 } 323 324 /** 325 * @covers ::bbp_decrease_forum_topic_count_hidden 326 */ 327 public function test_bbp_decrease_forum_topic_count_hidden() { 328 $f = $this->factory->forum->create(); 329 330 $count = bbp_get_forum_topic_count_hidden( $f ); 331 $this->assertSame( '0', $count ); 332 333 $t = $this->factory->topic->create_many( 2, array( 334 'post_parent' => $f, 335 'post_status' => bbp_get_spam_status_id(), 336 'topic_meta' => array( 337 'forum_id' => $f, 338 'spam_meta_status' => 'publish', 339 ) 340 ) ); 341 342 bbp_update_forum_topic_count_hidden( $f ); 343 344 $count = bbp_get_forum_topic_count_hidden( $f ); 345 $this->assertSame( '2', $count ); 346 347 bbp_decrease_forum_topic_count_hidden( $f ); 348 349 $count = bbp_get_forum_topic_count_hidden( $f ); 350 $this->assertSame( '1', $count ); 351 } 352 353 /** 272 354 * @covers ::bbp_bump_forum_reply_count 273 355 */ … … 279 361 280 362 bbp_bump_forum_reply_count( $f ); 363 364 $count = bbp_get_forum_reply_count( $f ); 365 $this->assertSame( '1', $count ); 366 } 367 368 /** 369 * @covers ::bbp_increase_forum_reply_count 370 */ 371 public function test_bbp_increase_forum_reply_count() { 372 $f = $this->factory->forum->create(); 373 374 $count = bbp_get_forum_reply_count( $f ); 375 $this->assertSame( '0', $count ); 376 377 bbp_increase_forum_reply_count( $f ); 378 379 $count = bbp_get_forum_reply_count( $f ); 380 $this->assertSame( '1', $count ); 381 } 382 383 /** 384 * @covers ::bbp_decrease_forum_reply_count 385 */ 386 public function test_bbp_decrease_forum_reply_count() { 387 $f = $this->factory->forum->create(); 388 389 $count = bbp_get_forum_reply_count( $f ); 390 $this->assertSame( '0', $count ); 391 392 $t = $this->factory->topic->create( array( 393 'post_parent' => $f, 394 ) ); 395 396 $r = $this->factory->reply->create_many( 2, array( 397 'post_parent' => $t, 398 ) ); 399 400 bbp_update_forum_reply_count( $f ); 401 402 $count = bbp_get_forum_reply_count( $f ); 403 $this->assertSame( '2', $count ); 404 405 bbp_decrease_forum_reply_count( $f ); 281 406 282 407 $count = bbp_get_forum_reply_count( $f );
Note: See TracChangeset
for help on using the changeset viewer.