Skip to content

Commit

Permalink
Adding tests for #32
Browse files Browse the repository at this point in the history
Also fixing headers not being forwarded via API.

Signed-off-by: Chris Hallgren <[email protected]>
  • Loading branch information
challgren committed Dec 23, 2019
1 parent 8436832 commit 62d1439
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/composer.lock
/phpunit.xml
/vendor
/.idea
/.phpunit.result.cache
/coverage
2 changes: 2 additions & 0 deletions src/Mailer/Transport/MailgunTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ protected function _processHeaders(Email $email)
}
} elseif (0 === strpos($header, $this->_customHeaderPrefix) && !empty($value)) {
$this->_formData->add($header, $value);
} else {
$this->_formData->add($this->_customHeaderPrefix . $header, $value);
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/TestCase/Mailer/Transport/MailgunTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public function testAdditionalEmailAddresses()
->addCC(['[email protected]', '[email protected]' => 'John'])
->addBcc(['[email protected]', '[email protected]' => 'John'])
->setEmailFormat('both')
->addHeaders([
'h:Reply-To' => '[email protected]',
'Sent-From' => '[email protected]',
])
->setSubject('Email from CakePHP Mailgun plugin')
->send('Hello there, <br> This is an email from CakePHP Mailgun Email plugin.');

Expand All @@ -106,12 +110,16 @@ public function testAdditionalEmailAddresses()
$this->assertTextContains('Content-Disposition: form-data; name="to"', $reqDataString);
$this->assertTextContains('Content-Disposition: form-data; name="cc"', $reqDataString);
$this->assertTextContains('Content-Disposition: form-data; name="bcc"', $reqDataString);
$this->assertTextContains('Content-Disposition: form-data; name="h:Reply-To"', $reqDataString);
$this->assertTextContains('Content-Disposition: form-data; name="h:Sent-From"', $reqDataString);
$this->assertTextContains('[email protected] <[email protected]>', $reqDataString);
$this->assertTextContains('[email protected] <[email protected]>', $reqDataString);
$this->assertTextContains('[email protected] <[email protected]>', $reqDataString);
$this->assertTextContains('John <[email protected]>', $reqDataString);
$this->assertTextContains('[email protected] <[email protected]>', $reqDataString);
$this->assertTextContains('John <[email protected]>', $reqDataString);
$this->assertTextContains('[email protected]', $reqDataString);
$this->assertTextContains('[email protected]', $reqDataString);
}

public function testAttachments()
Expand Down

0 comments on commit 62d1439

Please sign in to comment.