kibao / behat-mailcatcher-extension
MailCatcher extension for Behat
Installs: 59 856
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 0
Open Issues: 3
Type:behat-extension
Requires
- php: >=5.3.3
- behat/behat: ~3.0
- kibao/mailcatcher: 0.2.*@dev
Requires (Dev)
- phpspec/phpspec: ~2.0
- swiftmailer/swiftmailer: ~5.0
This package is not auto-updated.
Last update: 2024-04-13 13:42:46 UTC
README
MailCatcher is a super simple SMTP server which catches any message sent to it.
MailCatcherExtension provides:
Kibao\Behat\MailCatcherExtension\Context\MailCatcherAwareContext
, which provides MailCatcherClient
instance for your context.MailCatcherContext
context which provides base step definitions for your contexts.
Installation
This extension requires:
- Behat 3.0+
Through Composer
-
Add MailCatcherExtension to your composer.json:
{ "require-dev": { ... "kibao/mailcatcher": "*@dev", "kibao/behat-mailcatcher-extension": "0.2.*@dev" } }
-
Install or update vendors:
$ composer update kibao/mailcatcher kibao/behat-mailcatcher-extension
-
Activate extension in your
behat.yml
:default: # ... extensions: Kibao\Behat\MailCatcherExtension\Extension: ~
Configuration
Default configuration:
default: # ... extensions: Kibao\Behat\MailCatcherExtension\Extension: client: url: http://localhost # MailCatcher http url port: 1080 # MailCatcher http port purge_before_scenario: true mailcatcher_client: kibao.mailcatcher.client.default # client service mailcatcher_connection: kibao.mailcatcher.connection.guzzle # connection service
Usage
First of all you need to have installed MailCatcher.
There are few options:
-
Extending
RawMailCatcherContext
in your feature suite. It provides you preconfigured MailCatcher with basic methods.RawMailCatcherContext
doesn't provide any step definitions, so you can extend it in many contexts. -
Extending
MailCatcherContext
with one of your contexts. It provides you same things asRawMailCatcherContext
and also predefined steps out of the box. -
Adding
MailCatcherContext
as context in your suite.default: suites: my_suite: contexts: - FeatureContext - Kibao\Behat\MailCatcherExtension\Context\MailCatcherContext
-
Implementing
MailCatcherAwareContext
with your context. Target context must implementsetMailCatcher(ClientInterface $mailcatcher)
. This method would be automatically called immediately after each context creation before each scenario.$mailcatcher
will be preconfigured client based on your settings.