diff --git a/extensions/swiftmailer/Mailer.php b/extensions/swiftmailer/Mailer.php index 58f0f23..c00fad6 100644 --- a/extensions/swiftmailer/Mailer.php +++ b/extensions/swiftmailer/Mailer.php @@ -145,7 +145,7 @@ class Mailer extends BaseMailer $transport->$name = $value; } else { $setter = 'set' . $name; - if (method_exists($transport, $setter)) { + if (method_exists($transport, $setter) || method_exists($transport, '__call')) { $transport->$setter($value); } else { throw new InvalidConfigException('Setting unknown property: ' . get_class($transport) . '::' . $name); diff --git a/tests/unit/extensions/swiftmailer/MailerTest.php b/tests/unit/extensions/swiftmailer/MailerTest.php index 306e128..24602b2 100644 --- a/tests/unit/extensions/swiftmailer/MailerTest.php +++ b/tests/unit/extensions/swiftmailer/MailerTest.php @@ -53,6 +53,8 @@ class MailerTest extends VendorTestCase $transportConfig = [ 'class' => 'Swift_SmtpTransport', 'host' => 'localhost', + 'username' => 'username', + 'password' => 'password', ]; $mailer->setTransport($transportConfig); $transport = $mailer->getTransport(); diff --git a/tests/unit/extensions/swiftmailer/MessageTest.php b/tests/unit/extensions/swiftmailer/MessageTest.php index fdecd88..c46b43d 100644 --- a/tests/unit/extensions/swiftmailer/MessageTest.php +++ b/tests/unit/extensions/swiftmailer/MessageTest.php @@ -119,6 +119,8 @@ class MessageTest extends VendorTestCase { $charset = 'utf-16'; $subject = 'Test Subject'; + $from = 'from@somedomain.com'; + $replyTo = 'reply-to@somedomain.com'; $to = 'someuser@somedomain.com'; $cc = 'ccuser@somedomain.com'; $bcc = 'bccuser@somedomain.com'; @@ -126,6 +128,8 @@ class MessageTest extends VendorTestCase $messageString = $this->createTestMessage() ->setCharset($charset) ->setSubject($subject) + ->setFrom($from) + ->setReplyTo($replyTo) ->setTo($to) ->setCc($cc) ->setBcc($bcc) @@ -133,6 +137,8 @@ class MessageTest extends VendorTestCase $this->assertContains('charset=' . $charset, $messageString, 'Incorrect charset!'); $this->assertContains('Subject: ' . $subject, $messageString, 'Incorrect "Subject" header!'); + $this->assertContains('From: ' . $from, $messageString, 'Incorrect "From" header!'); + $this->assertContains('Reply-To: ' . $replyTo, $messageString, 'Incorrect "Reply-To" header!'); $this->assertContains('To: ' . $to, $messageString, 'Incorrect "To" header!'); $this->assertContains('Cc: ' . $cc, $messageString, 'Incorrect "Cc" header!'); $this->assertContains('Bcc: ' . $bcc, $messageString, 'Incorrect "Bcc" header!'); @@ -141,19 +147,6 @@ class MessageTest extends VendorTestCase /** * @depends testGetSwiftMessage */ - public function testSetupFrom() - { - $from = 'someuser@somedomain.com'; - $messageString = $this->createTestMessage() - ->setFrom($from) - ->toString(); - $this->assertContains('From: ' . $from, $messageString, 'Incorrect "From" header!'); - $this->assertContains('Reply-To: ' . $from, $messageString, 'Incorrect "Reply-To" header!'); - } - - /** - * @depends testGetSwiftMessage - */ public function testSend() { $message = $this->createTestMessage();