Implemented methods to configure "from".

This commit is contained in:
Juan Basso 2011-03-01 01:31:30 -03:00
parent 8f5049e3b1
commit 5cb58e8f99
2 changed files with 51 additions and 0 deletions

View file

@ -199,6 +199,30 @@ class CakeEmail {
}
}
/**
* Set From
*
* @param string $email
* @param string $name
* @return void
*/
public function setFrom($email, $name = null) {
if ($name !== null) {
$this->_from = array($email => $name);
} else {
$this->_from = array($email => $email);
}
}
/**
* Get the From information
*
* @return array Key is email, Value is name. If Key is equal of Value, the name is not specified
*/
public function getFrom() {
return $this->_from;
}
/**
* Sets headers for the message
*

View file

@ -25,6 +25,33 @@ App::import('Core', 'CakeEmail');
*/
class CakeEmailTest extends CakeTestCase {
/**
* setUp
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->CakeEmail = new CakeEmail();
}
/**
* testFrom method
*
* @return void
*/
public function testFrom() {
$this->assertIdentical($this->CakeEmail->getFrom(), array());
$this->CakeEmail->setFrom('cake@cakephp.org');
$expected = array('cake@cakephp.org' => 'cake@cakephp.org');
$this->assertIdentical($this->CakeEmail->getFrom(), $expected);
$this->CakeEmail->setFrom('cake@cakephp.org', 'CakePHP');
$expected = array('cake@cakephp.org' => 'CakePHP');
$this->assertIdentical($this->CakeEmail->getFrom(), $expected);
}
/**
* testHeaders method
*