Changeset 10481 for trunk/tests/phpunit/testcases/core/class-bp-email.php
- Timestamp:
- 01/28/2016 07:26:34 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/class-bp-email.php
r10470 r10481 5 5 */ 6 6 class BP_Tests_Email extends BP_UnitTestCase { 7 protected $u1; 8 protected $u2; 9 7 10 public function setUp() { 8 11 parent::setUp(); 12 13 $this->u1 = $this->factory->user->create( array( 14 'display_name' => 'Unit Test', 15 'user_email' => 'test1@example.com', 16 ) ); 17 18 $this->u2 = $this->factory->user->create( array( 19 'display_name' => 'Unit Test2', 20 'user_email' => 'test2@example.com', 21 ) ); 22 9 23 remove_filter( 'bp_email_get_headers', 'bp_email_set_default_headers', 6, 4 ); 10 24 remove_filter( 'bp_email_get_tokens', 'bp_email_set_default_tokens', 6, 4 ); … … 156 170 $this->assertSame( '<b>hello world</b><b>hello world</b>', $email->get_content() ); 157 171 } 172 173 public function test_multiple_recipients_are_supported_by_address() { 174 $email1 = 'test1@example.com'; 175 $email2 = 'test2@example.com'; 176 $email = new BP_Email( 'fake_type' ); 177 178 $email->set_to( array( $email1, $email2 ) ); 179 $addresses = $email->get_to(); 180 181 $this->assertCount( 2, $addresses ); 182 $this->assertSame( $email1, $addresses[0]->get_address() ); 183 $this->assertSame( $email2, $addresses[1]->get_address() ); 184 } 185 186 public function test_multiple_recipients_are_supported_by_wp_user_object() { 187 $user1 = get_user_by( 'id', $this->u1 ); 188 $user2 = get_user_by( 'id', $this->u2 ); 189 $email = new BP_Email( 'fake_type' ); 190 191 $email->set_to( array( $user1, $user2 ) ); 192 $addresses = $email->get_to(); 193 194 $this->assertCount( 2, $addresses ); 195 $this->assertSame( $user1->user_email, $addresses[0]->get_address() ); 196 $this->assertSame( $user2->user_email, $addresses[1]->get_address() ); 197 } 198 199 public function test_multiple_recipients_are_supported_by_wp_user_id() { 200 $user1 = get_user_by( 'id', $this->u1 ); 201 $user2 = get_user_by( 'id', $this->u2 ); 202 $email = new BP_Email( 'fake_type' ); 203 $email->set_to( array( $this->u1, $this->u2 ) ); 204 $addresses = $email->get_to(); 205 206 $this->assertCount( 2, $addresses ); 207 $this->assertSame( $user1->user_email, $addresses[0]->get_address() ); 208 $this->assertSame( $user2->user_email, $addresses[1]->get_address() ); 209 } 210 211 public function test_multiple_recipients_are_supported() { 212 $user1 = get_user_by( 'id', $this->u1 ); 213 $user2 = get_user_by( 'id', $this->u2 ); 214 $user3 = 'test3@example.com'; 215 $email = new BP_Email( 'fake_type' ); 216 217 $email->set_to( array( $user1, $this->u2, $user3 ) ); 218 $addresses = $email->get_to(); 219 220 $this->assertCount( 3, $addresses ); 221 $this->assertSame( $user1->user_email, $addresses[0]->get_address() ); 222 $this->assertSame( $user2->user_email, $addresses[1]->get_address() ); 223 $this->assertSame( $user3, $addresses[2]->get_address() ); 224 } 158 225 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)