Trait EmailAssertTrait

Email and mailer assertions.

Properties summary

Method Summary

Method Detail

assertEmailAttachmentsContains()source public

assertEmailAttachmentsContains( string $filename , array $file null , string|null $message null )

Asserts the email attachments contain the given filename (and optionally file info).

Parameters

string $filename
Expected attachment's filename.
array $file optional null
Expected attachment's file info.
string|null $message optional null
The failure message to define.

assertEmailBcc()source public

assertEmailBcc( string $email , string|null $name null , string|null $message null )

Asserts email is BCC'd to only one email address (and optionally name).

Parameters

string $email
BCC'd email address.
string|null $name optional null
BCC'd person name.
string|null $message optional null
The failure message to define.

assertEmailBccContains()source public

assertEmailBccContains( string $email , string|null $name null , string|null $message null )

Asserts email BCC'd addresses contain given email address (and optionally name).

Parameters

string $email
BCC'd email address.
string|null $name optional null
BCC'd person name.
string|null $message optional null
The failure message to define.

assertEmailCc()source public

assertEmailCc( string $email , string|null $name null , string|null $message null )

Asserts email is CC'd to only one email address (and optionally name).

Parameters

string $email
CC'd email address.
string|null $name optional null
CC'd person name.
string|null $message optional null
The failure message to define.

assertEmailCcContains()source public

assertEmailCcContains( string $email , string|null $name null , string|null $message null )

Asserts email CC'd addresses contain given email address (and optionally name).

Parameters

string $email
CC'd email address.
string|null $name optional null
CC'd person name.
string|null $message optional null
The failure message to define.

assertEmailFrom()source public

assertEmailFrom( string $email , string|null $name null , string|null $message null )

Asserts email's sender email address and optionally name.

Parameters

string $email
Sender's email address.
string|null $name optional null
Sender's name.
string|null $message optional null
The failure message to define.

assertEmailHtmlMessageContains()source public

assertEmailHtmlMessageContains( string $needle , string|null $message null )

Asserts HTML email content contains $needle.

Parameters

string $needle
Text to look for.
string|null $message optional null
The failure message to define.

assertEmailMessageContains()source public

assertEmailMessageContains( string $needle , string|null $message null )

Asserts email content (both text and HTML) contains $needle.

Parameters

string $needle
Text to look for.
string|null $message optional null
The failure message to define.

assertEmailSubject()source public

assertEmailSubject( string $expected , string|null $message null )

Asserts email's subject contains $expected.

Parameters

string $expected
Email's subject.
string|null $message optional null
The failure message to define.

assertEmailTextMessageContains()source public

assertEmailTextMessageContains( string $needle , string|null $message null )

Asserts text email content contains $needle.

Parameters

string $needle
Text to look for.
string|null $message optional null
The failure message to define.

assertEmailTo()source public

assertEmailTo( string $email , string|null $name null , string|null $message null )

Asserts email is sent to only the given recipient's address (and optionally name).

Parameters

string $email
Recipient's email address.
string|null $name optional null
Recipient's name.
string|null $message optional null
The failure message to define.

assertEmailToContains()source public

assertEmailToContains( string $email , string|null $name null , string|null $message null )

Asserts email recipients' list contains given email address (and optionally name).

Parameters

string $email
Recipient's email address.
string|null $name optional null
Recipient's name.
string|null $message optional null
The failure message to define.

email()source public

email( boolean $new false )

Creates an email instance overriding its transport for testing purposes.

Parameters

boolean $new optional false
Tells if new instance should forcibly be created.

Returns

Cake\Mailer\Email

getMockForMailer()source public

getMockForMailer( string $className , array $methods [] )

Generates mock for given mailer class.

Parameters

string $className
The mailer's FQCN.
array $methods optional []
The methods to mock on the mailer.

Returns

Cake\Mailer\Mailer|PHPUnit_Framework_MockObject_MockObject

send()source public

send( array|string|null $content null )

Sends email using the test email instance.

Parameters

array|string|null $content optional null
The email's content to send.

Magic methods summary

any()source public

any( )

Returns

PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount

assertSame()source public

assertSame( $expected , $result , $message )

Parameters

$expected
$result
$message

assertTextContains()source public

assertTextContains( $needle , $haystack , $message )

Parameters

$needle
$haystack
$message

getMockBuilder()source public

getMockBuilder( $className )

Parameters

$className

Returns

PHPUnit_Framework_MockObject_MockBuilder

Properties detail

$_emailsource

protected Cake\Mailer\Email

© 2005–2017 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.4/class-Cake.TestSuite.EmailAssertTrait.html