Skip to content
Permalink
Browse files

Allow setting only default layout without specifying template in emai…

…l config.

Closes #3336
  • Loading branch information...
ADmad committed Apr 22, 2014
1 parent bd5ce96 commit ead494eec117749f294d290e092c551eac00d7fd
Showing with 26 additions and 7 deletions.
  1. +6 −7 lib/Cake/Network/Email/CakeEmail.php
  2. +20 −0 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
@@ -1224,15 +1224,14 @@ protected function _applyConfig($config) {
$this->setHeaders($config['headers']);
unset($config['headers']);
}
if (array_key_exists('template', $config)) {
$layout = false;
if (array_key_exists('layout', $config)) {
$layout = $config['layout'];
unset($config['layout']);
}
$this->template($config['template'], $layout);
unset($config['template']);
$this->_template = $config['template'];
}
if (array_key_exists('layout', $config)) {
$this->_layout = $config['layout'];
}
$this->transportClass()->config($config);
}
@@ -1807,6 +1807,26 @@ public function testConstructWithConfigArray() {
$this->assertTrue((bool)strpos($result['headers'], 'To: '));
}
/**
* testConfigArrayWithLayoutWithoutTemplate method
*
* @return void
*/
public function testConfigArrayWithLayoutWithoutTemplate() {
$configs = array(
'from' => array('some@example.com' => 'My website'),
'to' => 'test@example.com',
'subject' => 'Test mail subject',
'transport' => 'Debug',
'layout' => 'custom'
);
$this->CakeEmail = new CakeEmail($configs);
$result = $this->CakeEmail->template();
$this->assertEquals('', $result['template']);
$this->assertEquals($configs['layout'], $result['layout']);
}
/**
* testConstructWithConfigString method
*

0 comments on commit ead494e

Please sign in to comment.
You can’t perform that action at this time.