- Add friendsofphp/php-cs-fixer ^3.75 and phpstan/phpstan ^2.0 to require-dev; add .php-cs-fixer.dist.php (@Symfony ruleset with phpdoc_to_comment ignored_tags) and phpstan.neon (level max, treatPhpDocTypesAsCertain: false) - Run CS Fixer and PHPStan in every CI matrix job alongside tests - Add composer scripts: cs, cs-check, phpstan - Add .php-cs-fixer.cache to .gitignore - Fix all PHPStan max violations across src/: add return/param types, narrow mixed config values with is_string()/is_array() guards, use TaggedNodeInterface for scenario tag access in SessionsListener - Remove GoutteFactory and its spec — the goutte driver and its underlying client library are abandoned Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
92 lines
2.8 KiB
PHP
92 lines
2.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Behat MinkExtension.
|
|
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Behat\MinkExtension\ServiceContainer\Driver;
|
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
|
use Symfony\Component\DependencyInjection\Definition;
|
|
|
|
class Selenium4Factory implements DriverFactory
|
|
{
|
|
use EnvironmentCapabilities;
|
|
|
|
public function getDriverName(): string
|
|
{
|
|
return 'selenium4';
|
|
}
|
|
|
|
public function supportsJavascript(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function configure(ArrayNodeDefinition $builder): void
|
|
{
|
|
$builder
|
|
->children()
|
|
->scalarNode('name')->defaultValue('Behat Test')->end()
|
|
->scalarNode('browser')->defaultValue('%mink.browser_name%')->end()
|
|
->append($this->getCapabilitiesNode())
|
|
->scalarNode('wd_host')->defaultValue('http://localhost:4444/wd/hub')->end()
|
|
->end()
|
|
;
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $config
|
|
*/
|
|
public function buildDriver(array $config): Definition
|
|
{
|
|
if (!class_exists('Behat\Mink\Driver\Selenium4Driver')) {
|
|
throw new \RuntimeException(sprintf('Install MinkSelenium4Driver in order to use %s driver.', $this->getDriverName()));
|
|
}
|
|
|
|
return new Definition('Behat\Mink\Driver\Selenium4Driver', [
|
|
$config['browser'],
|
|
array_merge(
|
|
$this->guessEnvironmentCapabilities(),
|
|
is_array($config['capabilities']) ? $config['capabilities'] : []
|
|
),
|
|
$config['wd_host'],
|
|
]);
|
|
}
|
|
|
|
protected function getCapabilitiesNode(): ArrayNodeDefinition
|
|
{
|
|
$node = new ArrayNodeDefinition('capabilities');
|
|
|
|
$node
|
|
->addDefaultsIfNotSet()
|
|
->normalizeKeys(false)
|
|
->children()
|
|
->arrayNode('firstMatch')
|
|
->end()
|
|
->arrayNode('alwaysMatch')
|
|
->children()
|
|
->scalarNode('browserName')->end()
|
|
->scalarNode('pageLoadStrategy')->end()
|
|
->arrayNode('goog:chromeOptions')
|
|
->children()
|
|
->arrayNode('extensions')
|
|
->scalarPrototype()->end()
|
|
->end()
|
|
->arrayNode('args')
|
|
->scalarPrototype()->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end();
|
|
|
|
return $node;
|
|
}
|
|
}
|