Merge pull request #1375 from dereuromark/master-cake-email

Move boundary calculation inside _render()
This commit is contained in:
Mark Story 2013-07-01 06:12:24 -07:00
commit da033cbed7
2 changed files with 27 additions and 2 deletions

View file

@ -1070,8 +1070,6 @@ class CakeEmail {
$content = implode("\n", $content) . "\n";
}
$this->_textMessage = $this->_htmlMessage = '';
$this->_createBoundary();
$this->_message = $this->_render($this->_wrap($content));
$contents = $this->transportClass()->send($this);
@ -1444,9 +1442,12 @@ class CakeEmail {
* @return array Email body ready to be sent
*/
protected function _render($content) {
$this->_textMessage = $this->_htmlMessage = '';
$content = implode("\n", $content);
$rendered = $this->_renderTemplates($content);
$this->_createBoundary();
$msg = array();
$contentIds = array_filter((array)Hash::extract($this->_attachments, '{s}.contentId'));

View file

@ -65,6 +65,14 @@ class TestCakeEmail extends CakeEmail {
return $this->_encode($text);
}
/**
* Render to protected method
*
*/
public function render($content) {
return $this->_render($content);
}
}
/*
@ -1484,6 +1492,22 @@ class CakeEmailTest extends CakeTestCase {
$this->assertSame($expected, $result);
}
/**
* testRender method
*
* @return void
*/
public function testRenderWithLayoutAndAttachment() {
$this->CakeEmail->emailFormat('html');
$this->CakeEmail->template('html', 'default');
$this->CakeEmail->attachments(array(CAKE . 'basics.php'));
$result = $this->CakeEmail->render(array());
$this->assertNotEmpty($result);
$result = $this->CakeEmail->getBoundary();
$this->assertNotEmpty($result);
}
/**
* testConstructWithConfigArray method
*