Skip to content

Commit e64f46f

Browse files
authored
Symfony 6.4 Support (#177)
* Update GitHub actions * Update to PHP 8.1 * Code cleanup * testing on Symfony 6.4
1 parent 5798e3e commit e64f46f

17 files changed

+59
-138
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,12 @@ jobs:
88

99
strategy:
1010
matrix:
11-
php: [8.0, 8.1, 8.2]
12-
symfony: ["4.4.*", "5.4.*", "6.0.*", "6.1.*", "6.2.*", "6.3.*"]
13-
exclude:
14-
- php: 8.0
15-
symfony: "6.1.*"
16-
- php: 8.0
17-
symfony: "6.2.*"
18-
- php: 8.0
19-
symfony: "6.3.*"
11+
php: [8.1, 8.2, 8.3]
12+
symfony: ["5.4.*", "6.4.*"]
2013

2114
steps:
2215
- name: Checkout code
23-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
2417

2518
- name: Setup PHP
2619
uses: shivammathur/setup-php@v2
@@ -30,67 +23,35 @@ jobs:
3023
extensions: ctype, iconv, intl, json, mbstring, pdo, pdo_sqlite
3124
coverage: none
3225

33-
- name: Checkout Symfony 4.4 Sample
34-
if: "matrix.symfony == '4.4.*'"
35-
uses: actions/checkout@v2
36-
with:
37-
repository: Codeception/symfony-module-tests
38-
path: framework-tests
39-
ref: "4.4_codecept5"
40-
4126
- name: Checkout Symfony 5.4 Sample
4227
if: "matrix.symfony == '5.4.*'"
43-
uses: actions/checkout@v2
28+
uses: actions/checkout@v4
4429
with:
4530
repository: Codeception/symfony-module-tests
4631
path: framework-tests
4732
ref: "5.4_codecept5"
4833

49-
- name: Checkout Symfony 6.0 Sample
50-
if: "matrix.symfony == '6.0.*'"
51-
uses: actions/checkout@v2
34+
- name: Checkout Symfony 6.4 Sample
35+
if: "matrix.symfony == '6.4.*'"
36+
uses: actions/checkout@v4
5237
with:
5338
repository: Codeception/symfony-module-tests
5439
path: framework-tests
55-
ref: "6.0"
56-
57-
- name: Checkout Symfony 6.1 Sample
58-
if: "matrix.symfony == '6.1.*'"
59-
uses: actions/checkout@v2
60-
with:
61-
repository: Codeception/symfony-module-tests
62-
path: framework-tests
63-
ref: "6.1"
64-
65-
- name: Checkout Symfony 6.2 Sample
66-
if: "matrix.symfony == '6.2.*'"
67-
uses: actions/checkout@v2
68-
with:
69-
repository: Codeception/symfony-module-tests
70-
path: framework-tests
71-
ref: "6.2"
72-
73-
- name: Checkout Symfony 6.3 Sample
74-
if: "matrix.symfony == '6.3.*'"
75-
uses: actions/checkout@v2
76-
with:
77-
repository: Codeception/symfony-module-tests
78-
path: framework-tests
79-
ref: "6.3"
40+
ref: "6.4"
8041

8142
- name: Get composer cache directory
8243
id: composer-cache
8344
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
8445

8546
- name: Cache composer dependencies
86-
uses: actions/cache@v2.1.3
47+
uses: actions/cache@v3
8748
with:
8849
path: ${{ steps.composer-cache.outputs.dir }}
8950
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
9051
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
9152

92-
- name: Install PHPUnit 9 for Symfony 4.4, 5.4 and 6.0
93-
if: "matrix.symfony == '4.4.*' || matrix.symfony == '5.4.*' || matrix.symfony == '6.0.*'"
53+
- name: Install PHPUnit 9 for Symfony 5.4
54+
if: "matrix.symfony == '5.4.*'"
9455
run: composer require --dev --no-update "phpunit/phpunit=^9.0"
9556

9657
- name: Install dependencies
@@ -111,8 +72,8 @@ jobs:
11172
run: composer validate
11273
working-directory: framework-tests
11374

114-
- name: Install PHPUnit 10 in framework-tests for Symfony 6.1 and 6.2
115-
if: "matrix.symfony == '6.1.*' || matrix.symfony == '6.2.*' || matrix.symfony == '6.3.*'"
75+
- name: Install PHPUnit 10 in framework-tests for Symfony 6.4
76+
if: "matrix.symfony == '6.4.*'"
11677
run: composer require --dev --no-update "phpunit/phpunit=^10.0"
11778
working-directory: framework-tests
11879

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2011-2020 Michael Bodnarchuk and contributors
3+
Copyright (c) 2011-2024 Michael Bodnarchuk and contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"homepage": "https://codeception.com/",
2020
"require": {
21-
"php": "^8.0",
21+
"php": "^8.1",
2222
"ext-json": "*",
2323
"codeception/codeception": "^5.0.8",
2424
"codeception/lib-innerbrowser": "^3.1.1 | ^4.0"

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ A Codeception module for Symfony framework.
99

1010
## Requirements
1111

12-
* `Symfony` `4.4.x`, `5.4.x`, `6.x` or higher, as per the [Symfony supported versions](https://symfony.com/releases).
13-
* `PHP 8.0` or higher.
12+
* `Symfony` `5.4.x`, `6.4.x` or higher, as per the [Symfony supported versions](https://symfony.com/releases).
13+
* `PHP 8.1` or higher.
1414

1515
## Installation
1616

src/Codeception/Lib/Connector/Symfony.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,29 @@
2020

2121
class Symfony extends HttpKernelBrowser
2222
{
23-
private bool $rebootable;
24-
2523
private bool $hasPerformedRequest = false;
2624

2725
private ?ContainerInterface $container;
2826

29-
public array $persistentServices = [];
30-
3127
/**
3228
* Constructor.
3329
*
3430
* @param Kernel $kernel A booted HttpKernel instance
35-
* @param array $services An injected services
36-
* @param bool $rebootable
31+
* @param array $persistentServices An injected services
3732
*/
38-
public function __construct(Kernel $kernel, array $services = [], bool $rebootable = true)
39-
{
33+
public function __construct(
34+
Kernel $kernel,
35+
public array $persistentServices = [],
36+
private readonly bool $rebootable = true
37+
) {
4038
parent::__construct($kernel);
4139
$this->followRedirects();
42-
$this->rebootable = $rebootable;
43-
$this->persistentServices = $services;
4440
$this->container = $this->getContainer();
4541
$this->rebootKernel();
4642
}
4743

48-
/**
49-
* @param Request $request
50-
* @return Response
51-
*/
52-
protected function doRequest($request): Response
44+
/** @param Request $request */
45+
protected function doRequest(object $request): Response
5346
{
5447
if ($this->rebootable) {
5548
if ($this->hasPerformedRequest) {

src/Codeception/Module/Symfony.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
use Symfony\Component\VarDumper\Cloner\Data;
4444
use function array_keys;
4545
use function array_map;
46-
use function array_merge;
4746
use function array_search;
4847
use function array_unique;
4948
use function class_exists;
@@ -74,7 +73,7 @@
7473
*
7574
* ## Config
7675
*
77-
* ### Symfony 5.x or 4.4
76+
* ### Symfony 5.4 or higher
7877
*
7978
* * app_path: 'src' - Specify custom path to your app dir, where the kernel interface is located.
8079
* * environment: 'local' - Environment used for load kernel
@@ -83,8 +82,8 @@
8382
* * debug: true - Turn on/off debug mode
8483
* * cache_router: 'false' - Enable router caching between tests in order to [increase performance](http://lakion.com/blog/how-did-we-speed-up-sylius-behat-suite-with-blackfire)
8584
* * rebootable_client: 'true' - Reboot client's kernel before each request
86-
* * guard: 'false' - Enable custom authentication system with guard (only for 4.x and 5.x versions of the symfony)
87-
* * authenticator: 'false' - Reboot client's kernel before each request (only for 6.x versions of the symfony)
85+
* * guard: 'false' - Enable custom authentication system with guard (only for Symfony 5.4)
86+
* * authenticator: 'false' - Reboot client's kernel before each request (only for Symfony 6.0 or higher)
8887
*
8988
* #### Example (`functional.suite.yml`) - Symfony 4 Directory Structure
9089
*
@@ -126,7 +125,7 @@
126125
* browser: firefox
127126
* ```
128127
*
129-
* If you're using Symfony with Eloquent ORM (instead of Doctrine), you can load the [`ORM` part of Laravel module](https://codeception.com/docs/modules/Laravel5#Parts)
128+
* If you're using Symfony with Eloquent ORM (instead of Doctrine), you can load the [`ORM` part of Laravel module](https://codeception.com/docs/modules/Laravel#Parts)
130129
* in addition to Symfony module.
131130
*
132131
*/
@@ -215,7 +214,7 @@ public function _initialize(): void
215214
*/
216215
public function _before(TestInterface $test): void
217216
{
218-
$this->persistentServices = array_merge($this->persistentServices, $this->permanentServices);
217+
$this->persistentServices = [...$this->persistentServices, ...$this->permanentServices];
219218
$this->client = new SymfonyConnector($this->kernel, $this->persistentServices, $this->config['rebootable_client']);
220219
}
221220

@@ -322,7 +321,7 @@ protected function getKernelClass(): string
322321

323322
$this->requireAdditionalAutoloader();
324323

325-
$filesRealPath = array_map(function ($file) {
324+
$filesRealPath = array_map(static function ($file) {
326325
require_once $file;
327326
return $file->getRealPath();
328327
}, $results);
@@ -331,7 +330,7 @@ protected function getKernelClass(): string
331330

332331
if (class_exists($kernelClass)) {
333332
$reflectionClass = new ReflectionClass($kernelClass);
334-
if ($file = array_search($reflectionClass->getFileName(), $filesRealPath)) {
333+
if ($file = array_search($reflectionClass->getFileName(), $filesRealPath, true)) {
335334
return $kernelClass;
336335
}
337336

@@ -355,7 +354,7 @@ protected function getProfile(): ?Profile
355354
try {
356355
$response = $this->getClient()->getResponse();
357356
return $profiler->loadProfileFromResponse($response);
358-
} catch (BadMethodCallException $e) {
357+
} catch (BadMethodCallException) {
359358
$this->fail('You must perform a request before using this method.');
360359
} catch (Exception $e) {
361360
$this->fail($e->getMessage());

src/Codeception/Module/Symfony/BrowserAssertionsTrait.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function rebootClientKernel(): void
3131

3232
/**
3333
* Verifies that a page is available.
34-
* By default it checks the current page, specify the `$url` parameter to change it.
34+
* By default, it checks the current page, specify the `$url` parameter to change it.
3535
*
3636
* ```php
3737
* <?php
@@ -60,9 +60,6 @@ public function seePageIsAvailable(string $url = null): void
6060
* <?php
6161
* $I->seePageRedirectsTo('/admin', '/login');
6262
* ```
63-
*
64-
* @param string $page
65-
* @param string $redirectsTo
6663
*/
6764
public function seePageRedirectsTo(string $page, string $redirectsTo): void
6865
{

src/Codeception/Module/Symfony/EventsAssertionsTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait EventsAssertionsTrait
2525
*/
2626
public function dontSeeEvent(array|string $expected = null): void
2727
{
28-
$actualEvents = array_merge(array_column($this->getCalledListeners(), 'event'));
28+
$actualEvents = [...array_column($this->getCalledListeners(), 'event')];
2929
$actual = [$this->getOrphanedEvents(), $actualEvents];
3030
$this->assertEventTriggered(false, $expected, $actual);
3131
}
@@ -110,7 +110,7 @@ public function dontSeeOrphanEvent(array|string $expected = null): void
110110
*/
111111
public function seeEvent(array|string $expected): void
112112
{
113-
$actualEvents = array_merge(array_column($this->getCalledListeners(), 'event'));
113+
$actualEvents = [...array_column($this->getCalledListeners(), 'event')];
114114
$actual = [$this->getOrphanedEvents(), $actualEvents];
115115
$this->assertEventTriggered(true, $expected, $actual);
116116
}

src/Codeception/Module/Symfony/FormAssertionsTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function dontSeeFormErrors(): void
4343
* $I->seeFormErrorMessage('username', 'Username is empty');
4444
* ```
4545
*
46-
* @param string $field
4746
* @param string|null $message
4847
*/
4948
public function seeFormErrorMessage(string $field, string $message = null): void

src/Codeception/Module/Symfony/MailerAssertionsTrait.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ trait MailerAssertionsTrait
1414
/**
1515
* Checks that no email was sent.
1616
* The check is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means:
17-
* If your app performs a HTTP redirect, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first; otherwise this check will *always* pass.
18-
* Starting with version 2.0.0, `codeception/module-symfony` requires your app to use [Symfony Mailer](https://symfony.com/doc/current/mailer.html). If your app still uses [Swift Mailer](https://symfony.com/doc/current/email.html), set your version constraint to `^1.6`.
17+
* If your app performs an HTTP redirect, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first; otherwise this check will *always* pass.
1918
*/
2019
public function dontSeeEmailIsSent(): void
2120
{
@@ -25,8 +24,7 @@ public function dontSeeEmailIsSent(): void
2524
/**
2625
* Checks if the given number of emails was sent (default `$expectedCount`: 1).
2726
* The check is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means:
28-
* If your app performs a HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first.
29-
* Starting with version 2.0.0, `codeception/module-symfony` requires your app to use [Symfony Mailer](https://symfony.com/doc/current/mailer.html). If your app still uses [Swift Mailer](https://symfony.com/doc/current/email.html), set your version constraint to `^1.6`.
27+
* If your app performs an HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first.
3028
*
3129
* ```php
3230
* <?php
@@ -43,8 +41,7 @@ public function seeEmailIsSent(int $expectedCount = 1): void
4341
/**
4442
* Returns the last sent email.
4543
* The function is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means:
46-
* If your app performs a HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first.
47-
* Starting with version 2.0.0, `codeception/module-symfony` requires your app to use [Symfony Mailer](https://symfony.com/doc/current/mailer.html). If your app still uses [Swift Mailer](https://symfony.com/doc/current/email.html), set your version constraint to `^1.6`.
44+
* If your app performs an HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first.
4845
* See also: [grabSentEmails()](https://codeception.com/docs/modules/Symfony#grabSentEmails)
4946
*
5047
* ```php
@@ -66,8 +63,7 @@ public function grabLastSentEmail(): ?Email
6663
/**
6764
* Returns an array of all sent emails.
6865
* The function is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means:
69-
* If your app performs a HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first.
70-
* Starting with version 2.0.0, `codeception/module-symfony` requires your app to use [Symfony Mailer](https://symfony.com/doc/current/mailer.html). If your app still uses [Swift Mailer](https://symfony.com/doc/current/email.html), set your version constraint to `^1.6`.
66+
* If your app performs an HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first.
7167
* See also: [grabLastSentEmail()](https://codeception.com/docs/modules/Symfony#grabLastSentEmail)
7268
*
7369
* ```php
@@ -94,9 +90,6 @@ protected function getMessageMailerEvents(): MessageEvents
9490
return $messageLogger->getEvents();
9591
}
9692

97-
$this->fail("codeception/module-symfony requires Symfony Mailer https://symfony.com/doc/current/mailer.html to test emails. If your app still uses Swift Mailer, downgrade codeception/module-symfony to ^1.6
98-
99-
100-
Emails can't be tested without Symfony Mailer service.");
93+
$this->fail("Emails can't be tested without Symfony Mailer service.");
10194
}
10295
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy