Fixing issue #5764

This commit is contained in:
Jan Dorsman 2015-01-28 14:33:42 +01:00 committed by ADmad
parent 8f50f1eab2
commit e3b5306521
2 changed files with 23 additions and 0 deletions

View file

@ -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;

View file

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