mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-12 20:49:50 +00:00
Implemented methods to configure "from".
This commit is contained in:
parent
8f5049e3b1
commit
5cb58e8f99
2 changed files with 51 additions and 0 deletions
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue