From 03e126ccd4b95d36bd596627e97e37d7f8bd7d24 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 18 Aug 2016 15:25:13 -0400 Subject: [PATCH] Make 'default' transport the default when you use array configuration. Refs #9286 --- src/Mailer/Email.php | 4 ++++ tests/TestCase/Mailer/EmailTest.php | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/Mailer/Email.php b/src/Mailer/Email.php index 88500578a48..583bcce4cb8 100644 --- a/src/Mailer/Email.php +++ b/src/Mailer/Email.php @@ -1389,6 +1389,10 @@ protected function _logDelivery($contents) public static function deliver($to = null, $subject = null, $message = null, $transportConfig = 'default', $send = true) { $class = __CLASS__; + + if (is_array($transportConfig)) { + $transportConfig += ['transport' => 'default']; + } $instance = new $class($transportConfig); if ($to !== null) { $instance->to($to); diff --git a/tests/TestCase/Mailer/EmailTest.php b/tests/TestCase/Mailer/EmailTest.php index 53c4b3b820f..3e94668dea3 100644 --- a/tests/TestCase/Mailer/EmailTest.php +++ b/tests/TestCase/Mailer/EmailTest.php @@ -1906,11 +1906,15 @@ public function testSendAttachment() */ public function testDeliver() { + Email::dropTransport('default'); + Email::configTransport('default', ['className' => 'Debug']); + $instance = Email::deliver('all@cakephp.org', 'About', 'Everything ok', ['from' => 'root@cakephp.org'], false); $this->assertInstanceOf('Cake\Mailer\Email', $instance); $this->assertSame($instance->to(), ['all@cakephp.org' => 'all@cakephp.org']); $this->assertSame($instance->subject(), 'About'); $this->assertSame($instance->from(), ['root@cakephp.org' => 'root@cakephp.org']); + $this->assertInstanceOf('Cake\Mailer\AbstractTransport', $instance->transport()); $config = [ 'from' => 'cake@cakephp.org', @@ -2668,6 +2672,8 @@ public function testWrapForJapaneseEncoding() */ public function testMockTransport() { + Email::dropTransport('default'); + $mock = $this->getMockBuilder('\Cake\Mailer\AbstractTransport')->getMock(); $config = ['from' => 'tester@example.org', 'transport' => 'default'];