From acd1c5661c067b434d0d883127be84d1804b348d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20M=C3=BCller?= Date: Thu, 3 Apr 2025 12:01:41 +0200 Subject: [PATCH 1/3] Replace kernel reboot with actual boot to reset services --- src/Codeception/Lib/Connector/Symfony.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Codeception/Lib/Connector/Symfony.php b/src/Codeception/Lib/Connector/Symfony.php index 44d7595a..6bfce582 100644 --- a/src/Codeception/Lib/Connector/Symfony.php +++ b/src/Codeception/Lib/Connector/Symfony.php @@ -31,18 +31,16 @@ public function __construct( parent::__construct($kernel); $this->followRedirects(); $this->container = $this->getContainer(); - $this->rebootKernel(); + $this->rebootKernel(); // Ensure the profiler exists } /** @param Request $request */ protected function doRequest(object $request): Response { - if ($this->rebootable) { - if ($this->hasPerformedRequest) { - $this->rebootKernel(); - } else { - $this->hasPerformedRequest = true; - } + if ($this->hasPerformedRequest && $this->rebootable) { + $this->rebootKernel(); + } else { + $this->hasPerformedRequest = true; } return parent::doRequest($request); @@ -66,7 +64,9 @@ public function rebootKernel(): void } $this->persistDoctrineConnections(); - $this->kernel->reboot(null); + $this->kernel->boot(); + $this->kernel->shutdown(); + $this->kernel->boot(); $this->container = $this->getContainer(); foreach ($this->persistentServices as $serviceName => $service) { From afae00e23413cfdd21b0d0a38a489f2180999d4d Mon Sep 17 00:00:00 2001 From: TavoNiievez Date: Fri, 30 May 2025 02:33:02 -0500 Subject: [PATCH 2/3] Ensure congruence with the flow in the Symfony KernelTestCase --- src/Codeception/Lib/Connector/Symfony.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Codeception/Lib/Connector/Symfony.php b/src/Codeception/Lib/Connector/Symfony.php index 6bfce582..019317af 100644 --- a/src/Codeception/Lib/Connector/Symfony.php +++ b/src/Codeception/Lib/Connector/Symfony.php @@ -31,23 +31,25 @@ public function __construct( parent::__construct($kernel); $this->followRedirects(); $this->container = $this->getContainer(); - $this->rebootKernel(); // Ensure the profiler exists + $this->rebootKernel(); } /** @param Request $request */ protected function doRequest(object $request): Response { - if ($this->hasPerformedRequest && $this->rebootable) { - $this->rebootKernel(); - } else { - $this->hasPerformedRequest = true; + if ($this->rebootable) { + if ($this->hasPerformedRequest) { + $this->rebootKernel(); + } else { + $this->hasPerformedRequest = true; + } } return parent::doRequest($request); } /** - * Reboot kernel + * Reboots the kernel. * * Services from the list of persistent services * are updated from service container before kernel shutdown @@ -64,8 +66,7 @@ public function rebootKernel(): void } $this->persistDoctrineConnections(); - $this->kernel->boot(); - $this->kernel->shutdown(); + $this->ensureKernelShutdown(); $this->kernel->boot(); $this->container = $this->getContainer(); @@ -82,6 +83,12 @@ public function rebootKernel(): void } } + protected function ensureKernelShutdown(): void + { + $this->kernel->boot(); + $this->kernel->shutdown(); + } + private function getContainer(): ?ContainerInterface { /** @var ContainerInterface $container */ From 0149f51dcff8a3151328b0c5b7f318e899cc4335 Mon Sep 17 00:00:00 2001 From: TavoNiievez Date: Fri, 30 May 2025 02:40:08 -0500 Subject: [PATCH 3/3] Add 6.4wApi branch to CI # Conflicts: # .github/workflows/main.yml --- .github/workflows/main.yml | 50 ++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43762ad0..c95a2224 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,10 +7,7 @@ jobs: strategy: matrix: php: [8.2, 8.3, 8.4] - symfony: ["5.4.*", "6.4.*", "7.2.*"] - exclude: - - php: 8.1 - symfony: "7.2.*" + symfony: ["5.4.*", "6.4.*", "6.4wApi", "7.2.*"] steps: - name: Checkout code @@ -25,11 +22,26 @@ jobs: coverage: none - name: Set Symfony version reference - run: echo "SF_REF=${MATRIX_SYMFONY%.*}" >> $GITHUB_ENV env: MATRIX_SYMFONY: ${{ matrix.symfony }} + run: | + if [[ "$MATRIX_SYMFONY" == *'*' ]]; then + echo "SF_REF=${MATRIX_SYMFONY%.*}" >> "$GITHUB_ENV" + else + echo "SF_REF=$MATRIX_SYMFONY" >> "$GITHUB_ENV" + fi + + - name: Set Composer Symfony constraint + env: + MATRIX_SYMFONY: ${{ matrix.symfony }} + run: | + if [[ "$MATRIX_SYMFONY" == "6.4wApi" ]]; then + echo "COMP_SYMFONY=6.4.*" >> "$GITHUB_ENV" + else + echo "COMP_SYMFONY=$MATRIX_SYMFONY" >> "$GITHUB_ENV" + fi - - name: Checkout Symfony ${{ env.SF_REF }} Sample + - name: Checkout Symfony ${{ env.SF_REF }} sample uses: actions/checkout@v4 with: repository: Codeception/symfony-module-tests @@ -51,17 +63,24 @@ jobs: run: composer require --dev --no-update "phpunit/phpunit=^10.0" - name: Install dependencies + env: + MATRIX_SYMFONY: ${{ matrix.symfony }} run: | - composer require symfony/finder=${{ matrix.symfony }} --no-update - composer require symfony/yaml=${{ matrix.symfony }} --no-update - composer require symfony/console=${{ matrix.symfony }} --no-update - composer require symfony/event-dispatcher=${{ matrix.symfony }} --no-update - composer require symfony/css-selector=${{ matrix.symfony }} --no-update - composer require symfony/dom-crawler=${{ matrix.symfony }} --no-update - composer require symfony/browser-kit=${{ matrix.symfony }} --no-update + composer require symfony/finder=${{ env.COMP_SYMFONY }} --no-update + composer require symfony/yaml=${{ env.COMP_SYMFONY }} --no-update + composer require symfony/console=${{ env.COMP_SYMFONY }} --no-update + composer require symfony/event-dispatcher=${{ env.COMP_SYMFONY }} --no-update + composer require symfony/css-selector=${{ env.COMP_SYMFONY }} --no-update + composer require symfony/dom-crawler=${{ env.COMP_SYMFONY }} --no-update + composer require symfony/browser-kit=${{ env.COMP_SYMFONY }} --no-update composer require vlucas/phpdotenv --no-update composer require codeception/module-asserts="3.*" --no-update composer require codeception/module-doctrine="3.*" --no-update + + if [[ "$MATRIX_SYMFONY" == "6.4wApi" ]]; then + composer require codeception/module-rest="3.*" --no-update + fi + composer update --prefer-dist --no-progress --no-dev - name: Validate Composer files @@ -84,6 +103,11 @@ jobs: php bin/console doctrine:fixtures:load --quiet working-directory: framework-tests + - name: Generate JWT keypair + if: ${{ matrix.symfony == '6.4wApi' }} + run: php bin/console lexik:jwt:generate-keypair --skip-if-exists + working-directory: framework-tests + - name: Run tests run: | php vendor/bin/codecept build -c framework-tests