W3cubDocs

/CakePHP 3.8

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.

Namespace: Cake\TestSuite
Location: TestSuite/EmailTrait.php

Method Summary

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

cleanupEmailTrait()source public

cleanupEmailTrait( )

Resets transport state

After

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.8/class-Cake.TestSuite.EmailTrait.html