Skip to content

Commit

Permalink
Implemented methods to configure "from".
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Apr 13, 2011
1 parent 8f5049e commit 5cb58e8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/Cake/Network/CakeEmail.php
Expand Up @@ -199,6 +199,30 @@ public function __construct() {
}
}

/**
* 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
*
Expand Down
27 changes: 27 additions & 0 deletions lib/Cake/tests/Case/Network/CakeEmailTest.php
Expand Up @@ -25,6 +25,33 @@
*/
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
*
Expand Down

0 comments on commit 5cb58e8

Please sign in to comment.