Skip to content

Commit

Permalink
Fixing issue #5764
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Dorsman authored and ADmad committed Feb 19, 2015
1 parent 8f50f1e commit e3b5306
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -353,6 +353,10 @@ public function __construct($config = null) {


if ($config) { if ($config) {
$this->config($config); $this->config($config);
} elseif (config('email')) {
if (property_exists($this->_configClass, 'default')) {
$this->config('default');
}
} }
if (empty($this->headerCharset)) { if (empty($this->headerCharset)) {
$this->headerCharset = $this->charset; $this->headerCharset = $this->charset;
Expand Down
19 changes: 19 additions & 0 deletions lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
Expand Up @@ -2449,4 +2449,23 @@ public function assertLineLengths($message) {
} }
} }


/**
* 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();
}
}

} }

0 comments on commit e3b5306

Please sign in to comment.