- Timestamp:
- 05/30/2016 10:28:36 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/topics/functions/counts.php
r5922 r6036 14 14 */ 15 15 public function test_bbp_topic_new_reply_counts() { 16 remove_action( 'bbp_insert_reply', 'bbp_insert_reply_update_counts', 10 ); 17 16 18 $f = $this->factory->forum->create(); 17 19 $t = $this->factory->topic->create( array( … … 32 34 $u = $this->factory->user->create(); 33 35 34 // Cheating here, but we need $_SERVER['SERVER_NAME'] to be set.35 $this->setUp_wp_mail( false);36 // Don't attempt to send an email. This is for speed and PHP errors. 37 remove_action( 'bbp_new_reply', 'bbp_notify_topic_subscribers', 11, 5 ); 36 38 37 39 // Simulate the 'bbp_new_reply' action. 38 40 do_action( 'bbp_new_reply', $r1, $t, $f, false, bbp_get_current_user_id() ); 39 41 40 // Reverse our changes.41 $this->tearDown_wp_mail( false );42 43 42 $count = bbp_get_topic_reply_count( $t, true ); 44 43 $this->assertSame( 1, $count ); … … 58 57 ), 59 58 ) ); 60 61 // Cheating here, but we need $_SERVER['SERVER_NAME'] to be set.62 $this->setUp_wp_mail( false );63 59 64 60 // Simulate the 'bbp_new_topic' action. 65 61 do_action( 'bbp_new_reply', $r2, $t, $f, false, $u ); 66 62 67 // Reverse our changes. 68 $this->tearDown_wp_mail( false ); 69 70 $count = bbp_get_topic_reply_count( $t, true ); 71 $this->assertSame( 2, $count ); 72 73 $count = bbp_get_topic_reply_count_hidden( $t, true ); 74 $this->assertSame( 0, $count ); 75 76 $count = bbp_get_topic_voice_count( $t, true ); 77 $this->assertSame( 2, $count ); 63 $count = bbp_get_topic_reply_count( $t, true ); 64 $this->assertSame( 2, $count ); 65 66 $count = bbp_get_topic_reply_count_hidden( $t, true ); 67 $this->assertSame( 0, $count ); 68 69 $count = bbp_get_topic_voice_count( $t, true ); 70 $this->assertSame( 2, $count ); 71 72 // Re-add removed actions. 73 add_action( 'bbp_insert_reply', 'bbp_insert_reply_update_counts', 10, 2 ); 74 add_action( 'bbp_new_reply', 'bbp_notify_topic_subscribers', 11, 5 ); 75 78 76 } 79 77 … … 342 340 343 341 /** 342 * @covers ::bbp_increase_topic_reply_count 343 */ 344 public function test_bbp_increase_topic_reply_count() { 345 $t = $this->factory->topic->create(); 346 347 $count = bbp_get_topic_reply_count( $t ); 348 $this->assertSame( '0', $count ); 349 350 bbp_increase_topic_reply_count( $t ); 351 352 $count = bbp_get_topic_reply_count( $t ); 353 $this->assertSame( '1', $count ); 354 } 355 356 /** 357 * @covers ::bbp_decrease_topic_reply_count 358 */ 359 public function test_bbp_decrease_topic_reply_count() { 360 $t = $this->factory->topic->create(); 361 362 $count = bbp_get_topic_reply_count( $t ); 363 $this->assertSame( '0', $count ); 364 365 // Set the count manually to 2 366 bbp_update_topic_reply_count( $t, 2 ); 367 368 $count = bbp_get_topic_reply_count( $t ); 369 $this->assertSame( '2', $count ); 370 371 bbp_decrease_topic_reply_count( $t ); 372 373 $count = bbp_get_topic_reply_count( $t ); 374 $this->assertSame( '1', $count ); 375 } 376 377 /** 344 378 * @covers ::bbp_bump_topic_reply_count_hidden 345 379 */ … … 357 391 $count = bbp_get_topic_reply_count_hidden( $t ); 358 392 $this->assertSame( '4', $count ); 393 } 394 395 /** 396 * @covers ::bbp_increase_topic_reply_count_hidden 397 */ 398 public function test_bbp_increase_topic_reply_count_hidden() { 399 $t = $this->factory->topic->create(); 400 401 $count = bbp_get_topic_reply_count_hidden( $t ); 402 $this->assertSame( '0', $count ); 403 404 bbp_increase_topic_reply_count_hidden( $t ); 405 406 $count = bbp_get_topic_reply_count_hidden( $t ); 407 $this->assertSame( '1', $count ); 408 } 409 410 /** 411 * @covers ::bbp_decrease_topic_reply_count_hidden 412 */ 413 public function test_bbp_decrease_topic_reply_count_hidden() { 414 $t = $this->factory->topic->create(); 415 416 $count = bbp_get_topic_reply_count_hidden( $t ); 417 $this->assertSame( '0', $count ); 418 419 // Set the count manually to 2 420 bbp_update_topic_reply_count_hidden( $t, 2 ); 421 422 $count = bbp_get_topic_reply_count_hidden( $t ); 423 $this->assertSame( '2', $count ); 424 425 bbp_decrease_topic_reply_count_hidden( $t ); 426 427 $count = bbp_get_topic_reply_count_hidden( $t ); 428 $this->assertSame( '1', $count ); 359 429 } 360 430
Note: See TracChangeset
for help on using the changeset viewer.