From be596e782c6311e836865ac24292341479165ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Tue, 8 Sep 2026 01:20:25 +0200 Subject: [PATCH] Support Behat 4 and declare the Symfony components in use The fixture configuration moves to behat.php, the only form Behat 4 accepts and one that Behat 3 reads as well. The Symfony Config, DependencyInjection and EventDispatcher components the extension calls directly are declared instead of relied on transitively, with Symfony 8 allowed for Behat 4. CI runs Behat 4.0.0-alpha1 and a lowest-dependencies job. --- .github/workflows/CI.yml | 17 +++++++++++---- composer.json | 5 ++++- tests/Fixtures/behat.php | 35 ++++++++++++++++++++++++++++++ tests/Fixtures/behat.yml | 14 ------------ tests/Integration/BehatRunTest.php | 2 +- 5 files changed, 53 insertions(+), 20 deletions(-) create mode 100644 tests/Fixtures/behat.php delete mode 100644 tests/Fixtures/behat.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5740513..d79aaed 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,16 +22,21 @@ jobs: uses: playwright-php/.github/.github/workflows/SA.yml@main tests: - name: Tests (PHP ${{ matrix.php }}, Behat ${{ matrix.behat }}) + name: Tests (PHP ${{ matrix.php }}, Behat ${{ matrix.behat }}, ${{ matrix.dependencies }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: php: ['8.2', '8.3', '8.4'] behat: ['^3.23'] + dependencies: ['highest'] include: + - php: '8.2' + behat: '^3.23' + dependencies: 'lowest' - php: '8.4' - behat: '^3.33' + behat: '4.0.0-alpha1' + dependencies: 'highest' steps: - uses: actions/checkout@v4 @@ -53,7 +58,11 @@ jobs: - name: Install PHP deps run: | composer require "behat/behat:${{ matrix.behat }}" --no-update --no-interaction - composer update --no-interaction --prefer-dist --no-progress + if [ "${{ matrix.dependencies }}" = "lowest" ]; then + composer update --prefer-lowest --no-interaction --prefer-dist --no-progress + else + composer update --no-interaction --prefer-dist --no-progress + fi - name: Cache Playwright browsers uses: actions/cache@v4 @@ -72,6 +81,6 @@ jobs: if: failure() uses: actions/upload-artifact@v4 with: - name: screenshots-php${{ matrix.php }} + name: screenshots-php${{ matrix.php }}-behat${{ matrix.behat }}-${{ matrix.dependencies }} path: tests/Fixtures/var/screenshots/ if-no-files-found: ignore diff --git a/composer.json b/composer.json index f31f0ab..97865e0 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,10 @@ "require": { "php": "^8.2", "behat/behat": "^3.23", - "playwright-php/playwright": "^1.4" + "playwright-php/playwright": "^1.4", + "symfony/config": "^5.4 || ^6.4 || ^7.0 || ^8.0", + "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0 || ^8.0", + "symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0 || ^8.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.40", diff --git a/tests/Fixtures/behat.php b/tests/Fixtures/behat.php new file mode 100644 index 0000000..89825aa --- /dev/null +++ b/tests/Fixtures/behat.php @@ -0,0 +1,35 @@ +withProfile((new Profile('default')) + ->withExtension(new Extension(PlaywrightExtension::class, [ + 'base_url' => 'http://127.0.0.1:8971', + 'screenshot_dir' => '%paths.base%/var/screenshots', + ])) + ->withSuite((new Suite('passing')) + ->withPaths('%paths.base%/features/passing') + ->withContexts(PlaywrightContext::class)) + ->withSuite((new Suite('failing')) + ->withPaths('%paths.base%/features/failing') + ->withContexts(PlaywrightContext::class)) + ); diff --git a/tests/Fixtures/behat.yml b/tests/Fixtures/behat.yml deleted file mode 100644 index 03b99ba..0000000 --- a/tests/Fixtures/behat.yml +++ /dev/null @@ -1,14 +0,0 @@ -default: - extensions: - Playwright\Behat\ServiceContainer\PlaywrightExtension: - base_url: 'http://127.0.0.1:8971' - screenshot_dir: '%paths.base%/var/screenshots' - suites: - passing: - paths: ['%paths.base%/features/passing'] - contexts: - - Playwright\Behat\Context\PlaywrightContext - failing: - paths: ['%paths.base%/features/failing'] - contexts: - - Playwright\Behat\Context\PlaywrightContext diff --git a/tests/Integration/BehatRunTest.php b/tests/Integration/BehatRunTest.php index dd5002c..75c4cbe 100644 --- a/tests/Integration/BehatRunTest.php +++ b/tests/Integration/BehatRunTest.php @@ -63,7 +63,7 @@ private function runBehat(string $suite): Process $process = new Process([ PHP_BINARY, __DIR__.'/../../vendor/bin/behat', - '--config', __DIR__.'/../Fixtures/behat.yml', + '--config', __DIR__.'/../Fixtures/behat.php', '--suite', $suite, '--format', 'progress', '--no-colors',