Skip to content

Commit 89b4af1

Browse files
authored
Merge pull request #156 from Codeception/3.0
Merge 3.0 to main
2 parents cb10c02 + 9e8afcc commit 89b4af1

12 files changed

+41
-42
lines changed

Diff for: .github/workflows/main.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
php: [8.0, 8.1]
12-
symfony: [4.4, 5.4]
12+
symfony: ["4.4.*", "5.4.*"]
1313

1414
steps:
1515
- name: Checkout code
@@ -24,15 +24,15 @@ jobs:
2424
coverage: none
2525

2626
- name: Checkout Symfony 4.4 Sample
27-
if: matrix.symfony == 4.4
27+
if: "matrix.symfony == '4.4.*'"
2828
uses: actions/checkout@v2
2929
with:
3030
repository: Codeception/symfony-module-tests
3131
path: framework-tests
3232
ref: 4.4_codecept5
3333

3434
- name: Checkout Symfony 5.4 Sample
35-
if: matrix.symfony == 5.4
35+
if: "matrix.symfony == '5.4.*'"
3636
uses: actions/checkout@v2
3737
with:
3838
repository: Codeception/symfony-module-tests
@@ -60,8 +60,8 @@ jobs:
6060
composer require symfony/dom-crawler=${{ matrix.symfony }} --ignore-platform-req=php --no-update
6161
composer require symfony/browser-kit=${{ matrix.symfony }} --ignore-platform-req=php --no-update
6262
composer require vlucas/phpdotenv --ignore-platform-req=php --no-update
63-
composer require codeception/module-asserts --ignore-platform-req=php --no-update
64-
composer require codeception/module-doctrine2 --ignore-platform-req=php --no-update
63+
composer require codeception/module-asserts="3.*" --ignore-platform-req=php --no-update
64+
composer require codeception/module-doctrine2="3.*" --ignore-platform-req=php --no-update
6565
composer install --prefer-dist --no-progress --ignore-platform-req=php --no-dev
6666
6767
- name: Validate composer.json and composer.lock
@@ -83,4 +83,4 @@ jobs:
8383
- name: Run test suite
8484
run: |
8585
php vendor/bin/codecept build -c framework-tests
86-
php vendor/bin/codecept run Functional -c framework-tests
86+
php vendor/bin/codecept run Functional -c framework-tests

