CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.3 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
      • Constraint
      • Fixture
      • Stub
    • Utility
    • Validation
    • View

Trait EmailAssertTrait

Email and mailer assertions.

Namespace: Cake\TestSuite

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\Mailer|PHPUnit_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\Mailer|PHPUnit_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

Property Detail

$_email ¶ protected

Type
Cake\Mailer\Email
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs