Browse Source

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.
tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
44bdb65d7b
  1. 2
      extensions/swiftmailer/Mailer.php
  2. 2
      tests/unit/extensions/swiftmailer/MailerTest.php
  3. 19
      tests/unit/extensions/swiftmailer/MessageTest.php

2
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);

2
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();

19
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();

Loading…
Cancel
Save