diff --git a/test/Storage/MessageTest.php b/test/Storage/MessageTest.php index f1f1357c..3d931bd1 100644 --- a/test/Storage/MessageTest.php +++ b/test/Storage/MessageTest.php @@ -17,6 +17,7 @@ use Zend\Mail\Storage\Message; use Zend\Mime; use Zend\Mime\Exception as MimeException; +use Zend\Mail; /** * @group Zend_Mail @@ -415,6 +416,35 @@ public function testMultivalueToHeader() $this->assertEquals('nicpoń', $addressList->get('bar@example.pl')->getName()); } + /** + * Test case for creating mail with Mail\Message containing \n\n, + * serializing it to text and loading with Storage\Message. + * + * Testcase showing that if mail is created with text body + * that is \n separated, loading such mail with Storage\Message + * causes parse error because it goes into mail body to find headers. + */ + public function testDogFood() { + $text = "Hello, bödi tekst\n\nBye"; + + $part = new Mime\Part($text); + $part->type = 'text/plain'; + $part->charset = 'UTF-8'; + + $mime = new Mime\Message(); + $mime->addPart($part); + + $message = new Mail\Message(); + $message->setEncoding('UTF-8'); + $message->setBody($text); + + $raw = $message->toString(); + $this->assertContains($text, $raw, "original text is preserved"); + + $message = new Storage\Message(['raw' => $raw]); + $this->assertNotNull($message); + } + public function filesProvider() { $filePath = __DIR__ . '/../_files/mail.txt';