Commit 44bdb65d by Carsten Brandt

Merge branch 'master' of github.com:yiisoft/yii2

* 'master' of github.com:yiisoft/yii2: Creating transport at 'yii\swiftmailer\Mailer' fixed to track possible "__call". Unit test for 'yii\swiftmailer\Message' fixed.
parents 5ddb0e2c d1f18e43
......@@ -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);
......
......@@ -53,6 +53,8 @@ class MailerTest extends VendorTestCase
$transportConfig = [
'class' => 'Swift_SmtpTransport',
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
];
$mailer->setTransport($transportConfig);
$transport = $mailer->getTransport();
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment