Skip to content

Commit c2adb5c

Browse files
SerosTavoNiievez
andauthored
Replace kernel reboot with actual boot to reset services (#209)
* Replace kernel reboot with actual boot to reset services * Ensure congruence with the flow in the Symfony KernelTestCase * Add 6.4wApi branch to CI --------- Co-authored-by: TavoNiievez <[email protected]>
1 parent d8a8943 commit c2adb5c

File tree

2 files changed

+46
-15
lines changed

2 files changed

+46
-15
lines changed

.github/workflows/main.yml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
php: [8.2, 8.3, 8.4]
10-
symfony: ["5.4.*", "6.4.*", "7.2.*"]
11-
exclude:
12-
- php: 8.1
13-
symfony: "7.2.*"
10+
symfony: ["5.4.*", "6.4.*", "6.4wApi", "7.2.*"]
1411

1512
steps:
1613
- name: Checkout code
@@ -25,11 +22,26 @@ jobs:
2522
coverage: none
2623

2724
- name: Set Symfony version reference
28-
run: echo "SF_REF=${MATRIX_SYMFONY%.*}" >> $GITHUB_ENV
2925
env:
3026
MATRIX_SYMFONY: ${{ matrix.symfony }}
27+
run: |
28+
if [[ "$MATRIX_SYMFONY" == *'*' ]]; then
29+
echo "SF_REF=${MATRIX_SYMFONY%.*}" >> "$GITHUB_ENV"
30+
else
31+
echo "SF_REF=$MATRIX_SYMFONY" >> "$GITHUB_ENV"
32+
fi
33+
34+
- name: Set Composer Symfony constraint
35+
env:
36+
MATRIX_SYMFONY: ${{ matrix.symfony }}
37+
run: |
38+
if [[ "$MATRIX_SYMFONY" == "6.4wApi" ]]; then
39+
echo "COMP_SYMFONY=6.4.*" >> "$GITHUB_ENV"
40+
else
41+
echo "COMP_SYMFONY=$MATRIX_SYMFONY" >> "$GITHUB_ENV"
42+
fi
3143
32-
- name: Checkout Symfony ${{ env.SF_REF }} Sample
44+
- name: Checkout Symfony ${{ env.SF_REF }} sample
3345
uses: actions/checkout@v4
3446
with:
3547
repository: Codeception/symfony-module-tests
@@ -51,17 +63,24 @@ jobs:
5163
run: composer require --dev --no-update "phpunit/phpunit=^10.0"
5264

5365
- name: Install dependencies
66+
env:
67+
MATRIX_SYMFONY: ${{ matrix.symfony }}
5468
run: |
55-
composer require symfony/finder=${{ matrix.symfony }} --no-update
56-
composer require symfony/yaml=${{ matrix.symfony }} --no-update
57-
composer require symfony/console=${{ matrix.symfony }} --no-update
58-
composer require symfony/event-dispatcher=${{ matrix.symfony }} --no-update
59-
composer require symfony/css-selector=${{ matrix.symfony }} --no-update
60-
composer require symfony/dom-crawler=${{ matrix.symfony }} --no-update
61-
composer require symfony/browser-kit=${{ matrix.symfony }} --no-update
69+
composer require symfony/finder=${{ env.COMP_SYMFONY }} --no-update
70+
composer require symfony/yaml=${{ env.COMP_SYMFONY }} --no-update
71+
composer require symfony/console=${{ env.COMP_SYMFONY }} --no-update
72+
composer require symfony/event-dispatcher=${{ env.COMP_SYMFONY }} --no-update
73+
composer require symfony/css-selector=${{ env.COMP_SYMFONY }} --no-update
74+
composer require symfony/dom-crawler=${{ env.COMP_SYMFONY }} --no-update
75+
composer require symfony/browser-kit=${{ env.COMP_SYMFONY }} --no-update
6276
composer require vlucas/phpdotenv --no-update
6377
composer require codeception/module-asserts="3.*" --no-update
6478
composer require codeception/module-doctrine="3.*" --no-update
79+
80+
if [[ "$MATRIX_SYMFONY" == "6.4wApi" ]]; then
81+
composer require codeception/module-rest="3.*" --no-update
82+
fi
83+
6584
composer update --prefer-dist --no-progress --no-dev
6685
6786
- name: Validate Composer files
@@ -84,6 +103,11 @@ jobs:
84103
php bin/console doctrine:fixtures:load --quiet
85104
working-directory: framework-tests
86105

106+
- name: Generate JWT keypair
107+
if: ${{ matrix.symfony == '6.4wApi' }}
108+
run: php bin/console lexik:jwt:generate-keypair --skip-if-exists
109+
working-directory: framework-tests
110+
87111
- name: Run tests
88112
run: |
89113
php vendor/bin/codecept build -c framework-tests

src/Codeception/Lib/Connector/Symfony.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function doRequest(object $request): Response
4949
}
5050

5151
/**
52-
* Reboot kernel
52+
* Reboots the kernel.
5353
*
5454
* Services from the list of persistent services
5555
* are updated from service container before kernel shutdown
@@ -66,7 +66,8 @@ public function rebootKernel(): void
6666
}
6767

6868
$this->persistDoctrineConnections();
69-
$this->kernel->reboot(null);
69+
$this->ensureKernelShutdown();
70+
$this->kernel->boot();
7071
$this->container = $this->getContainer();
7172

7273
foreach ($this->persistentServices as $serviceName => $service) {
@@ -82,6 +83,12 @@ public function rebootKernel(): void
8283
}
8384
}
8485

86+
protected function ensureKernelShutdown(): void
87+
{
88+
$this->kernel->boot();
89+
$this->kernel->shutdown();
90+
}
91+
8592
private function getContainer(): ?ContainerInterface
8693
{
8794
/** @var ContainerInterface $container */

0 commit comments

Comments
 (0)