Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Codeception 5 #110

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ jobs:
strategy:
matrix:
php: ['7.4', '8.0', '8.1']
codeception: ['^4.0', '^5.0']
exclude:
# Codeception 5 requires PHP ≥ 8
- php: '7.4'
codeception: '^5.0'

steps:
- uses: actions/checkout@v3
Expand All @@ -39,6 +44,7 @@ jobs:
- uses: ramsey/composer-install@v2
with:
dependency-versions: highest
composer-options: "--with=codeception/codeception:${{ matrix.codeception }}"
- run: php vendor/bin/codecept build
- name: Acceptance tests
run: php vendor/bin/codecept run acceptance -d
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"php": "^7.4 || ^8.0",
"ext-json": "*",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"codeception/codeception": "^3.0 || ^4.0",
"codeception/codeception": "^4.0 || ^5.0",
"zbateson/mail-mime-parser": "^1.2"
},
"autoload": {
Expand All @@ -25,7 +25,7 @@
}
},
"require-dev": {
"codeception/module-asserts": "^1.1",
"codeception/module-asserts": "^1.1 || ^2",
"phpmailer/phpmailer": "^6.1.6"
},
"suggest": {
Expand Down
54 changes: 40 additions & 14 deletions src/Module/MailCatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,54 @@

namespace Codeception\Module;

use Codeception\Codecept;
use Codeception\Module;
use Codeception\Util\Email;
use GuzzleHttp\Client;
use ZBateson\MailMimeParser\Message;

class MailCatcher extends Module
{
/**
* @var Client
*/
protected $mailcatcher;
if (substr(Codecept::VERSION, 0, 1) === '4') {
class MailCatcher extends Module
{
/**
* @var array
*/
protected $config = ['url', 'port', 'guzzleRequestOptions'];

/**
* @var Client
*/
protected $mailcatcher;

/**
* @var array
*/
protected $requiredFields = ['url', 'port'];

use MailCatcherImplementation;
}
} else {
class MailCatcher extends Module
{
/**
* @var array
*/
protected array $config = ['url', 'port', 'guzzleRequestOptions'];

/**
* @var array
*/
protected $config = ['url', 'port', 'guzzleRequestOptions'];
protected Client $mailcatcher;

/**
* @var array
*/
protected $requiredFields = ['url', 'port'];
protected array $requiredFields = ['url', 'port'];

use MailCatcherImplementation;
}
}

/**
* @internal The methods as exposed by the MailCatcher class are public but do
* not depend on the existence of this trait.
*/
trait MailCatcherImplementation
{
public function _initialize(): void
{
$base_uri = trim($this->config['url'], '/') . ':' . $this->config['port'];
Expand Down