Browse files

debugtransport now also returns in correct format as stated in RFC 28…

…22 2.3, updated tests
  • Loading branch information...
1 parent 2efa3b0 commit 3be9a8a5e8f5a453f3fbb9223ba4ca5b666248ca @ceeram ceeram committed Aug 29, 2011
Showing with 7 additions and 11 deletions.
  1. +1 −1 lib/Cake/Network/Email/DebugTransport.php
  2. +6 −10 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
View
2 lib/Cake/Network/Email/DebugTransport.php
@@ -34,7 +34,7 @@ class DebugTransport extends AbstractTransport {
public function send(CakeEmail $email) {
$headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject'));
$headers = $this->_headersToString($headers);
- $message = implode("\n", (array)$email->message());
+ $message = implode("\r\n", (array)$email->message());
return array('headers' => $headers, 'message' => $message);
}
View
16 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
@@ -542,15 +542,15 @@ public function testSendWithContent() {
$result = $this->CakeEmail->send("Here is my body, with multi lines.\nThis is the second line.\r\n\r\nAnd the last.");
$expected = array('headers', 'message');
$this->assertEquals($expected, array_keys($result));
- $expected = "Here is my body, with multi lines.\nThis is the second line.\n\nAnd the last.\n\n";
+ $expected = "Here is my body, with multi lines.\r\nThis is the second line.\r\n\r\nAnd the last.\r\n\r\n";
$this->assertEquals($expected, $result['message']);
$this->assertTrue((bool)strpos($result['headers'], 'Date: '));
$this->assertTrue((bool)strpos($result['headers'], 'Message-ID: '));
$this->assertTrue((bool)strpos($result['headers'], 'To: '));
$result = $this->CakeEmail->send("Other body");
- $expected = "Other body\n\n";
+ $expected = "Other body\r\n\r\n";
$this->assertIdentical($result['message'], $expected);
$this->assertTrue((bool)strpos($result['headers'], 'Message-ID: '));
$this->assertTrue((bool)strpos($result['headers'], 'To: '));
@@ -710,11 +710,7 @@ public function testSendAttachment() {
$this->CakeEmail->config(array());
$this->CakeEmail->attachments(array(CAKE . 'basics.php'));
$result = $this->CakeEmail->send('body');
-
- $wrap = $this->CakeEmail->wrap($result['message']);
- $this->assertTrue(in_array("Content-Type: application/octet-stream", $wrap));
- $this->assertTrue(in_array("Content-Transfer-Encoding: base64", $wrap));
- $this->assertTrue(in_array("Content-Disposition: attachment; filename=\"basics.php\"", $wrap));
+ $this->assertTrue((bool)strpos($result['message'], "Content-Type: application/octet-stream\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment; filename=\"basics.php\""));
$this->CakeEmail->attachments(array('my.file.txt' => CAKE . 'basics.php'));
$result = $this->CakeEmail->send('body');
@@ -724,9 +720,9 @@ public function testSendAttachment() {
$result = $this->CakeEmail->send('body');
$this->assertTrue((bool)strpos($result['message'], "Content-Type: text/plain\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment; filename=\"file.txt\""));
- $this->CakeEmail->attachments(array('file.txt' => array('file' => CAKE . 'basics.php', 'mimetype' => 'text/plain', 'contentId' => 'a1b1c1')));
- $this->CakeEmail->send('body');
- $this->assertTrue((bool)strpos($result['message'], "Content-Type: text/plain\r\nContent-Transfer-Encoding: base64\r\nContent-ID: <a1b1c1>\r\nContent-Disposition: inline; filename=\"file.txt\""));
+ $this->CakeEmail->attachments(array('file2.txt' => array('file' => CAKE . 'basics.php', 'mimetype' => 'text/plain', 'contentId' => 'a1b1c1')));
+ $result = $this->CakeEmail->send('body');
+ $this->assertTrue((bool)strpos($result['message'], "Content-Type: text/plain\r\nContent-Transfer-Encoding: base64\r\nContent-ID: <a1b1c1>\r\nContent-Disposition: inline; filename=\"file2.txt\""));
}
/**

0 comments on commit 3be9a8a

Please sign in to comment.