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 -
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
-
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 = null )
Asserts an email contains expected contents
Parameters
- string $contents
- Contents
- string $message optional null
- Message
assertMailContainsAt() public ¶
assertMailContainsAt( integer $at , string $contents , string $message = null )
Asserts an email at a specific index contains expected contents
Parameters
- integer $at
- Email index
- string $contents
- Contents
- string $message optional null
- Message
assertMailContainsHtml() public ¶
assertMailContainsHtml( string $contents , string $message = null )
Asserts an email contains expected html contents
Parameters
- string $contents
- Contents
- string $message optional null
- Message
assertMailContainsHtmlAt() public ¶
assertMailContainsHtmlAt( integer $at , string $contents , string $message = null )
Asserts an email at a specific index contains expected html contents
Parameters
- integer $at
- Email index
- string $contents
- Contents
- string $message optional null
- Message
assertMailContainsText() public ¶
assertMailContainsText( string $expectedText , string $message = null )
Asserts an email contains an expected text content
Parameters
- string $expectedText
- Expected text.
- string $message optional null
- Message to display if assertion fails.
assertMailContainsTextAt() public ¶
assertMailContainsTextAt( integer $at , string $contents , string $message = null )
Asserts an email at a specific index contains expected text contents
Parameters
- integer $at
- Email index
- string $contents
- Contents
- string $message optional null
- Message
assertMailCount() public ¶
assertMailCount( integer $count , string $message = null )
Asserts an expected number of emails were sent
Parameters
- integer $count
- Email count
- string $message optional null
- Message
assertMailSentFrom() public ¶
assertMailSentFrom( string $address , string $message = null )
Asserts an email was sent from an address
Parameters
- string $address
- Email address
- string $message optional null
- Message
assertMailSentFromAt() public ¶
assertMailSentFromAt( integer $at , string $address , string $message = null )
Asserts an email at a specific index was sent from an address
Parameters
- integer $at
- Email index
- string $address
- Email address
- string $message optional null
- Message
assertMailSentTo() public ¶
assertMailSentTo( string $address , string $message = null )
Asserts an email was sent to an address
Parameters
- string $address
- Email address
- string $message optional null
- Message
assertMailSentToAt() public ¶
assertMailSentToAt( integer $at , string $address , string $message = null )
Asserts an email at a specific index was sent to an address
Parameters
- integer $at
- Email index
- string $address
- Email address
- string $message optional null
- Message
assertMailSentWith() public ¶
assertMailSentWith( string $expected , string $parameter , string $message = null )
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 null
- Message
assertMailSentWithAt() public ¶
assertMailSentWithAt( integer $at , string $expected , string $parameter , string $message = null )
Asserts an email at a specific index contains the expected value within an Email getter
Parameters
- integer $at
- Email index
- string $expected
- Contents
- string $parameter
- Email getter parameter (e.g. "cc", "subject")
- string $message optional null
- Message
assertNoMailSent() public ¶
assertNoMailSent( string $message = null )
Asserts that no emails were sent
Parameters
- string $message optional null
- Message
setupTransports() public ¶
setupTransports( )
Replaces all transports with the test transport during test setup