Download the PHP package captbaritone/mailcatcher-codeception-module without Composer
On this page you can find all versions of the php package captbaritone/mailcatcher-codeception-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download captbaritone/mailcatcher-codeception-module
More information about captbaritone/mailcatcher-codeception-module
Files in captbaritone/mailcatcher-codeception-module
Package mailcatcher-codeception-module
Short Description Test emails in your Codeception acceptance tests
License MIT
Informations about the package mailcatcher-codeception-module
Codeception MailCatcher Module
This module will let you test emails that are sent during your Codeception acceptance tests. It depends upon you having MailCatcher installed on your development server.
It was inspired by the Codeception blog post: Testing Email in PHP. It is currently very simple. Send a pull request or file an issue if you have ideas for more features.
Installation
-
Add the package to your
composer.json
:composer require --dev captbaritone/mailcatcher-codeception-module
-
Configure your project to actually send emails through
smtp://127.0.0.1:1025
in the test environment - Enable the module in your
acceptance.suite.yml
:
Optional Configuration
If you need to specify some special options (e.g. SSL verification or authentication headers), you can set all of the allowed Guzzle request options:
class_name: WebGuy
modules:
enabled:
- MailCatcher
config:
MailCatcher:
url: 'http://127.0.0.1'
port: '1080'
guzzleRequestOptions:
verify: false
debug: true
version: 1.0
Example Usage
Actions
resetEmails
Clears the emails in MailCatcher's list. This prevents seeing emails sent during a previous test. You probably want to do this before you trigger any emails to be sent
Example:
seeEmailAttachmentCount
Checks expected count of attachments in last email.
Example:
- Param $expectCount
seeAttachmentInLastEmail
Checks that last email contains an attachment with filename.
Example:
- Param $filename
seeInLastEmail
Checks that an email contains a value. It searches the full raw text of the email: headers, subject line, and body.
Example:
- Param $text
seeInLastEmailTo
Checks that the last email sent to an address contains a value. It searches the full raw text of the email: headers, subject line, and body.
This is useful if, for example a page triggers both an email to the new user, and to the administrator.
Example:
- Param $email
- Param $text
dontSeeInLastEmail
Checks that an email does NOT contain a value. It searches the full raw text of the email: headers, subject line, and body.
Example:
- Param $text
dontSeeInLastEmailTo
Checks that the last email sent to an address does NOT contain a value. It searches the full raw text of the email: headers, subject line, and body.
Example:
- Param $email
- Param $text
grabAttachmentsFromLastEmail
Grab Attachments From Email
Returns array with the format [ [filename1 => bytes1], [filename2 => bytes2], ...]
Example:
grabMatchesFromLastEmail
Extracts an array of matches and sub-matches from the last email based on
a regular expression. It searches the full raw text of the email: headers,
subject line, and body. The return value is an array like that returned by
preg_match()
.
Example:
- Param $regex
grabFromLastEmail
Extracts a string from the last email based on a regular expression. It searches the full raw text of the email: headers, subject line, and body.
Example:
- Param $regex
grabUrlsFromLastEmail
Extracts an array of urls from the last email. It searches the full raw body of the email. The return value is an array of strings.
Example:
lastMessageFrom
Grab the full email object sent to an address.
Example:
lastMessage
Grab the full email object from the last email.
Example:
grabMatchesFromLastEmailTo
Extracts an array of matches and sub-matches from the last email to a given
address based on a regular expression. It searches the full raw text of the
email: headers, subject line, and body. The return value is an array like that
returned by preg_match()
.
Example:
- Param $email
- Param $regex
grabFromLastEmailTo
Extracts a string from the last email to a given address based on a regular expression. It searches the full raw text of the email: headers, subject line, and body.
Example:
- Param $email
- Param $regex
seeEmailCount
Asserts that a certain number of emails have been sent since the last time
resetEmails()
was called.
Example:
- Param $count
License
Released under the same license as Codeception: MIT
All versions of mailcatcher-codeception-module with dependencies
ext-json Version *
guzzlehttp/guzzle Version ^6.0 || ^7.0
codeception/codeception Version ^4.0 || ^5.0
zbateson/mail-mime-parser Version ^1.2