Download the PHP package webcanyon/codeception-mailtrap without Composer
On this page you can find all versions of the php package webcanyon/codeception-mailtrap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webcanyon/codeception-mailtrap
More information about webcanyon/codeception-mailtrap
Files in webcanyon/codeception-mailtrap
Package codeception-mailtrap
Short Description Mailtrap module for Codeception
License MIT
Informations about the package codeception-mailtrap
Codeception Mailtrap Module
This package provides a Mailtrap module for Codeception.
Installation
You need to add the repository into your composer.json file
Setup
You can use this module as any other Codeception module, by adding 'Mailtrap' to the enabled modules in your Codeception suite configurations.
Add Mailtrap to your list of modules
Setup the configuration variables
- The
client_id
token can be found on the pagehttps://mailtrap.io/public-api
- The
inbox_id
can be found in the url when visiting the website: https://mailtrap.io/inboxes/`12345`/messages.
Update Codeception build
You're all set up!
Usage Examples
Waiting for mail to arrive
If your test depends on your application sending an email, you can instruct the test to wait for something to arrive in your configured Mailtrap inbox before proceeding. These methods all have an optional timeout that can be passed as an additional parameter.
You can also wait for emails that match certain conditions.
Confirming email contents
To confirm specific parts of your email, you can instruct the test to fetch the last email received, and run equality assertions on the email details.
The parameters available for checking are those provided by the Mailtrap API /api/v1/inboxes/inbox_id/messages action.
There are methods for checking the most common parameters of a message, which may make your test more legible. These methods will look for exact equivalency.
You can also check the last received email for partial matches. For example, looking for an occurrence of 'Great Savings' in 'Great Savings on Hamburgers'.
Checking Attachments
You can check if your has attachments, or a specific number of attachments. If you want to run further checks on the contents of the attachments you'll have to fetch the message, then interact with the Mailtrap API yourself, though.
Directly fetching emails
If you need to perform more complex tests, you can directly fetch received emails. Messages are returned as instances of Codeception\Module\MailtrapMessage
.