CakeEmail::viewVars() now merge the param with previous config.

This commit is contained in:
Juan Basso 2011-04-17 20:57:57 -04:00
parent 7acdf1e436
commit 5ea3b75b2f
2 changed files with 20 additions and 2 deletions

View file

@ -675,14 +675,14 @@ class CakeEmail {
/**
* Variables to be set on render
*
* @param array
* @param array $viewVars
* @return mixed
*/
public function viewVars($viewVars = null) {
if ($viewVars === null) {
return $this->_viewVars;
}
$this->_viewVars = $viewVars;
$this->_viewVars = array_merge($this->_viewVars, (array)$viewVars);
return $this;
}

View file

@ -431,6 +431,24 @@ class CakeEmailTest extends CakeTestCase {
$this->assertIdentical($this->CakeEmail->template(), $expected);
}
/**
* testViewVars method
*
* @return void
*/
public function testViewVars() {
$this->assertIdentical($this->CakeEmail->viewVars(), array());
$this->CakeEmail->viewVars(array('value' => 12345));
$this->assertIdentical($this->CakeEmail->viewVars(), array('value' => 12345));
$this->CakeEmail->viewVars(array('name' => 'CakePHP'));
$this->assertIdentical($this->CakeEmail->viewVars(), array('value' => 12345, 'name' => 'CakePHP'));
$this->CakeEmail->viewVars(array('value' => 4567));
$this->assertIdentical($this->CakeEmail->viewVars(), array('value' => 4567, 'name' => 'CakePHP'));
}
/**
* testAttachments method
*