Skip to content

Commit ddb8a13

Browse files
authored
Merge pull request #15 from Codeception/codecept5
Support Codeception 5
2 parents e732900 + 2221745 commit ddb8a13

4 files changed

Lines changed: 24 additions & 30 deletions

File tree

.github/workflows/main.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
php: [7.4, 8.0, 8.1]
12-
diactoros: ['diactoros:^1.8.7', 'diactoros:^2.0']
11+
php: [8.0]
1312

1413
steps:
1514
- name: Checkout code
@@ -24,30 +23,21 @@ jobs:
2423
- name: Checkout Mezzio Sample
2524
uses: actions/checkout@v2
2625
with:
27-
repository: Slamdunk/codeception-mezzio-tests
26+
repository: Naktibalda/codeception-mezzio-tests
2827
path: framework-tests
28+
ref: '5.0'
2929
submodules: recursive
3030

31-
- name: Install Mezzio Sample on PHP 7
32-
if: matrix.php < 8
31+
- name: Install Mezzio Sample
3332
run: composer update --no-dev --prefer-dist --no-interaction
3433
working-directory: framework-tests
3534

36-
- name: Install Mezzio Sample on PHP 8
37-
if: matrix.php >= 8.0
38-
run: composer update --no-dev --prefer-dist --no-interaction --ignore-platform-req=php
39-
working-directory: framework-tests
4035

4136
- name: Validate composer.json and composer.lock
4237
run: composer validate
4338

44-
- name: Install dependencies on PHP 7
45-
if: matrix.php < 8
46-
run: composer update --prefer-dist --no-progress --no-interaction --no-suggest --with='laminas/laminas-${{ matrix.diactoros }}'
47-
48-
- name: Install dependencies on PHP 8
49-
if: matrix.php >= 8
50-
run: composer update --prefer-dist --no-progress --no-interaction --ignore-platform-req=php --with='laminas/laminas-${{ matrix.diactoros }}'
39+
- name: Install dependencies
40+
run: composer update --prefer-dist --no-progress --no-interaction --no-suggest
5141

5242
- name: Run test suite
5343
run: php vendor/bin/codecept run functional -c framework-tests

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
"name": "Gintautas Miselis"
1111
}
1212
],
13-
"minimum-stability": "RC",
13+
"minimum-stability": "dev",
1414
"require": {
15-
"php": "^7.4 | ^8.0",
16-
"codeception/lib-innerbrowser": "^2.0",
17-
"codeception/codeception": "^4.1",
15+
"php": "^8.0",
16+
"codeception/lib-innerbrowser": "^3.0",
17+
"codeception/codeception": "^5.0.0-alpha2",
1818
"container-interop/container-interop": "^1.2",
19-
"laminas/laminas-diactoros": "^1.8.7 || ^2.0",
19+
"laminas/laminas-diactoros": "^2.0",
2020
"mezzio/mezzio": "^3.0"
2121
},
2222
"require-dev": {
23-
"codeception/module-rest": "^2.0"
23+
"codeception/module-rest": "^3.0"
2424
},
2525
"autoload": {
2626
"classmap": [

src/Codeception/Lib/Connector/Mezzio.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Mezzio extends Client
2626
* @param BrowserKitRequest $request
2727
* @throws Exception
2828
*/
29-
public function doRequest($request)
29+
public function doRequest($request): Response
3030
{
3131
$inputStream = fopen('php://memory', 'r+');
3232
$content = $request->getContent();
@@ -114,6 +114,9 @@ private function convertFiles(array $files): array
114114
return $fileObjects;
115115
}
116116

117+
/**
118+
* @return array<string, string>
119+
*/
117120
private function extractHeaders(BrowserKitRequest $request): array
118121
{
119122
$headers = [];
@@ -123,7 +126,7 @@ private function extractHeaders(BrowserKitRequest $request): array
123126
foreach ($server as $header => $val) {
124127
$header = html_entity_decode(implode('-', array_map('ucfirst', explode('-', strtolower(str_replace('_', '-', $header))))), ENT_NOQUOTES);
125128

126-
if (strpos($header, 'Http-') === 0) {
129+
if (str_starts_with($header, 'Http-')) {
127130
$headers[substr($header, 5)] = $val;
128131
} elseif (isset($contentHeaders[$header])) {
129132
$headers[$header] = $val;

src/Codeception/Module/Mezzio.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Codeception\Lib\Framework;
99
use Codeception\Lib\Interfaces\DoctrineProvider;
1010
use Codeception\TestInterface;
11+
use Doctrine\ORM\EntityManagerInterface;
1112
use Interop\Container\ContainerInterface;
1213
use Mezzio\Application;
1314
use PHPUnit\Framework\AssertionFailedError;
@@ -39,9 +40,9 @@
3940
class Mezzio extends Framework implements DoctrineProvider
4041
{
4142
/**
42-
* @var array
43+
* @var array<string, mixed>
4344
*/
44-
protected $config = [
45+
protected array $config = [
4546
'container' => 'config/container.php',
4647
'recreateApplicationBetweenTests' => true,
4748
'recreateApplicationBetweenRequests' => false,
@@ -62,7 +63,7 @@ class Mezzio extends Framework implements DoctrineProvider
6263
*/
6364
public Application $application;
6465

65-
public function _initialize()
66+
public function _initialize(): void
6667
{
6768
$this->client = new MezzioConnector();
6869
$this->client->setConfig($this->config);
@@ -73,7 +74,7 @@ public function _initialize()
7374
}
7475
}
7576

76-
public function _before(TestInterface $test)
77+
public function _before(TestInterface $test): void
7778
{
7879
$this->client = new MezzioConnector();
7980
$this->client->setConfig($this->config);
@@ -86,7 +87,7 @@ public function _before(TestInterface $test)
8687
}
8788
}
8889

89-
public function _after(TestInterface $test)
90+
public function _after(TestInterface $test): void
9091
{
9192
//Close the session, if any are open
9293
if (session_status() == PHP_SESSION_ACTIVE) {
@@ -99,7 +100,7 @@ public function _after(TestInterface $test)
99100
parent::_after($test);
100101
}
101102

102-
public function _getEntityManager()
103+
public function _getEntityManager(): EntityManagerInterface
103104
{
104105
$service = 'Doctrine\ORM\EntityManager';
105106
if (!$this->container->has($service)) {

0 commit comments

Comments
 (0)