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
-
assertMailContains() public
Asserts an email contains expected contents
-
assertMailContainsAt() public
Asserts an email at a specific index contains expected contents
-
assertMailContainsAttachment() public
Asserts an email contains expected attachment
-
assertMailContainsHtml() public
Asserts an email contains expected html contents
-
assertMailContainsHtmlAt() public
Asserts an email at a specific index contains expected html contents
-
assertMailContainsText() public
Asserts an email contains an expected text content
-
assertMailContainsTextAt() public
Asserts an email at a specific index contains expected text contents
-
assertMailCount() public
Asserts an expected number of emails were sent
-
assertMailSentFrom() public
Asserts an email was sent from an address
-
assertMailSentFromAt() public
Asserts an email at a specific index was sent from an address
-
assertMailSentTo() public
Asserts an email was sent to an address
-
assertMailSentToAt() public
Asserts an email at a specific index was sent to an address
-
assertMailSentWith() public
Asserts an email contains the expected value within an Email getter
-
assertMailSentWithAt() public
Asserts an email at a specific index contains the expected value within an Email getter
-
assertNoMailSent() public
Asserts that no emails were sent
-
cleanupEmailTrait() public
Resets transport state
-
setupTransports() public
Replaces all transports with the test transport during test setup
Method Detail
assertMailContains() ¶ public
assertMailContains(string $contents, string $message = ''): void
Asserts an email contains expected contents
Parameters
-
string$contents Contents
-
string$message optional Message
Returns
voidassertMailContainsAt() ¶ public
assertMailContainsAt(int $at, string $contents, string $message = ''): void
Asserts an email at a specific index contains expected contents
Parameters
-
int$at Email index
-
string$contents Contents
-
string$message optional Message
Returns
voidassertMailContainsAttachment() ¶ public
assertMailContainsAttachment(string $filename, array $file = [], string $message = ''): void
Asserts an email contains expected attachment
Parameters
-
string$filename Filename
-
array$file optional Additional file properties
-
string$message optional Message
Returns
voidassertMailContainsHtml() ¶ public
assertMailContainsHtml(string $contents, string $message = ''): void
Asserts an email contains expected html contents
Parameters
-
string$contents Contents
-
string$message optional Message
Returns
voidassertMailContainsHtmlAt() ¶ public
assertMailContainsHtmlAt(int $at, string $contents, string $message = ''): void
Asserts an email at a specific index contains expected html contents
Parameters
-
int$at Email index
-
string$contents Contents
-
string$message optional Message
Returns
voidassertMailContainsText() ¶ public
assertMailContainsText(string $expected, string $message = ''): void
Asserts an email contains an expected text content
Parameters
-
string$expected Expected text.
-
string$message optional Message to display if assertion fails.
Returns
voidassertMailContainsTextAt() ¶ public
assertMailContainsTextAt(int $at, string $contents, string $message = ''): void
Asserts an email at a specific index contains expected text contents
Parameters
-
int$at Email index
-
string$contents Contents
-
string$message optional Message
Returns
voidassertMailCount() ¶ public
assertMailCount(int $count, string $message = ''): void
Asserts an expected number of emails were sent
Parameters
-
int$count Email count
-
string$message optional Message
Returns
voidassertMailSentFrom() ¶ public
assertMailSentFrom(string $address, string $message = ''): void
Asserts an email was sent from an address
Parameters
-
string$address Email address
-
string$message optional Message
Returns
voidassertMailSentFromAt() ¶ public
assertMailSentFromAt(int $at, string $address, string $message = ''): void
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
Returns
voidassertMailSentTo() ¶ public
assertMailSentTo(string $address, string $message = ''): void
Asserts an email was sent to an address
Parameters
-
string$address Email address
-
string$message optional Message
Returns
voidassertMailSentToAt() ¶ public
assertMailSentToAt(int $at, string $address, string $message = ''): void
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
Returns
voidassertMailSentWith() ¶ public
assertMailSentWith(string $expected, string $parameter, string $message = ''): void
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
Returns
voidassertMailSentWithAt() ¶ public
assertMailSentWithAt(int $at, string $expected, string $parameter, string $message = ''): void
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
Returns
voidassertNoMailSent() ¶ public
assertNoMailSent(string $message = ''): void
Asserts that no emails were sent
Parameters
-
string$message optional Message
Returns
voidsetupTransports() ¶ public
setupTransports(): void
Replaces all transports with the test transport during test setup
Returns
void