Trait EmailTrait
Make assertions on emails sent through the Cake\TestSuite\TestEmailTransport
After adding the trait to your test case, all mail transports will be replaced with TestEmailTransport which is used for making assertions and will not actually send emails.
Method Summary
- assertMailContainsHtmlAt() public
Asserts an email at a specific index contains expected html contents
- assertMailContainsTextAt() public
Asserts an email at a specific index contains expected text contents
- assertMailSentWithAt() public
Asserts an email at a specific index contains the expected value within an Email getter
Method Detail
assertMailContains() public
assertMailContains(string $contents, string $message)
Asserts an email contains expected contents
Parameters
-
string
$contents Contents
-
string
$message optional Message
assertMailContainsAt() public
assertMailContainsAt(int $at, string $contents, string $message)
Asserts an email at a specific index contains expected contents
Parameters
-
int
$at Email index
-
string
$contents Contents
-
string
$message optional Message
assertMailContainsAttachment() public
assertMailContainsAttachment(string $filename, array $file, string $message)
Asserts an email contains expected attachment
Parameters
-
string
$filename Filename
-
array
$file optional Additional file properties
-
string
$message optional Message
assertMailContainsHtml() public
assertMailContainsHtml(string $contents, string $message)
Asserts an email contains expected html contents
Parameters
-
string
$contents Contents
-
string
$message optional Message
assertMailContainsHtmlAt() public
assertMailContainsHtmlAt(int $at, string $contents, string $message)
Asserts an email at a specific index contains expected html contents
Parameters
-
int
$at Email index
-
string
$contents Contents
-
string
$message optional Message
assertMailContainsText() public
assertMailContainsText(string $expected, string $message)
Asserts an email contains an expected text content
Parameters
-
string
$expected Expected text.
-
string
$message optional Message to display if assertion fails.
assertMailContainsTextAt() public
assertMailContainsTextAt(int $at, string $contents, string $message)
Asserts an email at a specific index contains expected text contents
Parameters
-
int
$at Email index
-
string
$contents Contents
-
string
$message optional Message
assertMailCount() public
assertMailCount(int $count, string $message)
Asserts an expected number of emails were sent
Parameters
-
int
$count Email count
-
string
$message optional Message
assertMailSentFrom() public
assertMailSentFrom(string $address, string $message)
Asserts an email was sent from an address
Parameters
-
string
$address Email address
-
string
$message optional Message
assertMailSentFromAt() public
assertMailSentFromAt(int $at, string $address, string $message)
Asserts an email at a specific index was sent from an address
Parameters
-
int
$at Email index
-
string
$address Email address
-
string
$message optional Message
assertMailSentTo() public
assertMailSentTo(string $address, string $message)
Asserts an email was sent to an address
Parameters
-
string
$address Email address
-
string
$message optional Message
assertMailSentToAt() public
assertMailSentToAt(int $at, string $address, string $message)
Asserts an email at a specific index was sent to an address
Parameters
-
int
$at Email index
-
string
$address Email address
-
string
$message optional Message
assertMailSentWith() public
assertMailSentWith(string $expected, string $parameter, string $message)
Asserts an email contains the expected value within an Email getter
Parameters
-
string
$expected Contents
-
string
$parameter Email getter parameter (e.g. "cc", "subject")
-
string
$message optional Message
assertMailSentWithAt() public
assertMailSentWithAt(int $at, string $expected, string $parameter, string $message)
Asserts an email at a specific index contains the expected value within an Email getter
Parameters
-
int
$at Email index
-
string
$expected Contents
-
string
$parameter Email getter parameter (e.g. "cc", "subject")
-
string
$message optional Message
assertNoMailSent() public
assertNoMailSent(string $message)
Asserts that no emails were sent
Parameters
-
string
$message optional Message
cleanupEmailTrait() public
cleanupEmailTrait()
Resets transport state
setupTransports() public
setupTransports()
Replaces all transports with the test transport during test setup
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/trait-Cake.TestSuite.EmailTrait.html