Skip to content

Commit

Permalink
Add test for raw binary attachment functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
johanmeiring committed Oct 11, 2018
1 parent f05d49d commit 902b9fb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/TestCase/Mailer/Transport/MailgunTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,27 @@ public function testAttachments()
$this->assertStringEndsWith("--$boundary--", rtrim($reqDataString));
}

public function testRawBinaryAttachments()
{
$this->_setEmailConfig();
$email = new Email();
$email->setProfile(['transport' => 'mailgun']);
$res = $email->setFrom('from@example.com')
->setTo('to@example.com')
->setAttachments([
'myfile.txt' => ['data' => 'c29tZSB0ZXh0', 'mimetype' => 'text/plain'], // c29tZSB0ZXh0 = base64_encode('some text')
])
->setSubject('Email from CakePHP Mailgun plugin')
->send('Hello there, <br> This is an email from CakePHP Mailgun Email plugin.');

$reqData = $res['reqData'];
$boundary = $reqData->boundary();
$reqDataString = (string)$reqData;
$this->assertNotEmpty($reqDataString);
$this->assertStringStartsWith("--$boundary", $reqDataString);
$this->assertStringEndsWith("--$boundary--", rtrim($reqDataString));
}

public function testSetOption()
{
$this->_setEmailConfig();
Expand Down

0 comments on commit 902b9fb

Please sign in to comment.