Download the PHP package tpayne/behat-mail-extension without Composer
On this page you can find all versions of the php package tpayne/behat-mail-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tpayne/behat-mail-extension
More information about tpayne/behat-mail-extension
Files in tpayne/behat-mail-extension
Package behat-mail-extension
Short Description An extension for testing emails with Behat
License MIT
Informations about the package behat-mail-extension
Behat Mail Extension
Requirements
- PHP 5.5 or newer
Supported Drivers
Installation
Require tpayne/behat-mail-extension
using composer
or add it manually to the require-dev section of your composer.json
file.
Configure your context
Setup your feature context to use the Behat Mail Extension
1) Implement the MailAwareContext in your feature context.
2) Use the Mail trait in your context.
Using the mail trait will add a mail property to your feature context.
behat.yml
Chose one of the following configurations for your behat.yml
file.
Defaults
If no drivers are specified the following defaults will be used:
driver
: mailcatcherbase_uri
: localhosthttp_port
: 1080
MailCatcher
Add the MailExtension to your behat.yml
file:
Mailtrap.io
Add the MailExtension to your behat.yaml
file:
Usage
The Behat Mail Extension will automatically clear messages from the inbox when runing scenarios tagged with @mail
Access the mail property from your feature context to test any emails sent.
The Mail Driver API
The mail driver, accessible via the mail property on the feature context, offers the following methods:
getMessages()
getLatestMessage()
deleteMessages()
(This is called automatically after scenarios tagged@mail
)
The Message API
The mail driver will return a message object with the following API:
to()
from()
subject()
plainText()
html()
date()