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() publicAsserts an email contains expected contents
- assertMailContainsAt() publicAsserts an email at a specific index contains expected contents
- assertMailContainsHtml() publicAsserts an email contains expected html contents
- assertMailContainsHtmlAt() publicAsserts an email at a specific index contains expected html contents
- assertMailContainsText() publicAsserts an email contains an expected text content
- assertMailContainsTextAt() publicAsserts an email at a specific index contains expected text contents
- assertMailCount() publicAsserts an expected number of emails were sent
- assertMailSentFrom() publicAsserts an email was sent from an address
- assertMailSentFromAt() publicAsserts an email at a specific index was sent from an address
- assertMailSentTo() publicAsserts an email was sent to an address
- assertMailSentToAt() publicAsserts an email at a specific index was sent to an address
- assertMailSentWith() publicAsserts an email contains the expected value within an Email getter
- assertMailSentWithAt() publicAsserts an email at a specific index contains the expected value within an Email getter
- assertNoMailSent() public
- cleanupEmailTrait() publicResets transport state
- setupTransports() publicReplaces all transports with the test transport during test setup
Method Detail
assertMailContains()source public
assertMailContains( string $contents , string $message = null )
Asserts an email contains expected contents
Parameters
- string
$contents
- Contents
- string
$message
optional null - Message
assertMailContainsAt()source 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()source public
assertMailContainsHtml( string $contents , string $message = null )
Asserts an email contains expected html contents
Parameters
- string
$contents
- Contents
- string
$message
optional null - Message
assertMailContainsHtmlAt()source 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()source 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()source 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()source 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()source 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()source 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()source 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()source 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()source 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()source 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()source public
assertNoMailSent( string $message = null )
Asserts that no emails were sent
Parameters
- string
$message
optional null - Message
setupTransports()source public
setupTransports( )
Replaces all transports with the test transport during test setup
Before
© 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/3.7/class-Cake.TestSuite.EmailTrait.html