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.
Table of Contents
Methods
- assertMailContains() : void
- Asserts an email contains expected contents
- assertMailContainsAt() : void
- Asserts an email at a specific index contains expected contents
- assertMailContainsAttachment() : void
- Asserts an email contains expected attachment
- assertMailContainsHtml() : void
- Asserts an email contains expected html contents
- assertMailContainsHtmlAt() : void
- Asserts an email at a specific index contains expected html contents
- assertMailContainsText() : void
- Asserts an email contains an expected text content
- assertMailContainsTextAt() : void
- Asserts an email at a specific index contains expected text contents
- assertMailCount() : void
- Asserts an expected number of emails were sent
- assertMailSentFrom() : void
- Asserts an email was sent from an address
- assertMailSentFromAt() : void
- Asserts an email at a specific index was sent from an address
- assertMailSentTo() : void
- Asserts an email was sent to an address
- assertMailSentToAt() : void
- Asserts an email at a specific index was sent to an address
- assertMailSentWith() : void
- Asserts an email contains the expected value within an Email getter
- assertMailSentWithAt() : void
- Asserts an email at a specific index contains the expected value within an Email getter
- assertMailSubjectContains() : void
- Asserts an email subject contains expected contents
- assertMailSubjectContainsAt() : void
- Asserts an email at a specific index contains expected html contents
- assertNoMailSent() : void
- Asserts that no emails were sent
- cleanupEmailTrait() : void
- Resets transport state
- setupTransports() : void
- Replaces all transports with the test transport during test setup
Methods
assertMailContains()
Asserts an email contains expected contents
public
assertMailContains(string $contents[, string $message = '' ]) : void
Parameters
- $contents : string
-
Contents
- $message : string = ''
-
Message
assertMailContainsAt()
Asserts an email at a specific index contains expected contents
public
assertMailContainsAt(int $at, string $contents[, string $message = '' ]) : void
Parameters
- $at : int
-
Email index
- $contents : string
-
Contents
- $message : string = ''
-
Message
assertMailContainsAttachment()
Asserts an email contains expected attachment
public
assertMailContainsAttachment(string $filename[, array<string|int, mixed> $file = [] ][, string $message = '' ]) : void
Parameters
- $filename : string
-
Filename
- $file : array<string|int, mixed> = []
-
Additional file properties
- $message : string = ''
-
Message
assertMailContainsHtml()
Asserts an email contains expected html contents
public
assertMailContainsHtml(string $contents[, string $message = '' ]) : void
Parameters
- $contents : string
-
Contents
- $message : string = ''
-
Message
assertMailContainsHtmlAt()
Asserts an email at a specific index contains expected html contents
public
assertMailContainsHtmlAt(int $at, string $contents[, string $message = '' ]) : void
Parameters
- $at : int
-
Email index
- $contents : string
-
Contents
- $message : string = ''
-
Message
assertMailContainsText()
Asserts an email contains an expected text content
public
assertMailContainsText(string $expected[, string $message = '' ]) : void
Parameters
- $expected : string
-
Expected text.
- $message : string = ''
-
Message to display if assertion fails.
assertMailContainsTextAt()
Asserts an email at a specific index contains expected text contents
public
assertMailContainsTextAt(int $at, string $contents[, string $message = '' ]) : void
Parameters
- $at : int
-
Email index
- $contents : string
-
Contents
- $message : string = ''
-
Message
assertMailCount()
Asserts an expected number of emails were sent
public
assertMailCount(int $count[, string $message = '' ]) : void
Parameters
- $count : int
-
Email count
- $message : string = ''
-
Message
assertMailSentFrom()
Asserts an email was sent from an address
public
assertMailSentFrom(array<string|int, string>|string $address[, string $message = '' ]) : void
Parameters
- $address : array<string|int, string>|string
-
Email address
- $message : string = ''
-
Message
assertMailSentFromAt()
Asserts an email at a specific index was sent from an address
public
assertMailSentFromAt(int $at, string $address[, string $message = '' ]) : void
Parameters
- $at : int
-
Email index
- $address : string
-
Email address
- $message : string = ''
-
Message
assertMailSentTo()
Asserts an email was sent to an address
public
assertMailSentTo(string $address[, string $message = '' ]) : void
Parameters
- $address : string
-
Email address
- $message : string = ''
-
Message
assertMailSentToAt()
Asserts an email at a specific index was sent to an address
public
assertMailSentToAt(int $at, string $address[, string $message = '' ]) : void
Parameters
- $at : int
-
Email index
- $address : string
-
Email address
- $message : string = ''
-
Message
assertMailSentWith()
Asserts an email contains the expected value within an Email getter
public
assertMailSentWith(string $expected, string $parameter[, string $message = '' ]) : void
Parameters
- $expected : string
-
Contents
- $parameter : string
-
Email getter parameter (e.g. "cc", "subject")
- $message : string = ''
-
Message
assertMailSentWithAt()
Asserts an email at a specific index contains the expected value within an Email getter
public
assertMailSentWithAt(int $at, string $expected, string $parameter[, string $message = '' ]) : void
Parameters
- $at : int
-
Email index
- $expected : string
-
Contents
- $parameter : string
-
Email getter parameter (e.g. "cc", "bcc")
- $message : string = ''
-
Message
assertMailSubjectContains()
Asserts an email subject contains expected contents
public
assertMailSubjectContains(string $contents[, string $message = '' ]) : void
Parameters
- $contents : string
-
Contents
- $message : string = ''
-
Message
assertMailSubjectContainsAt()
Asserts an email at a specific index contains expected html contents
public
assertMailSubjectContainsAt(int $at, string $contents[, string $message = '' ]) : void
Parameters
- $at : int
-
Email index
- $contents : string
-
Contents
- $message : string = ''
-
Message
assertNoMailSent()
Asserts that no emails were sent
public
assertNoMailSent([string $message = '' ]) : void
Parameters
- $message : string = ''
-
Message
cleanupEmailTrait()
Resets transport state
public
cleanupEmailTrait() : void
Tags
setupTransports()
Replaces all transports with the test transport during test setup
public
setupTransports() : void