Trait EmailAssertTrait
Email and mailer assertions.
Property Summary
-
$_email protected
Cake\Mailer\Email
Method Summary
-
any() public @method
-
assertEmailAttachmentsContains() public
Asserts the email attachments contain the given filename (and optionally file info).
-
assertEmailBcc() public
Asserts email is BCC'd to only one email address (and optionally name).
-
assertEmailBccContains() public
Asserts email BCC'd addresses contain given email address (and optionally name).
-
assertEmailCc() public
Asserts email is CC'd to only one email address (and optionally name).
-
assertEmailCcContains() public
Asserts email CC'd addresses contain given email address (and optionally name).
-
assertEmailFrom() public
Asserts email's sender email address and optionally name.
-
assertEmailHtmlMessageContains() public
Asserts HTML email content contains
$needle
. -
assertEmailMessageContains() public
Asserts email content (both text and HTML) contains
$needle
. -
assertEmailSubject() public
Asserts email's subject contains
$expected
. -
assertEmailTextMessageContains() public
Asserts text email content contains
$needle
. -
assertEmailTo() public
Asserts email is sent to only the given recipient's address (and optionally name).
-
assertEmailToContains() public
Asserts email recipients' list contains given email address (and optionally name).
-
assertSame() public @method
-
assertTextContains() public @method
-
email() public
Creates an email instance overriding its transport for testing purposes.
-
getMockBuilder() public @method
-
getMockForMailer() public
Generates mock for given mailer class.
-
send() public
Sends email using the test email instance.
Method Detail
any() ¶ public @method
any(): PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount
Returns
PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount
assertEmailAttachmentsContains() ¶ public
assertEmailAttachmentsContains(string $filename, array|null $file = null, string|null $message = null): void
Asserts the email attachments contain the given filename (and optionally file info).
Parameters
-
string
$filename Expected attachment's filename.
-
array|null
$file optional Expected attachment's file info.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailBcc() ¶ public
assertEmailBcc(string $email, string|null $name = null, string|null $message = null): void
Asserts email is BCC'd to only one email address (and optionally name).
Parameters
-
string
$email BCC'd email address.
-
string|null
$name optional BCC'd person name.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailBccContains() ¶ public
assertEmailBccContains(string $email, string|null $name = null, string|null $message = null): void
Asserts email BCC'd addresses contain given email address (and optionally name).
Parameters
-
string
$email BCC'd email address.
-
string|null
$name optional BCC'd person name.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailCc() ¶ public
assertEmailCc(string $email, string|null $name = null, string|null $message = null): void
Asserts email is CC'd to only one email address (and optionally name).
Parameters
-
string
$email CC'd email address.
-
string|null
$name optional CC'd person name.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailCcContains() ¶ public
assertEmailCcContains(string $email, string|null $name = null, string|null $message = null): void
Asserts email CC'd addresses contain given email address (and optionally name).
Parameters
-
string
$email CC'd email address.
-
string|null
$name optional CC'd person name.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailFrom() ¶ public
assertEmailFrom(string $email, string|null $name = null, string|null $message = null): void
Asserts email's sender email address and optionally name.
Parameters
-
string
$email Sender's email address.
-
string|null
$name optional Sender's name.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailHtmlMessageContains() ¶ public
assertEmailHtmlMessageContains(string $needle, string|null $message = null): void
Asserts HTML email content contains $needle
.
Parameters
-
string
$needle Text to look for.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailMessageContains() ¶ public
assertEmailMessageContains(string $needle, string|null $message = null): void
Asserts email content (both text and HTML) contains $needle
.
Parameters
-
string
$needle Text to look for.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailSubject() ¶ public
assertEmailSubject(string $expected, string|null $message = null): void
Asserts email's subject contains $expected
.
Parameters
-
string
$expected Email's subject.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailTextMessageContains() ¶ public
assertEmailTextMessageContains(string $needle, string|null $message = null): void
Asserts text email content contains $needle
.
Parameters
-
string
$needle Text to look for.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailTo() ¶ public
assertEmailTo(string $email, string|null $name = null, string|null $message = null): void
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 Recipient's name.
-
string|null
$message optional The failure message to define.
Returns
void
assertEmailToContains() ¶ public
assertEmailToContains(string $email, string|null $name = null, string|null $message = null): void
Asserts email recipients' list contains given email address (and optionally name).
Parameters
-
string
$email Recipient's email address.
-
string|null
$name optional Recipient's name.
-
string|null
$message optional The failure message to define.
Returns
void
assertSame() ¶ public @method
assertSame(mixed $expected, mixed $result, mixed $message): void
Parameters
-
$expected
-
$result
-
$message
Returns
void
assertTextContains() ¶ public @method
assertTextContains(mixed $needle, mixed $haystack, mixed $message): void
Parameters
-
$needle
-
$haystack
-
$message
Returns
void
email() ¶ public
email(bool $new = false): Cake\Mailer\Email
Creates an email instance overriding its transport for testing purposes.
Parameters
-
bool
$new optional Tells if new instance should forcibly be created.
Returns
Cake\Mailer\Email
getMockBuilder() ¶ public @method
getMockBuilder(mixed $className): PHPUnit_Framework_MockObject_MockBuilder
Parameters
-
$className
Returns
PHPUnit_Framework_MockObject_MockBuilder
getMockForMailer() ¶ public
getMockForMailer(string $className, array $methods = []): Cake\Mailer\MailerPHPUnit_Framework_MockObject_MockObject
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\MailerPHPUnit_Framework_MockObject_MockObject
send() ¶ public
send(array|string|null $content = null): void
Sends email using the test email instance.
Parameters
-
array|string|null
$content optional The email's content to send.
Returns
void