Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/30/2016 08:39:59 PM (10 years ago)
Author:
djpaul
Message:

Emails: new param for set_bcc|cc|to() to add to current values

The default behaviour remains to replace the current value.

This will allow plugin developers to easily append a new email
recipient without having to re-add the existing recipients.

See #6592

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/class-bp-email.php

    r10481 r10482  
    223223        $this->assertSame( $user3,             $addresses[2]->get_address() );
    224224    }
     225
     226    public function test_replacing_existing_recipients_with_new_recipients() {
     227        $email              = new BP_Email( 'fake_type' );
     228        $original_recipient = 'test1@example.com';
     229        $new_recipient      = 'test2@example.com';
     230
     231        $email->set_to( $original_recipient );
     232        $addresses = $email->get_to();
     233        $this->assertSame( $original_recipient, $addresses[0]->get_address() );
     234
     235        $email->set_to( $new_recipient );
     236        $addresses = $email->get_to();
     237        $this->assertSame( $new_recipient, $addresses[0]->get_address() );
     238    }
     239
     240    public function test_appending_new_recipients_to_existing_recipients() {
     241        $email              = new BP_Email( 'fake_type' );
     242        $original_recipient = 'test1@example.com';
     243        $new_recipient      = 'test2@example.com';
     244
     245        $email->set_to( $original_recipient );
     246        $addresses = $email->get_to();
     247        $this->assertSame( $original_recipient, $addresses[0]->get_address() );
     248
     249        $email->set_to( $new_recipient, '', 'add' );
     250        $addresses = $email->get_to();
     251        $this->assertSame( $original_recipient, $addresses[0]->get_address() );
     252        $this->assertSame( $new_recipient, $addresses[1]->get_address() );
     253    }
    225254}
Note: See TracChangeset for help on using the changeset viewer.