Skip to content

Commit

Permalink
Merge pull request #110 from cs278/allow-codeception-5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesking56 authored Aug 8, 2023
2 parents 295104e + 34793c6 commit f9a10ba
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
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

0 comments on commit f9a10ba

Please sign in to comment.