Skip to content

Commit f825e91

Browse files
authored
Merge pull request #22 from Codeception/codecept5
Support Codeception 5
2 parents 3c8ae13 + 10c3171 commit f825e91

File tree

4 files changed

+33
-42
lines changed

4 files changed

+33
-42
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
2525
strategy:
2626
matrix:
27-
php: [7.4, 8.0]
27+
php: [8.0]
2828

2929
steps:
3030
- name: Checkout code
@@ -43,32 +43,21 @@ jobs:
4343
- name: Validate composer.json and composer.lock
4444
run: composer validate
4545

46-
- name: Install dependencies on PHP7
47-
if: matrix.php < 8
48-
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
49-
50-
- name: Install dependencies on PHP8
51-
if: matrix.php == 8.0
52-
run: composer install --prefer-dist --no-progress --no-interaction --ignore-platform-reqs
46+
- name: Install dependencies
47+
run: composer install --prefer-dist --no-progress --no-interaction
5348

5449
- name: Checkout Laminas tests
5550
uses: actions/checkout@v2
5651
with:
5752
repository: Naktibalda/codeception-laminas-tests
5853
path: framework-tests
59-
ref: 'master'
54+
ref: '5.0'
6055
submodules: recursive
6156

62-
- name: Install dependencies of Laminas tests on PHP 7
63-
if: matrix.php < 8
57+
- name: Install dependencies of Laminas tests
6458
run: composer update --no-dev --prefer-dist --no-interaction
6559
working-directory: framework-tests
6660

67-
- name: Install dependencies of Laminas tests on PHP 8
68-
if: matrix.php == 8.0
69-
run: composer update --no-dev --prefer-dist --no-interaction --ignore-platform-reqs
70-
working-directory: framework-tests
71-
7261
- name: Create database schema
7362
run: php vendor/bin/doctrine-module orm:schema-tool:create
7463
working-directory: framework-tests

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
"name": "Michael Bodnarchuk"
1414
}
1515
],
16-
"minimum-stability": "RC",
16+
"minimum-stability": "dev",
1717
"require": {
18-
"php": "^7.4 | ^8.0",
19-
"codeception/lib-innerbrowser": "^2.0",
20-
"codeception/codeception": "^4.1",
18+
"php": "^8.0",
19+
"codeception/lib-innerbrowser": "^3.0",
20+
"codeception/codeception": "^5.0.0-alpha2",
2121
"laminas/laminas-db": "^2.11.3",
2222
"laminas/laminas-mvc": "^3.1.1"
2323
},
2424
"require-dev": {
25-
"codeception/module-asserts": "^2.0",
26-
"codeception/module-doctrine2": "^2.0",
27-
"codeception/module-rest": "^2.0"
25+
"codeception/module-asserts": "^3.0",
26+
"codeception/module-doctrine2": "^3.0",
27+
"codeception/module-rest": "^3.0"
2828
},
2929
"autoload": {
3030
"classmap": [

src/Codeception/Lib/Connector/Laminas.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
use function explode;
2222
use function html_entity_decode;
2323
use function implode;
24-
use function is_null;
2524
use function parse_str;
2625
use function str_replace;
27-
use function strpos;
2826
use function strtolower;
2927
use function strtoupper;
3028
use function substr;
@@ -57,6 +55,9 @@ public function doRequest($request): Response
5755
$this->createApplication();
5856

5957
$laminasRequest = $this->application->getRequest();
58+
if (!$laminasRequest instanceof LaminasRequest) {
59+
throw new \InvalidArgumentException('Expected to get instance of ' . LaminasRequest::class);
60+
}
6061
$uri = new HttpUri($request->getUri());
6162
$queryString = $uri->getQuery();
6263
$method = strtoupper($request->getMethod());
@@ -72,12 +73,12 @@ public function doRequest($request): Response
7273
$post = $request->getParameters();
7374
}
7475

75-
$laminasRequest->setCookies(new Parameters($request->getCookies()));
76+
$laminasRequest->setCookies($request->getCookies());
7677
$laminasRequest->setServer(new Parameters($request->getServer()));
7778
$laminasRequest->setQuery(new Parameters($query));
7879
$laminasRequest->setPost(new Parameters($post));
7980
$laminasRequest->setFiles(new Parameters($request->getFiles()));
80-
$laminasRequest->setContent(is_null($content) ? '' : $content);
81+
$laminasRequest->setContent($content ?? '');
8182
$laminasRequest->setMethod($method);
8283
$laminasRequest->setUri($uri);
8384

@@ -116,7 +117,7 @@ public function getLaminasRequest(): LaminasRequest
116117
return $this->laminasRequest;
117118
}
118119

