Skip to content

Commit

Permalink
Make 'default' transport the default when you use array configuration.
Browse files Browse the repository at this point in the history
Refs #9286
  • Loading branch information
markstory committed Aug 18, 2016
1 parent 297b898 commit 03e126c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Mailer/Email.php
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions tests/TestCase/Mailer/EmailTest.php
Expand Up @@ -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',
Expand Down Expand Up @@ -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'];

Expand Down

0 comments on commit 03e126c

Please sign in to comment.