Merge pull request #7179 from cakephp/issue-7176

Fix fatal error on null subject.
This commit is contained in:
José Lorenzo Rodríguez 2015-08-06 09:35:58 +02:00
commit 2fe2f6eb5a
2 changed files with 28 additions and 1 deletions

View file

@ -309,7 +309,8 @@ class EmailComponent extends Component {
$lib->readReceipt($this->_formatAddresses((array)$this->readReceipt));
}
$lib->subject($this->subject)->messageID($this->messageId);
$lib->subject($this->subject);
$lib->messageID($this->messageId);
$lib->helpers($this->_controller->helpers);
$headers = array('X-Mailer' => $this->xMailer);

View file

@ -339,6 +339,32 @@ HTMLBLOC;
$this->assertRegExp('/http\:\/\/example\.com/', $result);
}
/**
* test send with null properties
*
* @return void
*/
public function testSendNullProperties() {
$this->Controller->EmailTest->to = 'test@example.com';
$this->Controller->EmailTest->from = 'test@example.com';
$this->Controller->EmailTest->subject = null;
$this->Controller->EmailTest->replyTo = null;
$this->Controller->EmailTest->messageId = null;
$this->Controller->EmailTest->template = null;
$this->Controller->EmailTest->delivery = 'DebugComp';
$this->assertTrue($this->Controller->EmailTest->send(null));
$result = DebugCompTransport::$lastEmail;
$this->assertRegExp('/To: test@example.com\n/', $result);
$this->assertRegExp('/Subject: \n/', $result);
$this->assertRegExp('/From: test@example.com\n/', $result);
$this->assertRegExp('/Date: ' . preg_quote(static::$sentDate) . '\n/', $result);
$this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result);
$this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
$this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result);
}
/**
* testSendDebug method
*