Browse Source

MailSentWith check for reply-to header array

Erwane Breton 6 years ago
parent
commit
f40dc0bfbb

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

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

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

@@ -96,6 +96,7 @@ class EmailTraitTest extends TestCase
         $this->assertMailSentWith('cc@example.com', 'cc');
         $this->assertMailSentWith('bcc@example.com', 'bcc');
         $this->assertMailSentWith('cc2@example.com', 'cc');
+        $this->assertMailSentWith('replyto@example.com', 'replyTo');
     }
 
     /**
@@ -122,6 +123,7 @@ class EmailTraitTest extends TestCase
         $this->assertMailContainsAt(1, 'html');
 
         $this->assertMailSentWithAt(0, 'Hello world', 'subject');
+        $this->assertMailSentWithAt(0, 'replyto@example.com', 'replyTo');
     }
 
     /**
@@ -232,6 +234,7 @@ class EmailTraitTest extends TestCase
         (new Mailer())
             ->setTo(['to@example.com' => 'Foo Bar'])
             ->addTo('alsoto@example.com')
+            ->setReplyTo(['replyto@example.com' => 'Reply to me'])
             ->setCc('cc@example.com')
             ->setBcc(['bcc@example.com' => 'Baz Qux'])
             ->setSubject('Hello world')