Skip to content

Commit 2e26967

Browse files
author
MailCare
authored
Minimal version
2 parents b629378 + f25fb0a commit 2e26967

File tree

13 files changed

+4038
-3
lines changed

13 files changed

+4038
-3
lines changed

.github/workflows/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
tests:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
matrix:
11+
php: [7.2, 7.3, 7.4]
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v1
16+
17+
- name: Setup PHP
18+
uses: shivammathur/setup-php@v1
19+
with:
20+
php-version: ${{ matrix.php }}
21+
extensions: mbstring
22+
coverage: none
23+
24+
- name: Validate composer.json and composer.lock
25+
run: composer validate
26+
27+
- name: Install dependencies
28+
run: composer install --prefer-dist --no-progress --no-suggest
29+
30+
- name: Run test suite
31+
run: |
32+
composer test-server
33+
composer test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
.php_cs.cache

README.md

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,57 @@ Module for testing receiving emails using [MailCare](https://mailcare.io).
1414

1515
### Configuration
1616

17-
* url *required* - API url of your mailcare server
17+
* url *optional* - API url of your mailcare server (default: https://mailix.xyz/api)
18+
* login *optional* - login of your mailcare server
19+
* password *optional* - password of your mailcare server
20+
* timeoutInSeconds *optional* - Waits up to n seconds for an email to be received (default: 30 seconds)
1821

1922
#### Example
2023
```
2124
modules:
2225
enabled
2326
- MailCare:
2427
url: 'https://mailix.xyz/api'
28+
login: 'https://mailix.xyz/api'
29+
password: 'https://mailix.xyz/api'
2530
```
2631

32+
### Criterias
33+
34+
* `inbox` Filter by inbox (test@example.com).
35+
* `sender` Filter by sender (test@example.com).
36+
* `subject` Filter by subject (Welcome).
37+
* `since` Filter by createdAt (2018-01-19T12:23:27+00:00 or ISO 8601 durations).
38+
* `search` Search by inbox or sender or subject (matching).
39+
* `unread` Filter only by unread (true).
40+
* `favorite` Filter only by favorite (true).
41+
42+
All criterias can be found in the [API Documentation of MailCare](https://mailcare.docs.apiary.io) except for page and limit.
43+
44+
Examples of `since` with ISO 8601 durations:
45+
* P1D: one-day duration
46+
* PT1M: one-minute duration (note the time designator, T, that precedes the time value)
47+
2748
### Actions
2849

50+
#### seeEmailCount
51+
52+
Checks that the email count equals expected value.
53+
Waits up to $timeout seconds for the given email to be received.
54+
55+
```php
56+
$I->seeEmailCount(2, [
57+
'inbox' => 'john@example.org',
58+
'sender' => 'no-reply@company.com',
59+
'subject' => 'Welcome John!',
60+
'since' => 'PT2M',
61+
], 30);
62+
```
63+
64+
* `param int` $expectedCount
65+
* `param array` $criterias
66+
* `param int` $timeoutInSeconds (optional)
67+
2968
#### seeEmail
3069

3170
Checks that the given email exists.
@@ -36,10 +75,58 @@ $I->seeEmail([
3675
'inbox' => 'john@example.org',
3776
'sender' => 'no-reply@company.com',
3877
'subject' => 'Welcome John!',
39-
'since' => 'P2M',
78+
'since' => 'PT2M',
4079
], 30);
4180
```
4281

4382
* `param array` $criterias
44-
* 'param int` $timeout (seconds)
83+
* `param int` $timeoutInSeconds (optional)
4584

85+
#### dontSeeEmail
86+
87+
Opposite to seeEmail.
88+
89+
```php
90+
$I->dontSeeEmail([
91+
'inbox' => 'john@example.org',
92+
'since' => 'PT2M',
93+
], 30);
94+
```
95+
96+
* `param array` $criterias
97+
* `param int` $timeoutInSeconds (optional)
98+
99+
#### grabLinksInLastEmail
100+
101+
In the last email, grabs all the links
102+
Waits up to $timeout seconds for the given email to be received.
103+
104+
```php
105+
$I->grabLinksInLastEmail([
106+
'inbox' => 'john@example.org',
107+
'since' => 'PT2M',
108+
], 30);
109+
```
110+
111+
* `param array` $criterias
112+
* `param int` $timeoutInSeconds (optional)
113+
* `return array` ['https://google.fr', 'https://mailcare.io']
114+
115+
116+
#### grabTextInLastEmail
117+
118+
In the last email, grabs all the text corresponding to a regex.
119+
Waits up to $timeout seconds for the given email to be received.
120+
121+
```php
122+
$I->grabTextInLastEmail('#Password: (?<password>\S+)#', [
123+
'inbox' => 'john@example.org',
124+
'subject' => 'Your credentials',
125+
'since' => 'PT2M',
126+
], 30);
127+
```
128+
129+
* `param string` $regex
130+
* `param array` $criterias
131+
* `param int` $timeoutInSeconds (optional)
132+
* `return array` matches from preg_match_all

composer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "mailcare/codeception-module-mailcare",
3+
"description": "MailCare module for Codeception",
4+
"keywords":["codeception", "codeception-module", "mailcare", "testing", "mail"],
5+
"homepage":"https://codeception.mailcare.io/",
6+
"type": "library",
7+
"license": "MIT",
8+
"minimum-stability": "stable",
9+
"authors": [
10+
{
11+
"name": "Vincent Dauce"
12+
}
13+
],
14+
"require": {
15+
"php": "^7.2",
16+
"codeception/codeception": "^4.0"
17+
},
18+
"require-dev": {
19+
"friendsofphp/php-cs-fixer": "^2.16",
20+
"codeception/util-universalframework": "^1.0",
21+
"phpunit/phpunit": "^8.0"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"Codeception\\Module\\": "src/Codeception/Module/"
26+
}
27+
},
28+
"scripts": {
29+
"format": [
30+
"./vendor/bin/php-cs-fixer fix ."
31+
],
32+
"test-server": [
33+
"nohup bash -c 'php -S localhost:8000 -t tests/test-server > /dev/null 2>&1 &'"
34+
],
35+
"test": [
36+
"vendor/bin/phpunit tests"
37+
]
38+
}
39+
}

0 commit comments

Comments
 (0)