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 ...@@ -145,7 +145,7 @@ class Mailer extends BaseMailer
$transport->$name = $value; $transport->$name = $value;
} else { } else {
$setter = 'set' . $name; $setter = 'set' . $name;
if (method_exists($transport, $setter)) { if (method_exists($transport, $setter) || method_exists($transport, '__call')) {
$transport->$setter($value); $transport->$setter($value);
} else { } else {
throw new InvalidConfigException('Setting unknown property: ' . get_class($transport) . '::' . $name); throw new InvalidConfigException('Setting unknown property: ' . get_class($transport) . '::' . $name);
......
...@@ -53,6 +53,8 @@ class MailerTest extends VendorTestCase ...@@ -53,6 +53,8 @@ class MailerTest extends VendorTestCase
$transportConfig = [ $transportConfig = [
'class' => 'Swift_SmtpTransport', 'class' => 'Swift_SmtpTransport',
'host' => 'localhost', 'host' => 'localhost',
'username' => 'username',
'password' => 'password',
]; ];
$mailer->setTransport($transportConfig); $mailer->setTransport($transportConfig);
$transport = $mailer->getTransport(); $transport = $mailer->getTransport();
......
...@@ -119,6 +119,8 @@ class MessageTest extends VendorTestCase ...@@ -119,6 +119,8 @@ class MessageTest extends VendorTestCase
{ {
$charset = 'utf-16'; $charset = 'utf-16';
$subject = 'Test Subject'; $subject = 'Test Subject';
$from = 'from@somedomain.com';
$replyTo = 'reply-to@somedomain.com';
$to = 'someuser@somedomain.com'; $to = 'someuser@somedomain.com';
$cc = 'ccuser@somedomain.com'; $cc = 'ccuser@somedomain.com';
$bcc = 'bccuser@somedomain.com'; $bcc = 'bccuser@somedomain.com';
...@@ -126,6 +128,8 @@ class MessageTest extends VendorTestCase ...@@ -126,6 +128,8 @@ class MessageTest extends VendorTestCase
$messageString = $this->createTestMessage() $messageString = $this->createTestMessage()
->setCharset($charset) ->setCharset($charset)
->setSubject($subject) ->setSubject($subject)
->setFrom($from)
->setReplyTo($replyTo)
->setTo($to) ->setTo($to)
->setCc($cc) ->setCc($cc)
->setBcc($bcc) ->setBcc($bcc)
...@@ -133,6 +137,8 @@ class MessageTest extends VendorTestCase ...@@ -133,6 +137,8 @@ class MessageTest extends VendorTestCase
$this->assertContains('charset=' . $charset, $messageString, 'Incorrect charset!'); $this->assertContains('charset=' . $charset, $messageString, 'Incorrect charset!');
$this->assertContains('Subject: ' . $subject, $messageString, 'Incorrect "Subject" header!'); $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('To: ' . $to, $messageString, 'Incorrect "To" header!');
$this->assertContains('Cc: ' . $cc, $messageString, 'Incorrect "Cc" header!'); $this->assertContains('Cc: ' . $cc, $messageString, 'Incorrect "Cc" header!');
$this->assertContains('Bcc: ' . $bcc, $messageString, 'Incorrect "Bcc" header!'); $this->assertContains('Bcc: ' . $bcc, $messageString, 'Incorrect "Bcc" header!');
...@@ -141,19 +147,6 @@ class MessageTest extends VendorTestCase ...@@ -141,19 +147,6 @@ class MessageTest extends VendorTestCase
/** /**
* @depends testGetSwiftMessage * @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() public function testSend()
{ {
$message = $this->createTestMessage(); $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