Changeset 13339 for trunk/tests/phpunit/testcases/messages/template.php
- Timestamp:
- 10/11/2022 07:10:58 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/messages/template.php
r13148 r13339 425 425 $this->assertCount( 1, $messages_template->threads[0]->recipients ); 426 426 } 427 428 /** 429 * @group pagination 430 * @group BP_Messages_Box_Template 431 * @group BP8750 432 */ 433 public function test_thread_unread_count_setting_per_page_recipients() { 434 $u1 = self::factory()->user->create(); 435 $u2 = self::factory()->user->create(); 436 437 // create initial thread 438 $message_1 = self::factory()->message->create_and_get( 439 array( 440 'sender_id' => $u1, 441 'recipients' => array( $u2 ), 442 ) 443 ); 444 445 // create some replies to thread 446 self::factory()->message->create_and_get( 447 array( 448 'thread_id' => $message_1->thread_id, 449 'sender_id' => $u2, 450 'recipients' => array( $u1 ), 451 ) 452 ); 453 454 self::factory()->message->create_and_get( 455 array( 456 'thread_id' => $message_1->thread_id, 457 'sender_id' => $u2, 458 'recipients' => array( $u1 ), 459 ) 460 ); 461 462 // set $u1 as current user. 463 $old_current_user = get_current_user_id(); 464 $this->set_current_user( $u1 ); 465 466 $messages_template = new BP_Messages_Box_Template( 467 array( 468 'recipients_page' => 1, 469 'recipients_per_page' => 1, 470 ) 471 ); 472 473 $this->set_current_user( $old_current_user ); 474 475 $thread = reset( $messages_template->threads ); 476 477 $this->assertEquals( 2, $thread->unread_count ); 478 } 479 480 /** 481 * @group pagination 482 * @group BP_Messages_Box_Template 483 * @group BP8750 484 */ 485 public function test_thread_unread_count_setting_per_page_recipients_with_specific_user_id() { 486 $u1 = self::factory()->user->create(); 487 $u2 = self::factory()->user->create(); 488 $u3 = self::factory()->user->create(); 489 490 // create initial thread 491 $message_1 = self::factory()->message->create_and_get( 492 array( 493 'sender_id' => $u3, 494 'recipients' => array( $u1, $u2 ), 495 ) 496 ); 497 498 // create some replies to thread 499 self::factory()->message->create_and_get( 500 array( 501 'thread_id' => $message_1->thread_id, 502 'sender_id' => $u2, 503 'recipients' => array( $u1, $u3 ), 504 ) 505 ); 506 507 self::factory()->message->create_and_get( 508 array( 509 'thread_id' => $message_1->thread_id, 510 'sender_id' => $u1, 511 'recipients' => array( $u2, $u3 ), 512 ) 513 ); 514 515 self::factory()->message->create_and_get( 516 array( 517 'thread_id' => $message_1->thread_id, 518 'sender_id' => $u3, 519 'recipients' => array( $u2, $u1 ), 520 ) 521 ); 522 523 $messages_template = new BP_Messages_Box_Template( 524 array( 525 'user_id' => $u3, 526 'recipients_page' => 1, 527 'recipients_per_page' => 1, 528 ) 529 ); 530 531 $thread = reset( $messages_template->threads ); 532 533 $this->assertFalse( isset( $thread->recipients[ $u3 ] ) ); 534 $this->assertCount( 1, $thread->recipients ); 535 $this->assertEquals( 2, $thread->unread_count ); 536 } 427 537 }
Note: See TracChangeset
for help on using the changeset viewer.