Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test for inline attachments.

  • Loading branch information...
commit f366a9ff834b96f3b971568916b40b06e1f8cc16 1 parent 0e4af54
@markstory markstory authored
Showing with 55 additions and 0 deletions.
  1. +55 −0 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
View
55 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
@@ -821,6 +821,61 @@ public function testSendNoTemplateWithAttachmentsAsBoth() {
}
/**
+ * Test setting inline attachments and messages.
+ *
+ * @return void
+ */
+ public function testSendWithInlineAttachments() {
+ $this->CakeEmail->transport('debug');
+ $this->CakeEmail->from('cake@cakephp.org');
+ $this->CakeEmail->to('cake@cakephp.org');
+ $this->CakeEmail->subject('My title');
+ $this->CakeEmail->emailFormat('both');
+ $this->CakeEmail->attachments(array(
+ 'cake.png' => array(
+ 'file' => CAKE . 'VERSION.txt',
+ 'contentId' => 'abc123'
+ )
+ ));
+ $result = $this->CakeEmail->send('Hello');
+
+ $boundary = $this->CakeEmail->getBoundary();
+ $this->assertContains('Content-Type: multipart/mixed; boundary="' . $boundary . '"', $result['headers']);
+ $expected = "--$boundary\r\n" .
+ "Content-Type: multipart/related; boundary=\"rel-$boundary\"\r\n" .
+ "\r\n" .
+ "--rel-$boundary\r\n" .
+ "Content-Type: multipart/alternative; boundary=\"alt-$boundary\"\r\n" .
+ "\r\n" .
+ "--alt-$boundary\r\n" .
+ "Content-Type: text/plain; charset=UTF-8\r\n" .
+ "Content-Transfer-Encoding: 8bit\r\n" .
+ "\r\n" .
+ "Hello" .
+ "\r\n" .
+ "\r\n" .
+ "\r\n" .
+ "--alt-$boundary\r\n" .
+ "Content-Type: text/html; charset=UTF-8\r\n" .
+ "Content-Transfer-Encoding: 8bit\r\n" .
+ "\r\n" .
+ "Hello" .
+ "\r\n" .
+ "\r\n" .
+ "\r\n" .
+ "--alt-{$boundary}--\r\n" .
+ "\r\n" .
+ "--$boundary\r\n" .
+ "Content-Type: application/octet-stream\r\n" .
+ "Content-Transfer-Encoding: base64\r\n" .
+ "Content-ID: <abc123>\r\n" .
+ "Content-Disposition: inline; filename=\"cake.png\"\r\n\r\n";
+ $this->assertContains($expected, $result['message']);
+ $this->assertContains('--rel-' . $boundary . '--', $result['message']);
+ $this->assertContains('--' . $boundary . '--', $result['message']);
+}
+
+/**
* testSendWithLog method
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.