Ticket #6063: 6063-assoc-array-args-tests.2.diff
File 6063-assoc-array-args-tests.2.diff, 4.1 KB (added by , 10 years ago) |
---|
-
tests/phpunit/testcases/messages/class.bp-messages-thread.php
diff --git tests/phpunit/testcases/messages/class.bp-messages-thread.php tests/phpunit/testcases/messages/class.bp-messages-thread.php index 047d3b5..2ba97e0 100644
class BP_Tests_BP_Messages_Thread extends BP_UnitTestCase { 23 23 'subject' => 'Bar', 24 24 ) ); 25 25 26 $threads = BP_Messages_Thread::get_current_threads_for_user( $u2, 'inbox', 'all', null, null, 'ar' ); 26 $threads = BP_Messages_Thread::get_current_threads_for_user( array( 27 'user_id' => $u2, 28 'search_terms' => 'ar', 29 ) ); 27 30 28 31 $expected = array( $t2 ); 29 32 $found = wp_parse_id_list( wp_list_pluck( $threads['threads'], 'thread_id' ) ); … … class BP_Tests_BP_Messages_Thread extends BP_UnitTestCase { 50 53 'subject' => 'Bar', 51 54 ) ); 52 55 56 $threads = BP_Messages_Thread::get_current_threads_for_user( array( 57 'user_id' => $u2, 58 'box' => 'setnbox', 59 'search_terms' => 'ar', 60 ) ); 61 62 $expected = array( $t2 ); 63 $found = wp_parse_id_list( wp_list_pluck( $threads['threads'], 'thread_id' ) ); 64 65 $this->assertSame( $expected, $found ); 66 } 67 68 /** 69 * @group get_current_threads_for_user 70 * @expectedDeprecated BP_Messages_Thread::get_current_threads_for_user 71 */ 72 public function test_get_current_threads_for_user_with_old_args() { 73 $u1 = $this->factory->user->create(); 74 $u2 = $this->factory->user->create(); 75 76 $t1 = $this->factory->message->create( array( 77 'sender_id' => $u1, 78 'recipients' => array( $u2 ), 79 'subject' => 'Foo', 80 ) ); 81 82 $t2 = $this->factory->message->create( array( 83 'sender_id' => $u1, 84 'recipients' => array( $u2 ), 85 'subject' => 'Bar', 86 ) ); 87 53 88 $threads = BP_Messages_Thread::get_current_threads_for_user( $u1, 'sentbox', 'all', null, null, 'ar' ); 54 89 55 90 $expected = array( $t2 ); … … class BP_Tests_BP_Messages_Thread extends BP_UnitTestCase { 57 92 58 93 $this->assertSame( $expected, $found ); 59 94 } 60 } 95 } 96 No newline at end of file -
new file tests/phpunit/testcases/messages/template.php
diff --git tests/phpunit/testcases/messages/template.php tests/phpunit/testcases/messages/template.php new file mode 100644 index 0000000..b65accf
- + 1 <?php 2 3 /** 4 * @group message 5 * @group template 6 */ 7 class BP_Tests_Messages_Template extends BP_UnitTestCase { 8 /** 9 * @group bp_has_message_threads 10 */ 11 public function test_has_message_threads() { 12 $u1 = $this->factory->user->create(); 13 $u2 = $this->factory->user->create(); 14 15 // create initial thread 16 $t1 = $this->factory->message->create( array( 17 'sender_id' => $u1, 18 'recipients' => array( $u2 ), 19 ) ); 20 21 // create some replies to thread 22 $this->factory->message->create( array( 23 'thread_id' => $t1, 24 'sender_id' => $u2, 25 'recipients' => array( $u1 ), 26 ) ); 27 $this->factory->message->create( array( 28 'thread_id' => $t1, 29 'sender_id' => $u2, 30 'recipients' => array( $u1 ), 31 ) ); 32 33 $messages_template = new BP_Messages_Box_Template( array( 'user_id' => $u1 ) ); 34 35 $this->assertEquals( 1, $messages_template->thread_count ); 36 $this->assertSame( array( $t1 ), wp_list_pluck( $messages_template->threads, 'thread_id' ) ); 37 } 38 39 /** 40 * @group bp_has_message_threads 41 * 42 * @expectedDeprecated BP_Messages_Box_Template::__construct 43 */ 44 public function test_has_message_threads_old_args() { 45 $u1 = $this->factory->user->create(); 46 $u2 = $this->factory->user->create(); 47 48 // create initial thread 49 $t1 = $this->factory->message->create( array( 50 'sender_id' => $u1, 51 'recipients' => array( $u2 ), 52 ) ); 53 54 // create some replies to thread 55 $this->factory->message->create( array( 56 'thread_id' => $t1, 57 'sender_id' => $u2, 58 'recipients' => array( $u1 ), 59 ) ); 60 $this->factory->message->create( array( 61 'thread_id' => $t1, 62 'sender_id' => $u2, 63 'recipients' => array( $u1 ), 64 ) ); 65 66 $messages_template = new BP_Messages_Box_Template( $u1 ); 67 68 $this->assertEquals( 1, $messages_template->thread_count ); 69 $this->assertSame( array( $t1 ), wp_list_pluck( $messages_template->threads, 'thread_id' ) ); 70 } 71 } 72 No newline at end of file