Skip to content

Commit

Permalink
Methods to set/get subject.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Apr 13, 2011
1 parent 187304c commit 82835a3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/Cake/Network/CakeEmail.php
Expand Up @@ -97,7 +97,7 @@ class CakeEmail {
*
* @var string
*/
protected $_subject = null;
protected $_subject = '';

/**
* Associative array of a user defined headers
Expand Down Expand Up @@ -451,6 +451,25 @@ protected function _addEmail($varName, $email, $name) {
$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
*
Expand Down
16 changes: 16 additions & 0 deletions lib/Cake/tests/Case/Network/CakeEmailTest.php
Expand Up @@ -102,6 +102,22 @@ public function testTo() {
$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
*
Expand Down

0 comments on commit 82835a3

Please sign in to comment.