Methods to set/get subject.

This commit is contained in:
Juan Basso 2011-03-01 14:20:13 -03:00
parent 187304cebb
commit 82835a3566
2 changed files with 36 additions and 1 deletions

View file

@ -97,7 +97,7 @@ class CakeEmail {
*
* @var string
*/
protected $_subject = null;
protected $_subject = '';
/**
* Associative array of a user defined headers
@ -451,6 +451,25 @@ class CakeEmail {
$this->{$varName} = array_merge($this->{$varName}, $list);
}
/**
* Set Subject
*
* @param string $subject
* @return void
*/
public function setSubject($subject) {
$this->_subject = (string)$subject;
}
/**
* Get Subject
*
* @return string
*/
public function getSubject() {
return $this->_subject;
}
/**
* Sets headers for the message
*

View file

@ -102,6 +102,22 @@ class CakeEmailTest extends CakeTestCase {
$this->assertIdentical($this->CakeEmail->getTo(), $expected);
}
/**
* testSubject method
*
* @return void
*/
public function testSubject() {
$this->CakeEmail->setSubject('You have a new message.');
$this->assertIdentical($this->CakeEmail->getSubject(), 'You have a new message.');
$this->CakeEmail->setSubject(1);
$this->assertIdentical($this->CakeEmail->getSubject(), '1');
$this->CakeEmail->setSubject(array('something'));
$this->assertIdentical($this->CakeEmail->getSubject(), 'Array');
}
/**
* testHeaders method
*