Browse Source

Fixed multiple addresses in same variable

Jeremy Harris 8 years ago
parent
commit
952552c82b

+ 2 - 2
src/TestSuite/Constraint/Email/MailSentWith.php

@@ -47,8 +47,8 @@ class MailSentWith extends MailConstraintBase
         $emails = $this->getEmails();
         foreach ($emails as $email) {
             $value = $email->{'get' . ucfirst($this->method)}();
-            if (in_array($this->method, ['to', 'cc', 'bcc', 'from'])) {
-                $value = key($value);
+            if (in_array($this->method, ['to', 'cc', 'bcc', 'from']) && isset($value[$other])) {
+                return true;
             }
             if ($value === $other) {
                 return true;

+ 2 - 0
tests/TestCase/TestSuite/EmailTraitTest.php

@@ -77,6 +77,7 @@ class EmailTraitTest extends TestCase
         $this->assertMailSentFrom('alternate@example.com');
 
         $this->assertMailSentTo('to@example.com');
+        $this->assertMailSentTo('alsoto@example.com');
         $this->assertMailSentTo('to2@example.com');
 
         $this->assertMailContains('text');
@@ -204,6 +205,7 @@ class EmailTraitTest extends TestCase
     {
         (new Email())
             ->setTo(['to@example.com' => 'Foo Bar'])
+            ->addTo('alsoto@example.com')
             ->setCc('cc@example.com')
             ->setBcc(['bcc@example.com' => 'Baz Qux'])
             ->setSubject('Hello world')