https://github.com/captbaritone/mailcatcher-codeception-helper
Test emails in your Codeception acceptance tests
https://github.com/captbaritone/mailcatcher-codeception-helper
Last synced: 10 months ago
JSON representation
Test emails in your Codeception acceptance tests
- Host: GitHub
- URL: https://github.com/captbaritone/mailcatcher-codeception-helper
- Owner: captbaritone
- Created: 2014-01-23T02:25:45.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-11-15T02:02:02.000Z (about 11 years ago)
- Last Synced: 2025-01-10T23:32:11.098Z (about 1 year ago)
- Language: PHP
- Size: 184 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deprecated
I've wrapped this helper up as a module which means it can be installed using
Composer which makes more sense. Plese use the module instead:
[Codeception MailCatcher
Module](https://github.com/captbaritone/codeception-mailcatcher-module)
# Codeception MailCatcher Helper
This helper will let you test emails that are sent during your Codeception
acceptance tests. It depends upon you having
[MailCatcher](http://mailcatcher.me/) installed on your development server.
I have it installed as part of my [development virtual
machine](https://github.com/captbaritone/vagrant-lamp).
It was inspired by the Codeception blog post: [Testing Email in
PHP](http://codeception.com/12-15-2013/testing-emails-in-php). It is currently
very simple. Send a pull request or file an issue if you have ideas for more
features.
## Installation
First you need to download the helper into your `_helpers` directory:
$ cd path/to/your/tests/_helpers/
$ wget https://raw.githubusercontent.com/captbaritone/mailcatcher-codeception-helper/master/MailCatcherHelper.php
Then enable it in your `acceptance.suite.yml` configuration and set the url and
port of your site's MailCatcher installation:
class_name: WebGuy
modules:
enabled:
- MailCatcherHelper
config:
MailCatcherHelper:
url: 'http://project.dev'
port: '1080'
## Example Usage
wantTo('Get a password reset email');
// Cleared old emails from MailCatcher
$I->resetEmails();
// Reset
$I->amOnPage('forgotPassword.php');
$I->fillField("input[name='email']", 'user@example.com');
$I->click("Submit");
$I->see("Please check your email");
$I->seeInLastEmail("Please click this link to reset your password");
## Actions
### resetEmails
Clears the emails in MailCatcher's list. This is prevents seeing emails sent
during a previous test. You probably want to do this before you trigger any
emails to be sent
Example:
resetEmails();
?>
### seeInLastEmail
Checks that an email contains a value. It searches the full raw text of the
email: headers, subject line, and body.
Example:
seeInLastEmail('Thanks for signing up!');
?>
* 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:
seeInLastEmailTo('user@example.com', 'Thanks for signing up!');
$I->seeInLastEmailTo('admin@example.com', 'A new user has signed up!');
?>
* Param $email
* Param $text
# License
Released under the same liceces as Codeception: MIT