Add behat-version matrix dimension, fix Behat 4 type errors, unify config

CI matrix now has a behat-version dimension (stable / 4.x-dev) so both
Behat 3.31 and Behat 4 are tested explicitly. Symfony 8.x rows always
use Behat 4; Symfony 7.4 rows test both versions.

behat.dist.php works with Behat 3.31 too (Behat\Config\Config exists as
a bridge since 3.31), so drop behat.yml.dist and always use the PHP
config — removes the if/else branch from CI and unifies local dev too.

SessionsListener: fix type hint on prepareDefaultMinkSession from
ScenarioLikeTested to ScenarioTested — the method uses getSuite() which
is on LifecycleEvent (not ScenarioLikeTested), and the dispatched events
are ScenarioTested subclasses. Also remove now-unused ScenarioLikeTested
import.

ServiceContainer/MinkExtension: add missing return types (: string,
: void) to all interface method overrides to satisfy Behat 4's stricter
interface signatures.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kamil Kokot
2026-06-12 17:15:15 +02:00
parent e7f7e3508a
commit a1355134df
5 changed files with 22 additions and 30 deletions

View File

@@ -11,7 +11,7 @@ on:
jobs: jobs:
test: test:
name: PHP ${{ matrix.php-version }} + Symfony ${{ matrix.symfony-version }} name: PHP ${{ matrix.php-version }} + Symfony ${{ matrix.symfony-version }} + Behat ${{ matrix.behat-version }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
continue-on-error: false continue-on-error: false
strategy: strategy:
@@ -25,11 +25,20 @@ jobs:
- '7.4.*' - '7.4.*'
- '8.0.*' - '8.0.*'
- '8.1.*' - '8.1.*'
behat-version:
- stable
- 4.x-dev
exclude: exclude:
# Symfony 8.x requires PHP >= 8.4
- php-version: '8.3' - php-version: '8.3'
symfony-version: '8.0.*' symfony-version: '8.0.*'
- php-version: '8.3' - php-version: '8.3'
symfony-version: '8.1.*' symfony-version: '8.1.*'
# Behat 3.31 (stable) cannot install with Symfony 8.x
- behat-version: stable
symfony-version: '8.0.*'
- behat-version: stable
symfony-version: '8.1.*'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -48,8 +57,8 @@ jobs:
- name: Lock Symfony version - name: Lock Symfony version
run: VERSION=${{ matrix.symfony-version }} .github/workflows/lock-symfony-version.sh run: VERSION=${{ matrix.symfony-version }} .github/workflows/lock-symfony-version.sh
- name: Require behat 4.x for Symfony 8+ - name: Require behat 4.x
if: startsWith(matrix.symfony-version, '8.') if: matrix.behat-version == '4.x-dev'
run: | run: |
VERSION="4.x-dev as 3.31.0" .github/workflows/lock-behat-version.sh VERSION="4.x-dev as 3.31.0" .github/workflows/lock-behat-version.sh
composer config minimum-stability dev composer config minimum-stability dev
@@ -62,9 +71,4 @@ jobs:
run: vendor/bin/phpspec run -f pretty run: vendor/bin/phpspec run -f pretty
- name: Behat - name: Behat
run: | run: vendor/bin/behat --config behat.dist.php -fprogress --strict
if [[ "${{ matrix.symfony-version }}" == 8.* ]]; then
vendor/bin/behat --config behat.dist.php -fprogress --strict
else
vendor/bin/behat -fprogress --strict
fi

View File

@@ -1,11 +0,0 @@
default:
suites:
default:
path: "%paths.base%/features"
contexts: [Behat\MinkExtension\Context\MinkContext]
extensions:
Behat\MinkExtension\ServiceContainer\MinkExtension:
base_url: http://en.wikipedia.org/
sessions:
default:
browserkit_http: ~

View File

@@ -48,7 +48,7 @@
"scripts": { "scripts": {
"test": [ "test": [
"vendor/bin/phpspec run -f pretty", "vendor/bin/phpspec run -f pretty",
"vendor/bin/behat -fprogress --strict" "vendor/bin/behat --config behat.dist.php -fprogress --strict"
] ]
} }
} }

View File

@@ -11,7 +11,6 @@
namespace Behat\MinkExtension\Listener; namespace Behat\MinkExtension\Listener;
use Behat\Behat\EventDispatcher\Event\ExampleTested; use Behat\Behat\EventDispatcher\Event\ExampleTested;
use Behat\Behat\EventDispatcher\Event\ScenarioLikeTested;
use Behat\Behat\EventDispatcher\Event\ScenarioTested; use Behat\Behat\EventDispatcher\Event\ScenarioTested;
use Behat\Mink\Mink; use Behat\Mink\Mink;
use Behat\Testwork\EventDispatcher\Event\ExerciseCompleted; use Behat\Testwork\EventDispatcher\Event\ExerciseCompleted;
@@ -79,11 +78,11 @@ class SessionsListener implements EventSubscriberInterface
* `@insulated` tag will cause Mink to stop current sessions before scenario * `@insulated` tag will cause Mink to stop current sessions before scenario
* instead of just soft-resetting them * instead of just soft-resetting them
* *
* @param ScenarioLikeTested $event * @param ScenarioTested $event
* *
* @throws ProcessingException when the @javascript tag is used without a javascript session * @throws ProcessingException when the @javascript tag is used without a javascript session
*/ */
public function prepareDefaultMinkSession(ScenarioLikeTested $event) public function prepareDefaultMinkSession(ScenarioTested $event)
{ {
$scenario = $event->getScenario(); $scenario = $event->getScenario();
$feature = $event->getFeature(); $feature = $event->getFeature();

View File

@@ -68,7 +68,7 @@ class MinkExtension implements ExtensionInterface
$this->registerDriverFactory(new WebdriverClassicFactory()); $this->registerDriverFactory(new WebdriverClassicFactory());
} }
public function registerDriverFactory(DriverFactory $driverFactory) public function registerDriverFactory(DriverFactory $driverFactory): void
{ {
$this->driverFactories[$driverFactory->getDriverName()] = $driverFactory; $this->driverFactories[$driverFactory->getDriverName()] = $driverFactory;
} }
@@ -76,7 +76,7 @@ class MinkExtension implements ExtensionInterface
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function load(ContainerBuilder $container, array $config) public function load(ContainerBuilder $container, array $config): void
{ {
if (isset($config['mink_loader'])) { if (isset($config['mink_loader'])) {
$basePath = $container->getParameter('paths.base'); $basePath = $container->getParameter('paths.base');
@@ -108,7 +108,7 @@ class MinkExtension implements ExtensionInterface
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function configure(ArrayNodeDefinition $builder) public function configure(ArrayNodeDefinition $builder): void
{ {
// Rewrite keys to define a shortcut way without allowing conflicts with real keys // Rewrite keys to define a shortcut way without allowing conflicts with real keys
$renamedKeys = array_diff( $renamedKeys = array_diff(
@@ -177,7 +177,7 @@ class MinkExtension implements ExtensionInterface
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getConfigKey() public function getConfigKey(): string
{ {
return 'mink'; return 'mink';
} }
@@ -185,14 +185,14 @@ class MinkExtension implements ExtensionInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function initialize(ExtensionManager $extensionManager) public function initialize(ExtensionManager $extensionManager): void
{ {
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function process(ContainerBuilder $container) public function process(ContainerBuilder $container): void
{ {
$this->processSelectors($container); $this->processSelectors($container);
} }