From 7acdf1e436f8d18af0afb11e649791af47277ff6 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 17 Apr 2011 19:40:18 -0400 Subject: [PATCH] Changed the method layout to template. Template is required to render, but layout is not. --- lib/Cake/Network/CakeEmail.php | 20 ++++++------ lib/Cake/tests/Case/Network/CakeEmailTest.php | 31 ++++++++++++++++--- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/lib/Cake/Network/CakeEmail.php b/lib/Cake/Network/CakeEmail.php index 69049f868..ae62d4a40 100644 --- a/lib/Cake/Network/CakeEmail.php +++ b/lib/Cake/Network/CakeEmail.php @@ -638,22 +638,22 @@ class CakeEmail { } /** - * Layout and template + * Template and layout * - * @param string $layout - * @param string $template + * @param mixed $template Template name or null to not use + * @param mixed $layout Layout name or null to not use * @return mixed */ - public function layout($layout = null, $template = null) { - if ($layout === null) { + public function template($template = false, $layout = false) { + if ($template === false) { return array( - 'layout' => $this->_layout, - 'template' => $this->_template + 'template' => $this->_template, + 'layout' => $this->_layout ); } - $this->_layout = (string)$layout; - if ($template !== null) { - $this->_template = (string)$template; + $this->_template = $template; + if ($layout !== false) { + $this->_layout = $layout; } return $this; } diff --git a/lib/Cake/tests/Case/Network/CakeEmailTest.php b/lib/Cake/tests/Case/Network/CakeEmailTest.php index 7149c0c5b..d96503a0e 100644 --- a/lib/Cake/tests/Case/Network/CakeEmailTest.php +++ b/lib/Cake/tests/Case/Network/CakeEmailTest.php @@ -409,7 +409,30 @@ class CakeEmailTest extends CakeTestCase { } /** - * testAttachments + * testTemplate method + * + * @return void + */ + public function testTemplate() { + $this->CakeEmail->template('template', 'layout'); + $expected = array('template' => 'template', 'layout' => 'layout'); + $this->assertIdentical($this->CakeEmail->template(), $expected); + + $this->CakeEmail->template('new_template'); + $expected = array('template' => 'new_template', 'layout' => 'layout'); + $this->assertIdentical($this->CakeEmail->template(), $expected); + + $this->CakeEmail->template('template', null); + $expected = array('template' => 'template', 'layout' => null); + $this->assertIdentical($this->CakeEmail->template(), $expected); + + $this->CakeEmail->template(null, null); + $expected = array('template' => null, 'layout' => null); + $this->assertIdentical($this->CakeEmail->template(), $expected); + } + +/** + * testAttachments method * * @return void */ @@ -510,7 +533,7 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail->to(array('you@cakephp.org' => 'You')); $this->CakeEmail->subject('My title'); $this->CakeEmail->config(array('empty')); - $this->CakeEmail->layout('default', 'default'); + $this->CakeEmail->template('default', 'default'); $result = $this->CakeEmail->send(); $this->assertTrue((bool)strpos(DebugTransport::$lastEmail, 'This email was sent using the CakePHP Framework')); @@ -532,7 +555,7 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail->to(array('you@cakephp.org' => 'You')); $this->CakeEmail->subject('My title'); $this->CakeEmail->config(array('empty')); - $this->CakeEmail->layout('default', 'custom'); + $this->CakeEmail->template('custom', 'default'); $this->CakeEmail->viewVars(array('value' => 12345)); $result = $this->CakeEmail->send(); @@ -553,7 +576,7 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail->to(array('you@cakephp.org' => 'You')); $this->CakeEmail->subject('My title'); $this->CakeEmail->config(array('empty')); - $this->CakeEmail->layout('default', 'default'); + $this->CakeEmail->template('default', 'default'); $this->CakeEmail->emailFormat('both'); $result = $this->CakeEmail->send();