Browse Source

Merge pull request #9292 from cakephp/issue-9286

Change default transport to 'default'
Mark Story 9 years ago
parent
commit
25bcf1b3d6
2 changed files with 11 additions and 1 deletions
  1. 5 1
      src/Mailer/Email.php
  2. 6 0
      tests/TestCase/Mailer/EmailTest.php

+ 5 - 1
src/Mailer/Email.php

@@ -1386,9 +1386,13 @@ class Email implements JsonSerializable, Serializable
      * @return \Cake\Mailer\Email Instance of Cake\Mailer\Email
      * @throws \InvalidArgumentException
      */
-    public static function deliver($to = null, $subject = null, $message = null, $transportConfig = 'fast', $send = true)
+    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);

+ 6 - 0
tests/TestCase/Mailer/EmailTest.php

@@ -1906,11 +1906,15 @@ class EmailTest extends TestCase
      */
     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 @@ HTML;
      */
     public function testMockTransport()
     {
+        Email::dropTransport('default');
+
         $mock = $this->getMockBuilder('\Cake\Mailer\AbstractTransport')->getMock();
         $config = ['from' => 'tester@example.org', 'transport' => 'default'];