Skip to content
Permalink
Browse files

Allow CakeEmail::template() to disable layout rendering.

Fix the code to act as documented. Sending template('view', null) should
disable layout rendering.

Fixes #3983
  • Loading branch information...
markstory committed Aug 13, 2013
1 parent 3bdcf7b commit cb6ea82fea919eff667aa5c79debf3d09a1522d6
Showing with 25 additions and 0 deletions.
  1. +5 −0 lib/Cake/Network/Email/CakeEmail.php
  2. +20 −0 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
@@ -1573,6 +1573,11 @@ protected function _renderTemplates($content) {
if ($this->_theme) {
$View->theme = $this->_theme;
}
// Convert null to false, as View needs false to disable
// the layout.
if ($layout === null) {
$layout = false;
}
foreach ($types as $type) {
$View->set('content', $content);
@@ -1048,6 +1048,26 @@ public function testSendRender() {
$this->assertContains('To: ', $result['headers']);
}
/**
* test sending and rendering with no layout
*
* @return void
*/
public function testSendRenderNoLayout() {
$this->CakeEmail->reset();
$this->CakeEmail->transport('debug');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->to(array('you@cakephp.org' => 'You'));
$this->CakeEmail->subject('My title');
$this->CakeEmail->config(array('empty'));
$this->CakeEmail->template('default', null);
$result = $this->CakeEmail->send('message body.');
$this->assertContains('message body.', $result['message']);
$this->assertNotContains('This email was sent using the CakePHP Framework', $result['message']);
}
/**
* testSendRender method for ISO-2022-JP
*

0 comments on commit cb6ea82

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.