Skip to content

Commit

Permalink
Minimal version
Browse files Browse the repository at this point in the history
  • Loading branch information
MailCare authored Dec 31, 2019
2 parents b629378 + f25fb0a commit 2e26967
Show file tree
Hide file tree
Showing 13 changed files with 4,038 additions and 3 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on: [push]

jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
php: [7.2, 7.3, 7.4]

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php }}
extensions: mbstring
coverage: none

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run test suite
run: |
composer test-server
composer test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor/
.php_cs.cache
93 changes: 90 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,57 @@ Module for testing receiving emails using [MailCare](https://mailcare.io).

### Configuration

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

#### Example
```
modules:
enabled
- MailCare:
url: 'https://mailix.xyz/api'
login: 'https://mailix.xyz/api'
password: 'https://mailix.xyz/api'
```

### Criterias

* `inbox` Filter by inbox (test@example.com).
* `sender` Filter by sender (test@example.com).
* `subject` Filter by subject (Welcome).
* `since` Filter by createdAt (2018-01-19T12:23:27+00:00 or ISO 8601 durations).
* `search` Search by inbox or sender or subject (matching).
* `unread` Filter only by unread (true).
* `favorite` Filter only by favorite (true).

All criterias can be found in the [API Documentation of MailCare](https://mailcare.docs.apiary.io) except for page and limit.

Examples of `since` with ISO 8601 durations:
* P1D: one-day duration
* PT1M: one-minute duration (note the time designator, T, that precedes the time value)

### Actions

#### seeEmailCount

Checks that the email count equals expected value.
Waits up to $timeout seconds for the given email to be received.

```php
$I->seeEmailCount(2, [
'inbox' => 'john@example.org',
'sender' => 'no-reply@company.com',
'subject' => 'Welcome John!',
'since' => 'PT2M',
], 30);
```

* `param int` $expectedCount
* `param array` $criterias
* `param int` $timeoutInSeconds (optional)

#### seeEmail

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

* `param array` $criterias
* 'param int` $timeout (seconds)
* `param int` $timeoutInSeconds (optional)

#### dontSeeEmail

Opposite to seeEmail.

```php
$I->dontSeeEmail([
'inbox' => 'john@example.org',
'since' => 'PT2M',
], 30);
```

* `param array` $criterias
* `param int` $timeoutInSeconds (optional)

#### grabLinksInLastEmail

In the last email, grabs all the links
Waits up to $timeout seconds for the given email to be received.

```php
$I->grabLinksInLastEmail([
'inbox' => 'john@example.org',
'since' => 'PT2M',
], 30);
```

* `param array` $criterias
* `param int` $timeoutInSeconds (optional)
* `return array` ['https://google.fr', 'https://mailcare.io']


#### grabTextInLastEmail

In the last email, grabs all the text corresponding to a regex.
Waits up to $timeout seconds for the given email to be received.

```php
$I->grabTextInLastEmail('#Password: (?<password>\S+)#', [
'inbox' => 'john@example.org',
'subject' => 'Your credentials',
'since' => 'PT2M',
], 30);
```

* `param string` $regex
* `param array` $criterias
* `param int` $timeoutInSeconds (optional)
* `return array` matches from preg_match_all
39 changes: 39 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "mailcare/codeception-module-mailcare",
"description": "MailCare module for Codeception",
"keywords":["codeception", "codeception-module", "mailcare", "testing", "mail"],
"homepage":"https://codeception.mailcare.io/",
"type": "library",
"license": "MIT",
"minimum-stability": "stable",
"authors": [
{
"name": "Vincent Dauce"
}
],
"require": {
"php": "^7.2",
"codeception/codeception": "^4.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"codeception/util-universalframework": "^1.0",
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
"Codeception\\Module\\": "src/Codeception/Module/"
}
},
"scripts": {
"format": [
"./vendor/bin/php-cs-fixer fix ."
],
"test-server": [
"nohup bash -c 'php -S localhost:8000 -t tests/test-server > /dev/null 2>&1 &'"
],
"test": [
"vendor/bin/phpunit tests"
]
}
}
Loading

0 comments on commit 2e26967

Please sign in to comment.