Changeset 10481
- Timestamp:
- 01/28/2016 07:26:34 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r10478 r10481 2839 2839 * @param string $email_type Type of email being sent. 2840 2840 * @param string|array|int|WP_User $to Either a email address, user ID, WP_User object, 2841 * or an array contain g the address and name.2841 * or an array containing any combination of the above. 2842 2842 * @param array $args { 2843 2843 * Optional. Array of extra. parameters. -
trunk/src/bp-core/classes/class-bp-email-recipient.php
r10473 r10481 50 50 * 51 51 * @param string|array|int|WP_User $email_or_user Either a email address, user ID, WP_User object, 52 * or an array contain g the address and name.52 * or an array containing any combination of the above. 53 53 * @param string $name Optional. If $email_or_user is a string, this is the recipient's name. 54 54 */ … … 95 95 * 96 96 * @param string|array|int|WP_User $email_or_user Either a email address, user ID, WP_User object, 97 * or an array contain g the address and name.97 * or an array containing any combination of the above. 98 98 * @param string $name If $email_or_user is a string, this is the recipient's name. 99 99 * @param BP_Email_Recipient $this Current instance of the email type class. -
trunk/src/bp-core/classes/class-bp-email.php
r10470 r10481 520 520 * 521 521 * @param string|array|int|WP_User $bcc_address Either a email address, user ID, WP_User object, 522 * or an array contain g the address and name.522 * or an array containing any combination of the above. 523 523 * @param string $name Optional. If $bcc_address is a string, this is the recipient's name. 524 524 * @return BP_Email 525 525 */ 526 526 public function set_bcc( $bcc_address, $name = '' ) { 527 $bcc = array( new BP_Email_Recipient( $bcc_address, $name ) ); 527 $bcc = array(); 528 529 if ( is_array( $bcc_address ) ) { 530 foreach ( $bcc_address as $address ) { 531 $bcc[] = new BP_Email_Recipient( $address ); 532 } 533 534 } else { 535 $bcc = array( new BP_Email_Recipient( $bcc_address, $name ) ); 536 } 528 537 529 538 /** … … 534 543 * @param BP_Email_Recipient[] $bcc BCC recipients. 535 544 * @param string|array|int|WP_User $bcc_address Either a email address, user ID, WP_User object, 536 * or an array contain g the address and name.545 * or an array containing any combination of the above. 537 546 * @param string $name Optional. If $bcc_address is a string, this is the recipient's name. 538 547 * @param BP_Email $this Current instance of the email type class. … … 555 564 * 556 565 * @param string|array|int|WP_User $cc_address Either a email address, user ID, WP_User object, 557 * or an array contain g the address and name.566 * or an array containing any combination of the above. 558 567 * @param string $name Optional. If $cc_address is a string, this is the recipient's name. 559 568 * @return BP_Email 560 569 */ 561 570 public function set_cc( $cc_address, $name = '' ) { 562 $cc = array( new BP_Email_Recipient( $cc_address, $name ) ); 571 $cc = array(); 572 573 if ( is_array( $cc_address ) ) { 574 foreach ( $cc_address as $address ) { 575 $cc[] = new BP_Email_Recipient( $address ); 576 } 577 578 } else { 579 $cc = array( new BP_Email_Recipient( $cc_address, $name ) ); 580 } 563 581 564 582 /** … … 569 587 * @param BP_Email_Recipient[] $cc CC recipients. 570 588 * @param string|array|int|WP_User $cc_address Either a email address, user ID, WP_User object, 571 * or an array contain g the address and name.589 * or an array containing any combination of the above. 572 590 * @param string $name Optional. If $cc_address is a string, this is the recipient's name. 573 591 * @param BP_Email $this Current instance of the email type class. … … 658 676 * @since 2.5.0 659 677 * 660 * @param string|array|int|WP_User $email_address Either a email address, user ID, WP_User object, 661 * or an array containg the address and name. 678 * @param string|array|int|WP_User $email_address Either a email address, user ID, or WP_User object. 662 679 * @param string $name Optional. If $email_address is a string, this is the recipient's name. 663 680 * @return BP_Email … … 672 689 * 673 690 * @param BP_Email_Recipient $from Sender details. 674 * @param string|array|int|WP_User $email_address Either a email address, user ID, WP_User object, 675 * or an array containg the address and name. 691 * @param string|array|int|WP_User $email_address Either a email address, user ID, or WP_User object. 676 692 * @param string $name Optional. If $email_address is a string, this is the recipient's name. 677 693 * @param BP_Email $this Current instance of the email type class. … … 727 743 * 728 744 * @param string|array|int|WP_User $email_address Either a email address, user ID, WP_User object, 729 * or an array contain g the address and name.745 * or an array containing any combination of the above. 730 746 * @param string $name Optional. If $email_address is a string, this is the recipient's name. 731 747 * @return BP_Email … … 741 757 * @param BP_Email_Recipient $reply_to "Reply to" recipient. 742 758 * @param string|array|int|WP_User $email_address Either a email address, user ID, WP_User object, 743 * or an array contain g the address and name.759 * or an array containing any combination of the above. 744 760 * @param string $name Optional. If $email_address is a string, this is the recipient's name. 745 761 * @param BP_Email $this Current instance of the email type class. … … 816 832 * 817 833 * @param string|array|int|WP_User $to_address Either a email address, user ID, WP_User object, 818 * or an array contain g the address and name.834 * or an array containing any combination of the above. 819 835 * @param string $name Optional. If $to_address is a string, this is the recipient's name. 820 836 * @return BP_Email 821 837 */ 822 838 public function set_to( $to_address, $name = '' ) { 823 $to = array( new BP_Email_Recipient( $to_address, $name ) ); 839 $to = array(); 840 841 if ( is_array( $to_address ) ) { 842 foreach ( $to_address as $address ) { 843 $to[] = new BP_Email_Recipient( $address ); 844 } 845 846 } else { 847 $to = array( new BP_Email_Recipient( $to_address, $name ) ); 848 } 824 849 825 850 /** -
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.