119-
public function grabServiceFromContainer(string $service)
120+
public function grabServiceFromContainer(string $service): object
120121
{
121122
$serviceManager = $this->application->getServiceManager();
122123

@@ -133,10 +134,7 @@ public function persistService(string $name): void
133134
$this->persistentServices[$name] = $service;
134135
}
135136

136-
/**
137-
* @param array|object $service
138-
*/
139-
public function addServiceToContainer(string $name, $service): void
137+
public function addServiceToContainer(string $name, array|object $service): void
140138
{
141139
$this->application->getServiceManager()->setAllowOverride(true);
142140
$this->application->getServiceManager()->setService($name, $service);
@@ -175,7 +173,7 @@ private function extractHeaders(BrowserKitRequest $browserKitRequest): Headers
175173
ENT_NOQUOTES
176174
);
177175

178-
if (strpos($header, 'Http-') === 0) {
176+
if (str_starts_with($header, 'Http-')) {
179177
$headers[substr($header, 5)] = $val;
180178
} elseif (isset($contentHeaders[$header])) {
181179
$headers[$header] = $val;

src/Codeception/Module/Laminas.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Codeception\Lib\Interfaces\PartedModule;
1212
use Codeception\TestInterface;
1313
use Codeception\Util\ReflectionHelper;
14+
use Doctrine\ORM\EntityManagerInterface;
1415
use Exception;
1516
use Laminas\Console\Console;
1617
use Laminas\Db\Adapter\AdapterInterface;
@@ -72,8 +73,8 @@ class Laminas extends Framework implements DoctrineProvider, PartedModule
7273
/** @var LaminasConnector */
7374
public ?AbstractBrowser $client = null;
7475

75-
/** @var string[] */
76-
protected $config = [
76+
/** @var array<string, mixed> */
77+
protected array $config = [
7778
'config' => 'tests/application.config.php',
7879
'em_service' => 'Doctrine\ORM\EntityManager',
7980
];
@@ -85,11 +86,11 @@ class Laminas extends Framework implements DoctrineProvider, PartedModule
8586
protected int $time = 0;
8687

8788
/**
88-
* Used to collect domains while recursively traversing route tree
89+
* @var string[] Used to collect domains while recursively traversing route tree
8990
*/
9091
private array $domainCollector = [];
9192

92-
public function _initialize()
93+
public function _initialize(): void
9394
{
9495
$initAutoloaderFile = Configuration::projectDir() . 'init_autoloader.php';
9596
if (file_exists($initAutoloaderFile)) {
@@ -110,14 +111,14 @@ public function _initialize()
110111
$this->client->setApplicationConfig($this->applicationConfig);
111112
}
112113

113-
public function _before(TestInterface $test)
114+
public function _before(TestInterface $test): void
114115
{
115116
$this->client = new LaminasConnector();
116117
$this->client->setApplicationConfig($this->applicationConfig);
117118
$_SERVER['REQUEST_URI'] = '';
118119
}
119120

120-
public function _after(TestInterface $test)
121+
public function _after(TestInterface $test): void
121122
{
122123
$_SESSION = [];
123124
$_GET = [];
@@ -130,17 +131,20 @@ public function _after(TestInterface $test)
130131
parent::_after($test);
131132
}
132133

133-
public function _parts()
134+
/**
135+
* @return string[]
136+
*/
137+
public function _parts(): array
134138
{
135139
return ['services'];
136140
}
137141

138-
public function _afterSuite()
142+
public function _afterSuite(): void
139143
{
140144
unset($this->client);
141145
}
142146

143-
public function _getEntityManager()
147+
public function _getEntityManager(): EntityManagerInterface
144148
{
145149
if (!$this->client) {
146150
$this->fail('Laminas module is not loaded');

0 commit comments

Comments
 (0)