From e3b530652117e606d6c3f648d821e07055520c8d Mon Sep 17 00:00:00 2001 From: Jan Dorsman Date: Wed, 28 Jan 2015 14:33:42 +0100 Subject: [PATCH] Fixing issue #5764 --- lib/Cake/Network/Email/CakeEmail.php | 4 ++++ .../Test/Case/Network/Email/CakeEmailTest.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 41b83032b..7150bb417 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -353,6 +353,10 @@ class CakeEmail { if ($config) { $this->config($config); + } elseif (config('email')) { + if (property_exists($this->_configClass, 'default')) { + $this->config('default'); + } } if (empty($this->headerCharset)) { $this->headerCharset = $this->charset; diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 1dc125fea..7668baad7 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -2449,4 +2449,23 @@ HTML; } } +/** + * Test if the EmailConfig::$default configuration is read when present + * + * @return void + */ + public function testDefaultConfig() { + $defaultConfig = new File(APP . 'Config' . DS . 'email.php.default'); + $emailConfig = new File(APP . 'Config' . DS . 'email.php'); + $hasConfig = $emailConfig->exists(); + $this->skipIf(!$defaultConfig->copy(APP . 'Config' . DS . 'email.php', false)); + + $Email = new CakeEmail(); + $this->skipIf(!property_exists('EmailConfig', 'default')); + $this->assertEquals('you@localhost', current($Email->from())); + if (!$hasConfig) { + $emailConfig->delete(); + } + } + }