Diff for: composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
],
1717
"minimum-stability": "dev",
1818
"require": {
19-
"php": "^7.4 | ^8.0",
19+
"php": "^8.0",
2020
"ext-json": "*",
21-
"codeception/lib-innerbrowser": "^2.0 | *@dev",
22-
"codeception/codeception": "^5.0.0-alpha1"
21+
"codeception/lib-innerbrowser": "^3.1.1",
22+
"codeception/codeception": "^5.0.0-RC1"
2323
},
2424
"require-dev": {
25-
"codeception/module-asserts": "^2.0 | *@dev",
26-
"codeception/module-doctrine2": "^2.0 | *@dev",
25+
"codeception/module-asserts": "^3.0",
26+
"codeception/module-doctrine2": "^3.0",
2727
"doctrine/orm": "^2.10",
2828
"symfony/form": "^4.4 | ^5.0",
2929
"symfony/framework-bundle": "^4.4 | ^5.0",

Diff for: readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A Codeception module for Symfony framework.
1010
## Requirements
1111

1212
* `Symfony 4.4` or higher.
13-
* `PHP 7.4` or higher.
13+
* `PHP 8.0` or higher.
1414

1515
## Installation
1616

Diff for: src/Codeception/Lib/Connector/Symfony.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
namespace Codeception\Lib\Connector;
66

77
use InvalidArgumentException;
8+
use ReflectionClass;
9+
use ReflectionMethod;
10+
use ReflectionProperty;
811
use Symfony\Bundle\FrameworkBundle\Test\TestContainer;
912
use Symfony\Component\DependencyInjection\ContainerInterface;
1013
use Symfony\Component\HttpFoundation\Request;
@@ -28,9 +31,9 @@ class Symfony extends HttpKernelBrowser
2831
/**
2932
* Constructor.
3033
*
31-
* @param Kernel $kernel A booted HttpKernel instance
32-
* @param array $services An injected services
33-
* @param bool $rebootable
34+
* @param Kernel $kernel A booted HttpKernel instance
35+
* @param array $services An injected services
36+
* @param bool $rebootable
3437
*/
3538
public function __construct(Kernel $kernel, array $services = [], bool $rebootable = true)
3639
{
@@ -133,17 +136,17 @@ private function persistDoctrineConnections(): void
133136
}
134137

135138
if ($this->container instanceof TestContainer) {
136-
$reflectedTestContainer = new \ReflectionMethod($this->container, 'getPublicContainer');
139+
$reflectedTestContainer = new ReflectionMethod($this->container, 'getPublicContainer');
137140
$reflectedTestContainer->setAccessible(true);
138141
$publicContainer = $reflectedTestContainer->invoke($this->container);
139142
} else {
140143
$publicContainer = $this->container;
141144
}
142145

143-
$reflectedContainer = new \ReflectionClass($publicContainer);
146+
$reflectedContainer = new ReflectionClass($publicContainer);
144147
$reflectionTarget = $reflectedContainer->hasProperty('parameters') ? $publicContainer : $publicContainer->getParameterBag();
145148

146-
$reflectedParameters = new \ReflectionProperty($reflectionTarget, 'parameters');
149+
$reflectedParameters = new ReflectionProperty($reflectionTarget, 'parameters');
147150
$reflectedParameters->setAccessible(true);
148151
$parameters = $reflectedParameters->getValue($reflectionTarget);
149152
unset($parameters['doctrine.connections']);

Diff for: src/Codeception/Module/Symfony.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,7 @@ class Symfony extends Framework implements DoctrineProvider, PartedModule
152152
*/
153153
public ?AbstractBrowser $client = null;
154154

155-
/**
156-
* @var array
157-
*/
158-
public $config = [
155+
public array $config = [
159156
'app_path' => 'app',
160157
'kernel_class' => 'App\Kernel',
161158
'environment' => 'test',
@@ -196,7 +193,7 @@ public function _initialize(): void
196193
$maxNestingLevel = 200; // Symfony may have very long nesting level
197194
$xdebugMaxLevelKey = 'xdebug.max_nesting_level';
198195
if (ini_get($xdebugMaxLevelKey) < $maxNestingLevel) {
199-
ini_set($xdebugMaxLevelKey, (string) $maxNestingLevel);
196+
ini_set($xdebugMaxLevelKey, (string)$maxNestingLevel);
200197
}
201198

202199
$this->kernel = new $this->kernelClass($this->config['environment'], $this->config['debug']);

Diff for: src/Codeception/Module/Symfony/ConsoleAssertionsTrait.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function runSymfonyConsoleCommand(string $command, array $parameters = []
4040
$this->assertSame(
4141
$expectedExitCode,
4242
$exitCode,
43-
'Command did not exit with code '.$expectedExitCode
44-
.' but with '.$exitCode.': '.$output
43+
'Command did not exit with code ' . $expectedExitCode
44+
. ' but with ' . $exitCode . ': ' . $output
4545
);
4646

4747
return $output;

Diff for: src/Codeception/Module/Symfony/DoctrineAssertionsTrait.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ trait DoctrineAssertionsTrait
2525
* $I->grabNumRecords('User::class', ['name' => 'davert']);
2626
* ```
2727
*
28-
* @param string $entityClass The entity class
29-
* @param array $criteria Optional query criteria
28+
* @param string $entityClass The entity class
29+
* @param array $criteria Optional query criteria
3030
* @return int
3131
*/
3232
public function grabNumRecords(string $entityClass, array $criteria = []): int
@@ -59,7 +59,7 @@ public function grabNumRecords(string $entityClass, array $criteria = []): int
5959
* @param object|string $mixed
6060
* @return \Doctrine\ORM\EntityRepository|null
6161
*/
62-
public function grabRepository($mixed)
62+
public function grabRepository($mixed): ?EntityRepository
6363
{
6464
$entityRepoClass = EntityRepository::class;
6565
$isNotARepo = function () use ($mixed): void {
@@ -86,12 +86,12 @@ public function grabRepository($mixed)
8686
return $getRepo();
8787
}
8888

89-
if (!is_string($mixed) || !class_exists($mixed) ) {
89+
if (!is_string($mixed) || !class_exists($mixed)) {
9090
$isNotARepo();
9191
return null;
9292
}
9393

94-
if (is_subclass_of($mixed, $entityRepoClass)){
94+
if (is_subclass_of($mixed, $entityRepoClass)) {
9595
return $getRepo();
9696
}
9797

Diff for: src/Codeception/Module/Symfony/EventsAssertionsTrait.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected function assertEventNotTriggered(Data $data, array $expected): void
125125
foreach ($expected as $expectedEvent) {
126126
$expectedEvent = is_object($expectedEvent) ? get_class($expectedEvent) : $expectedEvent;
127127
$this->assertFalse(
128-
$this->eventWasTriggered($actual, (string) $expectedEvent),
128+
$this->eventWasTriggered($actual, (string)$expectedEvent),
129129
"The '{$expectedEvent}' event triggered"
130130
);
131131
}
@@ -142,7 +142,7 @@ protected function assertEventTriggered(Data $data, array $expected): void
142142
foreach ($expected as $expectedEvent) {
143143
$expectedEvent = is_object($expectedEvent) ? get_class($expectedEvent) : $expectedEvent;
144144
$this->assertTrue(
145-
$this->eventWasTriggered($actual, (string) $expectedEvent),
145+
$this->eventWasTriggered($actual, (string)$expectedEvent),
146146
"The '{$expectedEvent}' event did not trigger"
147147
);
148148
}

Diff for: src/Codeception/Module/Symfony/FormAssertionsTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function dontSeeFormErrors(): void
2424
{
2525
$formCollector = $this->grabFormCollector(__FUNCTION__);
2626

27-
$errors = (int) $formCollector->getData()->offsetGet('nb_errors');
27+
$errors = (int)$formCollector->getData()->offsetGet('nb_errors');
2828

2929
$this->assertSame(
3030
0,

Diff for: src/Codeception/Module/Symfony/RouterAssertionsTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function seeInCurrentRoute(string $routeName): void
166166
$uri = explode('?', $this->grabFromCurrentUrl())[0];
167167
$matchedRouteName = '';
168168
try {
169-
$matchedRouteName = (string) $router->match($uri)['_route'];
169+
$matchedRouteName = (string)$router->match($uri)['_route'];
170170
} catch (ResourceNotFoundException $e) {
171171
$this->fail(sprintf('The "%s" url does not match with any route', $uri));
172172
}

Diff for: src/Codeception/Module/Symfony/SessionAssertionsTrait.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public function amLoggedInAs(UserInterface $user, string $firewallName = 'main',
4444
}
4545

4646
if ($firewallContext) {
47-
$session->set('_security_'.$firewallContext, serialize($token));
47+
$session->set('_security_' . $firewallContext, serialize($token));
4848
} else {
49-
$session->set('_security_'.$firewallName, serialize($token));
49+
$session->set('_security_' . $firewallName, serialize($token));
5050
}
5151

5252
$session->save();
@@ -75,8 +75,7 @@ public function dontSeeInSession(string $attribute, $value = null): void
7575
if ($session->has($attribute)) {
7676
$this->fail("Session attribute with name '{$attribute}' does exist");
7777
}
78-
}
79-
else {
78+
} else {
8079
$this->assertNotSame($value, $session->get($attribute));
8180
}
8281
}

Diff for: src/Codeception/Module/Symfony/TwigAssertionsTrait.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function dontSeeRenderedTemplate(string $template): void
2323
{
2424
$twigCollector = $this->grabTwigCollector(__FUNCTION__);
2525

26-
$templates = (array) $twigCollector->getTemplates();
26+
$templates = (array)$twigCollector->getTemplates();
2727

2828
$this->assertArrayNotHasKey(
2929
$template,
@@ -46,8 +46,8 @@ public function seeCurrentTemplateIs(string $expectedTemplate): void
4646
{
4747
$twigCollector = $this->grabTwigCollector(__FUNCTION__);
4848

49-
$templates = (array) $twigCollector->getTemplates();
50-
$actualTemplate = (string) array_key_first($templates);
49+
$templates = (array)$twigCollector->getTemplates();
50+
$actualTemplate = (string)array_key_first($templates);
5151

5252
$this->assertSame(
5353
$expectedTemplate,
@@ -72,7 +72,7 @@ public function seeRenderedTemplate(string $template): void
7272
{
7373
$twigCollector = $this->grabTwigCollector(__FUNCTION__);
7474

75-
$templates = (array) $twigCollector->getTemplates();
75+
$templates = (array)$twigCollector->getTemplates();
7676

7777
$this->assertArrayHasKey(
7878
$template,

0 commit comments

Comments
 (0)