CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.7 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.7
      • 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

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • ConsoleIntegrationTestCase
  • IntegrationTestCase
  • LegacyCommandRunner
  • LegacyShellDispatcher
  • TestCase
  • TestEmailTransport
  • TestSuite

Traits

  • ConsoleIntegrationTestTrait
  • EmailAssertTrait
  • EmailTrait
  • IntegrationTestTrait
  • StringCompareTrait

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

  • assertMailContains() public
    Asserts an email contains expected contents
  • assertMailContainsAt() public
    Asserts an email at a specific index contains expected contents
  • assertMailContainsHtml() public
    Asserts an email contains expected html contents
  • assertMailContainsHtmlAt() public
    Asserts an email at a specific index contains expected html contents
  • assertMailContainsText() public
    Asserts an email contains an expected text content
  • assertMailContainsTextAt() public
    Asserts an email at a specific index contains expected text contents
  • assertMailCount() public
    Asserts an expected number of emails were sent
  • assertMailSentFrom() public
    Asserts an email was sent from an address
  • assertMailSentFromAt() public
    Asserts an email at a specific index was sent from an address
  • assertMailSentTo() public
    Asserts an email was sent to an address
  • assertMailSentToAt() public
    Asserts an email at a specific index was sent to an address
  • assertMailSentWith() public
    Asserts an email contains the expected value within an Email getter
  • assertMailSentWithAt() public
    Asserts an email at a specific index contains the expected value within an Email getter
  • assertNoMailSent() public
  • cleanupEmailTrait() public
    Resets transport state
  • setupTransports() public
    Replaces all transports with the test transport during test setup

Method Detail

assertMailContains() public ¶

assertMailContains( string $contents , string $message null )

Asserts an email contains expected contents

Parameters
string $contents
Contents
string $message optional null
Message

assertMailContainsAt() 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() public ¶

assertMailContainsHtml( string $contents , string $message null )

Asserts an email contains expected html contents

Parameters
string $contents
Contents
string $message optional null
Message

assertMailContainsHtmlAt() 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() 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() 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() 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() 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() 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() 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() 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() 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() 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() public ¶

assertNoMailSent( string $message null )

Asserts that no emails were sent

Parameters
string $message optional null
Message

cleanupEmailTrait() public ¶

cleanupEmailTrait( )

Resets transport state

After

setupTransports() public ¶

setupTransports( )

Replaces all transports with the test transport during test setup

Before
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs