diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index f0cd00f3045..9500a767802 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1638,21 +1638,21 @@ protected function _renderTemplates($content) { $View->plugin = $layoutPlugin; } - // Convert null to false, as View needs false to disable - // the layout. - if ($layout === null) { - $layout = false; - } - if ($View->get('content') === null) { $View->set('content', $content); } + // Convert null to false, as View needs false to disable + // the layout. + if ($this->_layout === null) { + $this->_layout = false; + } + foreach ($types as $type) { $View->hasRendered = false; $View->viewPath = $View->layoutPath = 'Emails' . DS . $type; - $render = $View->render($template, $layout); + $render = $View->render($this->_template, $this->_layout); $render = str_replace(array("\r\n", "\r"), "\n", $render); $rendered[$type] = $this->_encodeString($render, $this->charset); } diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 5b0fdf6ed52..362081cca1f 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -1472,7 +1472,7 @@ public function testSendRenderPlugin() { App::build(array( 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) )); - CakePlugin::load('TestPlugin'); + CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); $this->CakeEmail->reset(); $this->CakeEmail->transport('debug'); @@ -1493,6 +1493,14 @@ public function testSendRenderPlugin() { $this->assertContains('Into TestPlugin.', $result['message']); $this->assertContains('This email was sent using the TestPlugin.', $result['message']); + $this->CakeEmail->template( + 'TestPlugin.test_plugin_tpl', + 'TestPluginTwo.default' + ); + $result = $this->CakeEmail->send(); + $this->assertContains('Into TestPlugin.', $result['message']); + $this->assertContains('This email was sent using TestPluginTwo.', $result['message']); + // test plugin template overridden by theme $this->CakeEmail->theme('TestTheme'); $result = $this->CakeEmail->send();