Skip to content

Commit bb8f5b9

Browse files
committed
Add readme.
1 parent f8a6738 commit bb8f5b9

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

readme.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Codeception - module MailCatcher
2+
This is a Codeception module to test the emails send by your application, using MailCatcher.
3+
4+
## Installation
5+
To add it to your project run `composer require rezouce/codeception-mailcatcher`
6+
7+
You can then add *MailCatcher* to your Codeception configuration file in the modules enabled section:
8+
`
9+
modules:
10+
enabled:
11+
- MailCatcher
12+
`
13+
14+
By default the module will try to contact MailCatcher on http://127.0.0.1:1080, you can change it using the ocnfiguration:
15+
`
16+
modules:
17+
enabled:
18+
- MailCatcher
19+
config:
20+
MailCatcher:
21+
url: 'http://127.0.0.1'
22+
port: '1080'
23+
`
24+
25+
## Usage
26+
27+
### Assertions
28+
```php
29+
<?php
30+
// Check if there is at least an email
31+
$this->hasEmails();
32+
33+
// Count the number of mails
34+
$this->seeNumberEmails(5);
35+
36+
// Check if at least an email contains a string in its source
37+
$this->seeInEmails('A string.');
38+
```
39+
40+
### Grabbing emails
41+
```php
42+
<?php
43+
$emails = $this->getEmailsBySubject('subject');
44+
$emails = $this->getEmailsBySender('user@example.com');
45+
$emails = $this->getEmailsByrecipients(['user1@example.com']);
46+
```
47+
By default each of these methods will retrieve emails matching partially the given parameters.
48+
You can use pass true as the second parameter to match strictly.
49+
50+
It's also possible to assert on the emails you grab:
51+
```php
52+
<?php
53+
$emails = $this->getEmailsBySubject('subject');
54+
$this->hasEmails($emails);
55+
```
56+
57+
## License
58+
This library is open-sourced software licensed under the MIT license

0 commit comments

Comments
 (0)