Browse Source

Fixes #61: yii\swiftmailer\Mailer::setTransport has no effect after sending of first message (#62)

* Fixes #61: setTransport has no effect after sending of first message

* Updated CHANGELOG.md [skip ci]
tags/2.1.1
Dmitry Kulikov 7 years ago committed by Carsten Brandt
parent
commit
cbc5a8e1f4
  1. 2
      CHANGELOG.md
  2. 1
      src/Mailer.php
  3. 3
      tests/MailerTest.php

2
CHANGELOG.md

@ -4,7 +4,7 @@ Yii Framework 2 swiftmailer extension Change Log
2.1.1 under development 2.1.1 under development
----------------------- -----------------------
- no changes in this release. - Bug #61: Fixed `yii\swiftmailer\Mailer::setTransport` has no effect after sending of first message (dmitry-kulikov)
2.1.0 August 04, 2017 2.1.0 August 04, 2017

1
src/Mailer.php

@ -121,6 +121,7 @@ class Mailer extends BaseMailer
throw new InvalidConfigException('"' . get_class($this) . '::transport" should be either object or array, "' . gettype($transport) . '" given.'); throw new InvalidConfigException('"' . get_class($this) . '::transport" should be either object or array, "' . gettype($transport) . '" given.');
} }
$this->_transport = $transport; $this->_transport = $transport;
$this->_swiftMailer = null;
} }
/** /**

3
tests/MailerTest.php

@ -33,10 +33,11 @@ class MailerTest extends TestCase
public function testSetupTransport() public function testSetupTransport()
{ {
$mailer = new Mailer(); $mailer = new Mailer();
$mailer->getSwiftMailer(); // make sure accessing SwiftMailer does not affect behavior of setTransport
$transport = new \Swift_SendmailTransport(); $transport = new \Swift_SendmailTransport();
$mailer->setTransport($transport); $mailer->setTransport($transport);
$this->assertEquals($transport, $mailer->getTransport(), 'Unable to setup transport!'); $this->assertSame($transport, $mailer->getSwiftMailer()->getTransport(), 'Unable to setup transport!');
} }
/** /**

Loading…
Cancel
Save