Add PHP CS Fixer and PHPStan max to CI; remove abandoned GoutteFactory
- 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>
This commit is contained in:
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Behat\MinkExtension\ServiceContainer\Driver;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
class AppiumFactory extends Selenium2Factory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'appium';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
@@ -31,18 +25,18 @@ class AppiumFactory extends Selenium2Factory
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function buildDriver(array $config)
|
||||
public function buildDriver(array $config): Definition
|
||||
{
|
||||
$host = $config['appium_host'].":".$config['appium_port'];
|
||||
$host = (is_string($config['appium_host']) ? $config['appium_host'] : '').':'.(is_string($config['appium_port']) ? $config['appium_port'] : '');
|
||||
|
||||
$config['wd_host'] = sprintf('%s/wd/hub', $host);
|
||||
|
||||
return parent::buildDriver($config);
|
||||
}
|
||||
|
||||
protected function getCapabilitiesNode()
|
||||
protected function getCapabilitiesNode(): ArrayNodeDefinition
|
||||
{
|
||||
$node = parent::getCapabilitiesNode();
|
||||
|
||||
@@ -63,7 +57,7 @@ class AppiumFactory extends Selenium2Factory
|
||||
->booleanNode('autoWebview')->end()
|
||||
->booleanNode('noReset')->end()
|
||||
->booleanNode('fullReset')->end()
|
||||
//ANDROID ONLY
|
||||
// ANDROID ONLY
|
||||
->scalarNode('appActivity')->end()
|
||||
->scalarNode('appPackage')->end()
|
||||
->scalarNode('appWaitActivity')->end()
|
||||
@@ -116,7 +110,7 @@ class AppiumFactory extends Selenium2Factory
|
||||
->booleanNode('keepKeyChains')->end()
|
||||
->booleanNode('showIOSLog')->end()
|
||||
->end()
|
||||
;
|
||||
;
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
@@ -10,34 +10,24 @@
|
||||
namespace Behat\MinkExtension\ServiceContainer\Driver;
|
||||
|
||||
use Behat\Mink\Driver\BrowserKitDriver;
|
||||
use Symfony\Component\BrowserKit\HttpBrowser;
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\BrowserKit\HttpBrowser;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
|
||||
|
||||
class BrowserKitFactory implements DriverFactory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'browserkit_http';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsJavascript()
|
||||
public function supportsJavascript(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
@@ -51,9 +41,9 @@ class BrowserKitFactory implements DriverFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function buildDriver(array $config)
|
||||
public function buildDriver(array $config): Definition
|
||||
{
|
||||
if (!class_exists(BrowserKitDriver::class)) {
|
||||
throw new \RuntimeException('Install behat/mink-browserkit-driver in order to use the browserkit_http driver.');
|
||||
@@ -77,5 +67,4 @@ class BrowserKitFactory implements DriverFactory
|
||||
'%mink.base_url%',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,21 +11,16 @@
|
||||
namespace Behat\MinkExtension\ServiceContainer\Driver;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
class BrowserStackFactory extends Selenium2Factory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'browser_stack';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
@@ -38,16 +33,16 @@ class BrowserStackFactory extends Selenium2Factory
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function buildDriver(array $config)
|
||||
public function buildDriver(array $config): Definition
|
||||
{
|
||||
$config['wd_host'] = sprintf('%s:%s@hub.browserstack.com/wd/hub', $config['username'], $config['access_key']);
|
||||
$config['wd_host'] = sprintf('%s:%s@hub.browserstack.com/wd/hub', is_string($config['username']) ? $config['username'] : '', is_string($config['access_key']) ? $config['access_key'] : '');
|
||||
|
||||
return parent::buildDriver($config);
|
||||
}
|
||||
|
||||
protected function getCapabilitiesNode()
|
||||
protected function getCapabilitiesNode(): ArrayNodeDefinition
|
||||
{
|
||||
$node = parent::getCapabilitiesNode();
|
||||
|
||||
|
||||
@@ -18,35 +18,14 @@ use Symfony\Component\DependencyInjection\Definition;
|
||||
*/
|
||||
interface DriverFactory
|
||||
{
|
||||
/**
|
||||
* Gets the name of the driver being configured.
|
||||
*
|
||||
* This will be the key of the configuration for the driver.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDriverName();
|
||||
public function getDriverName(): string;
|
||||
|
||||
public function supportsJavascript(): bool;
|
||||
|
||||
public function configure(ArrayNodeDefinition $builder): void;
|
||||
|
||||
/**
|
||||
* Defines whether a session using this driver is eligible as default javascript session
|
||||
*
|
||||
* @return boolean
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function supportsJavascript();
|
||||
|
||||
/**
|
||||
* Setups configuration for the driver factory.
|
||||
*
|
||||
* @param ArrayNodeDefinition $builder
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder);
|
||||
|
||||
/**
|
||||
* Builds the service definition for the driver.
|
||||
*
|
||||
* @param array $config
|
||||
*
|
||||
* @return Definition
|
||||
*/
|
||||
public function buildDriver(array $config);
|
||||
public function buildDriver(array $config): Definition;
|
||||
}
|
||||
|
||||
@@ -7,26 +7,29 @@ namespace Behat\MinkExtension\ServiceContainer\Driver;
|
||||
*/
|
||||
trait EnvironmentCapabilities
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function guessEnvironmentCapabilities(): array
|
||||
{
|
||||
switch (true) {
|
||||
case (bool)getenv('TRAVIS_JOB_NUMBER'):
|
||||
case (bool) getenv('TRAVIS_JOB_NUMBER'):
|
||||
return [
|
||||
'tunnel-identifier' => getenv('TRAVIS_JOB_NUMBER'),
|
||||
'build' => getenv('TRAVIS_BUILD_NUMBER'),
|
||||
'tags' => [
|
||||
'Travis-CI',
|
||||
'PHP ' . PHP_VERSION,
|
||||
'PHP '.PHP_VERSION,
|
||||
],
|
||||
];
|
||||
|
||||
case (bool)getenv('JENKINS_HOME'):
|
||||
case (bool) getenv('JENKINS_HOME'):
|
||||
return [
|
||||
'tunnel-identifier' => getenv('JOB_NAME'),
|
||||
'build' => getenv('BUILD_NUMBER'),
|
||||
'tags' => [
|
||||
'Jenkins',
|
||||
'PHP ' . PHP_VERSION,
|
||||
'PHP '.PHP_VERSION,
|
||||
getenv('BUILD_TAG'),
|
||||
],
|
||||
];
|
||||
@@ -35,7 +38,7 @@ trait EnvironmentCapabilities
|
||||
return [
|
||||
'tags' => [
|
||||
php_uname('n'),
|
||||
'PHP ' . PHP_VERSION,
|
||||
'PHP '.PHP_VERSION,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*/
|
||||
class GoutteFactory implements DriverFactory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
{
|
||||
return 'goutte';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsJavascript()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
->arrayNode('server_parameters')
|
||||
->useAttributeAsKey('key')
|
||||
->prototype('variable')->end()
|
||||
->end()
|
||||
->arrayNode('guzzle_parameters')
|
||||
->useAttributeAsKey('key')
|
||||
->prototype('variable')->end()
|
||||
->info(
|
||||
"For Goutte 1.x, these are the second argument of the Guzzle3 client constructor.\n".
|
||||
'For Goutte 2.x, these are the elements passed in the "defaults" key of the Guzzle4 config.'
|
||||
)
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildDriver(array $config)
|
||||
{
|
||||
trigger_deprecation('friends-of-behat/mink-extension', '2.8.0', 'Configuration for the "goutte" driver is deprecated, since the client implementation has been abandoned. Support for it will be removed in the next major version of this extension.');
|
||||
|
||||
if (!class_exists('Behat\Mink\Driver\GoutteDriver')) {
|
||||
throw new \RuntimeException(
|
||||
'Install MinkGoutteDriver in order to use goutte driver.'
|
||||
);
|
||||
}
|
||||
|
||||
$clientArguments = array(
|
||||
$config['server_parameters'],
|
||||
);
|
||||
$guzzleClient = null;
|
||||
|
||||
if ($this->isGoutte4()) {
|
||||
$clientArguments = array();
|
||||
|
||||
if (class_exists('Symfony\Component\HttpClient\HttpClient')) {
|
||||
$httpClient = new Definition('Symfony\Component\HttpClient\HttpClient');
|
||||
$httpClient->setFactory('Symfony\Component\HttpClient\HttpClient::create');
|
||||
$httpClient->setArgument(0, $config['server_parameters']);
|
||||
$clientArguments = array($httpClient);
|
||||
}
|
||||
} elseif ($this->isGoutte1()) {
|
||||
$guzzleClient = $this->buildGuzzle3Client($config['guzzle_parameters']);
|
||||
} elseif ($this->isGuzzle6()) {
|
||||
$guzzleClient = $this->buildGuzzle6Client($config['guzzle_parameters']);
|
||||
} else {
|
||||
$guzzleClient = $this->buildGuzzle4Client($config['guzzle_parameters']);
|
||||
}
|
||||
|
||||
$clientDefinition = new Definition('Behat\Mink\Driver\Goutte\Client', $clientArguments);
|
||||
|
||||
if (null !== $guzzleClient) {
|
||||
$clientDefinition->addMethodCall('setClient', array($guzzleClient));
|
||||
}
|
||||
|
||||
return new Definition('Behat\Mink\Driver\GoutteDriver', array(
|
||||
$clientDefinition,
|
||||
));
|
||||
}
|
||||
|
||||
private function buildGuzzle6Client(array $parameters)
|
||||
{
|
||||
// Force the parameters set by default in Goutte to reproduce its behavior
|
||||
$parameters['allow_redirects'] = false;
|
||||
$parameters['cookies'] = true;
|
||||
|
||||
return new Definition('GuzzleHttp\Client', array($parameters));
|
||||
}
|
||||
|
||||
private function buildGuzzle4Client(array $parameters)
|
||||
{
|
||||
// Force the parameters set by default in Goutte to reproduce its behavior
|
||||
$parameters['allow_redirects'] = false;
|
||||
$parameters['cookies'] = true;
|
||||
|
||||
return new Definition('GuzzleHttp\Client', array(array('defaults' => $parameters)));
|
||||
}
|
||||
|
||||
private function buildGuzzle3Client(array $parameters)
|
||||
{
|
||||
// Force the parameters set by default in Goutte to reproduce its behavior
|
||||
$parameters['redirect.disable'] = true;
|
||||
|
||||
return new Definition('Guzzle\Http\Client', array(null, $parameters));
|
||||
}
|
||||
|
||||
private function isGoutte4()
|
||||
{
|
||||
$client = 'Goutte\Client';
|
||||
|
||||
return class_exists($client) && is_a($client, 'Symfony\Component\BrowserKit\HttpBrowser', true);
|
||||
}
|
||||
|
||||
private function isGoutte1()
|
||||
{
|
||||
$refl = new \ReflectionParameter(array('Goutte\Client', 'setClient'), 0);
|
||||
|
||||
$type = $refl->getType();
|
||||
if ($type instanceof \ReflectionNamedType && 'Guzzle\Http\ClientInterface' === $type->getName()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isGuzzle6()
|
||||
{
|
||||
return interface_exists('GuzzleHttp\ClientInterface') &&
|
||||
version_compare(\GuzzleHttp\ClientInterface::VERSION, '6.0.0', '>=');
|
||||
}
|
||||
}
|
||||
@@ -15,26 +15,17 @@ use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
class SahiFactory implements DriverFactory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'sahi';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsJavascript()
|
||||
public function supportsJavascript(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
@@ -48,29 +39,27 @@ class SahiFactory implements DriverFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function buildDriver(array $config)
|
||||
public function buildDriver(array $config): Definition
|
||||
{
|
||||
trigger_deprecation('friends-of-behat/mink-extension', '2.8.0', 'Configuration for the "sahi" driver is deprecated, since the client implementation has been abandoned. Support for it will be removed in the next major version of this extension.');
|
||||
|
||||
if (!class_exists('Behat\Mink\Driver\SahiDriver')) {
|
||||
throw new \RuntimeException(
|
||||
'Install MinkSahiDriver in order to use sahi driver.'
|
||||
);
|
||||
throw new \RuntimeException('Install MinkSahiDriver in order to use sahi driver.');
|
||||
}
|
||||
|
||||
return new Definition('Behat\Mink\Driver\SahiDriver', array(
|
||||
return new Definition('Behat\Mink\Driver\SahiDriver', [
|
||||
'%mink.browser_name%',
|
||||
new Definition('Behat\SahiClient\Client', array(
|
||||
new Definition('Behat\SahiClient\Connection', array(
|
||||
new Definition('Behat\SahiClient\Client', [
|
||||
new Definition('Behat\SahiClient\Connection', [
|
||||
$config['sid'],
|
||||
$config['host'],
|
||||
$config['port'],
|
||||
$config['browser'],
|
||||
$config['limit'],
|
||||
)),
|
||||
)),
|
||||
));
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,21 +11,16 @@
|
||||
namespace Behat\MinkExtension\ServiceContainer\Driver;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
class SauceLabsFactory extends Selenium2Factory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'sauce_labs';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
@@ -39,21 +34,21 @@ class SauceLabsFactory extends Selenium2Factory
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function buildDriver(array $config)
|
||||
public function buildDriver(array $config): Definition
|
||||
{
|
||||
$host = 'ondemand.saucelabs.com';
|
||||
if ($config['connect']) {
|
||||
if (is_bool($config['connect']) ? $config['connect'] : (bool) $config['connect']) {
|
||||
$host = 'localhost:4445';
|
||||
}
|
||||
|
||||
$config['wd_host'] = sprintf('%s:%s@%s/wd/hub', $config['username'], $config['access_key'], $host);
|
||||
$config['wd_host'] = sprintf('%s:%s@%s/wd/hub', is_string($config['username']) ? $config['username'] : '', is_string($config['access_key']) ? $config['access_key'] : '', $host);
|
||||
|
||||
return parent::buildDriver($config);
|
||||
}
|
||||
|
||||
protected function getCapabilitiesNode()
|
||||
protected function getCapabilitiesNode(): ArrayNodeDefinition
|
||||
{
|
||||
$node = parent::getCapabilitiesNode();
|
||||
|
||||
@@ -84,9 +79,11 @@ class SauceLabsFactory extends Selenium2Factory
|
||||
->booleanNode('disable-popup-handler')->end()
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function ($v) {return empty($v['custom-data']);})
|
||||
->then(function ($v) {
|
||||
unset ($v['custom-data']);
|
||||
->ifTrue(function (mixed $v): bool {return !is_array($v) || empty($v['custom-data']); })
|
||||
->then(function (mixed $v): mixed {
|
||||
if (is_array($v)) {
|
||||
unset($v['custom-data']);
|
||||
}
|
||||
|
||||
return $v;
|
||||
})
|
||||
|
||||
@@ -17,26 +17,17 @@ class Selenium2Factory implements DriverFactory
|
||||
{
|
||||
use EnvironmentCapabilities;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'selenium2';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsJavascript()
|
||||
public function supportsJavascript(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
@@ -48,28 +39,28 @@ class Selenium2Factory implements DriverFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function buildDriver(array $config)
|
||||
public function buildDriver(array $config): Definition
|
||||
{
|
||||
if (!class_exists('Behat\Mink\Driver\Selenium2Driver')) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'Install MinkSelenium2Driver in order to use %s driver.',
|
||||
$this->getDriverName()
|
||||
));
|
||||
throw new \RuntimeException(sprintf('Install MinkSelenium2Driver in order to use %s driver.', $this->getDriverName()));
|
||||
}
|
||||
|
||||
$extraCapabilities = $config['capabilities']['extra_capabilities'];
|
||||
unset($config['capabilities']['extra_capabilities']);
|
||||
/** @var array<string, mixed> $capabilities */
|
||||
$capabilities = is_array($config['capabilities']) ? $config['capabilities'] : [];
|
||||
/** @var array<string, mixed> $extraCapabilities */
|
||||
$extraCapabilities = is_array($capabilities['extra_capabilities']) ? $capabilities['extra_capabilities'] : [];
|
||||
unset($capabilities['extra_capabilities']);
|
||||
|
||||
return new Definition('Behat\Mink\Driver\Selenium2Driver', array(
|
||||
return new Definition('Behat\Mink\Driver\Selenium2Driver', [
|
||||
$config['browser'],
|
||||
array_replace($this->guessEnvironmentCapabilities(), $extraCapabilities, $config['capabilities']),
|
||||
array_replace($this->guessEnvironmentCapabilities(), $extraCapabilities, $capabilities),
|
||||
$config['wd_host'],
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getCapabilitiesNode()
|
||||
protected function getCapabilitiesNode(): ArrayNodeDefinition
|
||||
{
|
||||
$node = new ArrayNodeDefinition('capabilities');
|
||||
|
||||
@@ -106,7 +97,7 @@ class Selenium2Factory implements DriverFactory
|
||||
->scalarNode('sslProxy')->end()
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function ($v) {
|
||||
->ifTrue(function (mixed $v): bool {
|
||||
return empty($v);
|
||||
})
|
||||
->thenUnset()
|
||||
@@ -116,8 +107,8 @@ class Selenium2Factory implements DriverFactory
|
||||
->children()
|
||||
->scalarNode('profile')
|
||||
->validate()
|
||||
->ifTrue(function ($v) {
|
||||
return !file_exists($v);
|
||||
->ifTrue(function (mixed $v): bool {
|
||||
return !is_string($v) || !file_exists($v);
|
||||
})
|
||||
->thenInvalid('Cannot find profile zip file %s')
|
||||
->end()
|
||||
@@ -137,11 +128,14 @@ class Selenium2Factory implements DriverFactory
|
||||
->end()
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function ($v) {
|
||||
return empty($v['prefs']);
|
||||
->ifTrue(function (mixed $v): bool {
|
||||
return !is_array($v) || empty($v['prefs']);
|
||||
})
|
||||
->then(function ($v) {
|
||||
unset($v['prefs']);
|
||||
->then(function (mixed $v): mixed {
|
||||
if (is_array($v)) {
|
||||
unset($v['prefs']);
|
||||
}
|
||||
|
||||
return $v;
|
||||
})
|
||||
->end()
|
||||
|
||||
@@ -17,26 +17,17 @@ class Selenium4Factory implements DriverFactory
|
||||
{
|
||||
use EnvironmentCapabilities;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'selenium4';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsJavascript()
|
||||
public function supportsJavascript(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
@@ -49,28 +40,25 @@ class Selenium4Factory implements DriverFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function buildDriver(array $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()
|
||||
));
|
||||
throw new \RuntimeException(sprintf('Install MinkSelenium4Driver in order to use %s driver.', $this->getDriverName()));
|
||||
}
|
||||
|
||||
return new Definition('Behat\Mink\Driver\Selenium4Driver', array(
|
||||
return new Definition('Behat\Mink\Driver\Selenium4Driver', [
|
||||
$config['browser'],
|
||||
array_merge(
|
||||
$this->guessEnvironmentCapabilities(),
|
||||
$config['capabilities']
|
||||
is_array($config['capabilities']) ? $config['capabilities'] : []
|
||||
),
|
||||
$config['wd_host'],
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getCapabilitiesNode()
|
||||
protected function getCapabilitiesNode(): ArrayNodeDefinition
|
||||
{
|
||||
$node = new ArrayNodeDefinition('capabilities');
|
||||
|
||||
|
||||
@@ -15,26 +15,17 @@ use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
class SeleniumFactory implements DriverFactory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'selenium';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsJavascript()
|
||||
public function supportsJavascript(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
@@ -46,25 +37,23 @@ class SeleniumFactory implements DriverFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function buildDriver(array $config)
|
||||
public function buildDriver(array $config): Definition
|
||||
{
|
||||
trigger_deprecation('friends-of-behat/mink-extension', '2.8.0', 'Configuration for the "selenium" driver is deprecated, since the client implementation has been abandoned. Support for it will be removed in the next major version of this extension.');
|
||||
|
||||
if (!class_exists('Behat\Mink\Driver\SeleniumDriver')) {
|
||||
throw new \RuntimeException(
|
||||
'Install MinkSeleniumDriver in order to activate selenium session.'
|
||||
);
|
||||
throw new \RuntimeException('Install MinkSeleniumDriver in order to activate selenium session.');
|
||||
}
|
||||
|
||||
return new Definition('Behat\Mink\Driver\SeleniumDriver', array(
|
||||
return new Definition('Behat\Mink\Driver\SeleniumDriver', [
|
||||
$config['browser'],
|
||||
'%mink.base_url%',
|
||||
new Definition('Selenium\Client', array(
|
||||
new Definition('Selenium\Client', [
|
||||
$config['host'],
|
||||
$config['port'],
|
||||
)),
|
||||
));
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,25 +10,16 @@ class WebdriverClassicFactory implements DriverFactory
|
||||
{
|
||||
use EnvironmentCapabilities;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'webdriver_classic';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsJavascript(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
@@ -43,22 +34,17 @@ class WebdriverClassicFactory implements DriverFactory
|
||||
->end();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildDriver(array $config): Definition
|
||||
{
|
||||
if (!class_exists(WebdriverClassicDriver::class)) {
|
||||
throw new \RuntimeException(
|
||||
"Install mink/webdriver-classic-driver in order to use the {$this->getDriverName()} driver."
|
||||
);
|
||||
throw new \RuntimeException("Install mink/webdriver-classic-driver in order to use the {$this->getDriverName()} driver.");
|
||||
}
|
||||
|
||||
return new Definition(WebdriverClassicDriver::class, [
|
||||
$config['browser'],
|
||||
array_merge(
|
||||
$this->guessEnvironmentCapabilities(),
|
||||
$config['capabilities']
|
||||
is_array($config['capabilities']) ? $config['capabilities'] : []
|
||||
),
|
||||
$config['wd_host'],
|
||||
]);
|
||||
|
||||
@@ -15,26 +15,17 @@ use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
class ZombieFactory implements DriverFactory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverName()
|
||||
public function getDriverName(): string
|
||||
{
|
||||
return 'zombie';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsJavascript()
|
||||
public function supportsJavascript(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder)
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
@@ -49,27 +40,25 @@ class ZombieFactory implements DriverFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function buildDriver(array $config)
|
||||
public function buildDriver(array $config): Definition
|
||||
{
|
||||
trigger_deprecation('friends-of-behat/mink-extension', '2.8.0', 'Configuration for the "zombie" driver is deprecated, since the client implementation has been abandoned. Support for it will be removed in the next major version of this extension.');
|
||||
|
||||
if (!class_exists('Behat\Mink\Driver\ZombieDriver')) {
|
||||
throw new \RuntimeException(
|
||||
'Install MinkZombieDriver in order to use zombie driver.'
|
||||
);
|
||||
throw new \RuntimeException('Install MinkZombieDriver in order to use zombie driver.');
|
||||
}
|
||||
|
||||
return new Definition('Behat\Mink\Driver\ZombieDriver', array(
|
||||
new Definition('Behat\Mink\Driver\NodeJS\Server\ZombieServer', array(
|
||||
return new Definition('Behat\Mink\Driver\ZombieDriver', [
|
||||
new Definition('Behat\Mink\Driver\NodeJS\Server\ZombieServer', [
|
||||
$config['host'],
|
||||
$config['port'],
|
||||
$config['node_bin'],
|
||||
$config['server_path'],
|
||||
$config['threshold'],
|
||||
$config['node_modules_path'],
|
||||
)),
|
||||
));
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ use Behat\MinkExtension\ServiceContainer\Driver\AppiumFactory;
|
||||
use Behat\MinkExtension\ServiceContainer\Driver\BrowserKitFactory;
|
||||
use Behat\MinkExtension\ServiceContainer\Driver\BrowserStackFactory;
|
||||
use Behat\MinkExtension\ServiceContainer\Driver\DriverFactory;
|
||||
use Behat\MinkExtension\ServiceContainer\Driver\GoutteFactory;
|
||||
use Behat\MinkExtension\ServiceContainer\Driver\SahiFactory;
|
||||
use Behat\MinkExtension\ServiceContainer\Driver\SauceLabsFactory;
|
||||
use Behat\MinkExtension\ServiceContainer\Driver\Selenium2Factory;
|
||||
@@ -43,19 +42,18 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
*/
|
||||
class MinkExtension implements ExtensionInterface
|
||||
{
|
||||
const MINK_ID = 'mink';
|
||||
const SELECTORS_HANDLER_ID = 'mink.selectors_handler';
|
||||
public const MINK_ID = 'mink';
|
||||
public const SELECTORS_HANDLER_ID = 'mink.selectors_handler';
|
||||
|
||||
const SELECTOR_TAG = 'mink.selector';
|
||||
public const SELECTOR_TAG = 'mink.selector';
|
||||
|
||||
/**
|
||||
* @var DriverFactory[]
|
||||
*/
|
||||
private $driverFactories = array();
|
||||
private $driverFactories = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->registerDriverFactory(new GoutteFactory());
|
||||
$this->registerDriverFactory(new BrowserKitFactory());
|
||||
$this->registerDriverFactory(new SahiFactory());
|
||||
$this->registerDriverFactory(new SeleniumFactory());
|
||||
@@ -73,18 +71,17 @@ class MinkExtension implements ExtensionInterface
|
||||
$this->driverFactories[$driverFactory->getDriverName()] = $driverFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function load(ContainerBuilder $container, array $config): void
|
||||
{
|
||||
if (isset($config['mink_loader'])) {
|
||||
$basePath = $container->getParameter('paths.base');
|
||||
$basePath = is_string($basePath) ? $basePath : '';
|
||||
$minkLoader = is_string($config['mink_loader']) ? $config['mink_loader'] : '';
|
||||
|
||||
if (file_exists($basePath.DIRECTORY_SEPARATOR.$config['mink_loader'])) {
|
||||
require($basePath.DIRECTORY_SEPARATOR.$config['mink_loader']);
|
||||
if (file_exists($basePath.DIRECTORY_SEPARATOR.$minkLoader)) {
|
||||
require $basePath.DIRECTORY_SEPARATOR.$minkLoader;
|
||||
} else {
|
||||
require($config['mink_loader']);
|
||||
require $minkLoader;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,31 +98,38 @@ class MinkExtension implements ExtensionInterface
|
||||
unset($config['sessions']);
|
||||
|
||||
$container->setParameter('mink.parameters', $config);
|
||||
$container->setParameter('mink.base_url', $config['base_url']);
|
||||
$container->setParameter('mink.browser_name', $config['browser_name']);
|
||||
$container->setParameter('mink.base_url', is_string($config['base_url'] ?? '') ? ($config['base_url'] ?? '') : '');
|
||||
$container->setParameter('mink.browser_name', is_string($config['browser_name'] ?? '') ? ($config['browser_name'] ?? '') : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function configure(ArrayNodeDefinition $builder): void
|
||||
{
|
||||
// Rewrite keys to define a shortcut way without allowing conflicts with real keys
|
||||
$renamedKeys = array_diff(
|
||||
array_keys($this->driverFactories),
|
||||
array('mink_loader', 'base_url', 'files_path', 'show_auto', 'show_cmd', 'show_tmp_dir', 'default_session', 'javascript_session', 'browser_name', 'sessions')
|
||||
['mink_loader', 'base_url', 'files_path', 'show_auto', 'show_cmd', 'show_tmp_dir', 'default_session', 'javascript_session', 'browser_name', 'sessions']
|
||||
);
|
||||
|
||||
$builder
|
||||
->beforeNormalization()
|
||||
->always()
|
||||
->then(function ($v) use ($renamedKeys) {
|
||||
->then(function (mixed $v) use ($renamedKeys): mixed {
|
||||
if (!is_array($v)) {
|
||||
return $v;
|
||||
}
|
||||
|
||||
foreach ($renamedKeys as $driverType) {
|
||||
if (!array_key_exists($driverType, $v) || isset($v['sessions'][$driverType])) {
|
||||
if (!array_key_exists($driverType, $v)) {
|
||||
continue;
|
||||
}
|
||||
/** @var array<string, array<string, mixed>> $sessions */
|
||||
$sessions = is_array($v['sessions']) ? $v['sessions'] : [];
|
||||
if (isset($sessions[$driverType])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$v['sessions'][$driverType][$driverType] = $v[$driverType];
|
||||
$sessions[$driverType][$driverType] = $v[$driverType];
|
||||
$v['sessions'] = $sessions;
|
||||
unset($v[$driverType]);
|
||||
}
|
||||
|
||||
@@ -164,84 +168,87 @@ class MinkExtension implements ExtensionInterface
|
||||
|
||||
$sessionsBuilder
|
||||
->validate()
|
||||
->ifTrue(function ($v) {return count($v) > 1;})
|
||||
->ifTrue(function (mixed $v): bool {return is_array($v) && count($v) > 1; })
|
||||
->thenInvalid('You cannot set multiple driver types for the same session')
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function ($v) {return count($v) === 0;})
|
||||
->ifTrue(function (mixed $v): bool {return is_array($v) && 0 === count($v); })
|
||||
->thenInvalid('You must set a driver definition for the session.')
|
||||
->end()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getConfigKey(): string
|
||||
{
|
||||
return 'mink';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function initialize(ExtensionManager $extensionManager): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$this->processSelectors($container);
|
||||
}
|
||||
|
||||
private function loadMink(ContainerBuilder $container)
|
||||
private function loadMink(ContainerBuilder $container): void
|
||||
{
|
||||
$container->setDefinition(self::MINK_ID, new Definition('Behat\Mink\Mink'));
|
||||
}
|
||||
|
||||
private function loadContextInitializer(ContainerBuilder $container)
|
||||
private function loadContextInitializer(ContainerBuilder $container): void
|
||||
{
|
||||
$definition = new Definition('Behat\MinkExtension\Context\Initializer\MinkAwareInitializer', array(
|
||||
$definition = new Definition('Behat\MinkExtension\Context\Initializer\MinkAwareInitializer', [
|
||||
new Reference(self::MINK_ID),
|
||||
'%mink.parameters%',
|
||||
));
|
||||
$definition->addTag(ContextExtension::INITIALIZER_TAG, array('priority' => 0));
|
||||
]);
|
||||
$definition->addTag(ContextExtension::INITIALIZER_TAG, ['priority' => 0]);
|
||||
$container->setDefinition('mink.context_initializer', $definition);
|
||||
}
|
||||
|
||||
private function loadSelectorsHandler(ContainerBuilder $container)
|
||||
private function loadSelectorsHandler(ContainerBuilder $container): void
|
||||
{
|
||||
$container->setDefinition(self::SELECTORS_HANDLER_ID, new Definition('Behat\Mink\Selector\SelectorsHandler'));
|
||||
|
||||
$cssSelectorDefinition = new Definition('Behat\Mink\Selector\CssSelector');
|
||||
$cssSelectorDefinition->addTag(self::SELECTOR_TAG, array('alias' => 'css'));
|
||||
$container->setDefinition(self::SELECTOR_TAG . '.css', $cssSelectorDefinition);
|
||||
$cssSelectorDefinition->addTag(self::SELECTOR_TAG, ['alias' => 'css']);
|
||||
$container->setDefinition(self::SELECTOR_TAG.'.css', $cssSelectorDefinition);
|
||||
|
||||
$namedSelectorDefinition = new Definition('Behat\Mink\Selector\NamedSelector');
|
||||
$namedSelectorDefinition->addTag(self::SELECTOR_TAG, array('alias' => 'named'));
|
||||
$container->setDefinition(self::SELECTOR_TAG . '.named', $namedSelectorDefinition);
|
||||
$namedSelectorDefinition->addTag(self::SELECTOR_TAG, ['alias' => 'named']);
|
||||
$container->setDefinition(self::SELECTOR_TAG.'.named', $namedSelectorDefinition);
|
||||
}
|
||||
|
||||
private function loadSessions(ContainerBuilder $container, array $config)
|
||||
/**
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
private function loadSessions(ContainerBuilder $container, array $config): void
|
||||
{
|
||||
$defaultSession = $config['default_session'];
|
||||
$javascriptSession = $config['javascript_session'];
|
||||
$javascriptSessions = $nonJavascriptSessions = array();
|
||||
/** @var string|null $defaultSession */
|
||||
$defaultSession = is_string($config['default_session']) ? $config['default_session'] : null;
|
||||
/** @var string|null $javascriptSession */
|
||||
$javascriptSession = is_string($config['javascript_session']) ? $config['javascript_session'] : null;
|
||||
/** @var string[] $javascriptSessions */
|
||||
$javascriptSessions = [];
|
||||
/** @var string[] $nonJavascriptSessions */
|
||||
$nonJavascriptSessions = [];
|
||||
|
||||
$minkDefinition = $container->getDefinition(self::MINK_ID);
|
||||
|
||||
foreach ($config['sessions'] as $name => $session) {
|
||||
$driver = key($session);
|
||||
/** @var array<string, array<string, mixed>> $sessions */
|
||||
$sessions = is_array($config['sessions']) ? $config['sessions'] : [];
|
||||
foreach ($sessions as $name => $session) {
|
||||
$driver = (string) key($session);
|
||||
$factory = $this->driverFactories[$driver];
|
||||
|
||||
$definition = new Definition('Behat\Mink\Session', array(
|
||||
$factory->buildDriver($session[$driver]),
|
||||
/** @var array<string, mixed> $driverConfig */
|
||||
$driverConfig = is_array($session[$driver]) ? $session[$driver] : [];
|
||||
$definition = new Definition('Behat\Mink\Session', [
|
||||
$factory->buildDriver($driverConfig),
|
||||
new Reference(self::SELECTORS_HANDLER_ID),
|
||||
));
|
||||
$minkDefinition->addMethodCall('registerSession', array($name, $definition));
|
||||
]);
|
||||
$minkDefinition->addMethodCall('registerSession', [$name, $definition]);
|
||||
|
||||
if ($factory->supportsJavascript()) {
|
||||
$javascriptSessions[] = $name;
|
||||
@@ -253,16 +260,12 @@ class MinkExtension implements ExtensionInterface
|
||||
if (null === $javascriptSession && !empty($javascriptSessions)) {
|
||||
$javascriptSession = $javascriptSessions[0];
|
||||
} elseif (null !== $javascriptSession && !in_array($javascriptSession, $javascriptSessions)) {
|
||||
throw new InvalidConfigurationException(sprintf(
|
||||
'The javascript session must be one of the enabled javascript sessions (%s), but got %s',
|
||||
json_encode($javascriptSessions),
|
||||
$javascriptSession
|
||||
));
|
||||
throw new InvalidConfigurationException(sprintf('The javascript session must be one of the enabled javascript sessions (%s), but got %s', json_encode($javascriptSessions), $javascriptSession));
|
||||
}
|
||||
|
||||
if (null === $defaultSession) {
|
||||
$defaultSession = !empty($nonJavascriptSessions) ? $nonJavascriptSessions[0] : $javascriptSessions[0];
|
||||
} elseif (!isset($config['sessions'][$defaultSession])) {
|
||||
} elseif (!is_array($config['sessions']) || !isset($config['sessions'][$defaultSession])) {
|
||||
throw new InvalidConfigurationException(sprintf('The default session must be one of the enabled sessions, but got %s', $defaultSession));
|
||||
}
|
||||
|
||||
@@ -271,43 +274,39 @@ class MinkExtension implements ExtensionInterface
|
||||
$container->setParameter('mink.available_javascript_sessions', $javascriptSessions);
|
||||
}
|
||||
|
||||
private function loadSessionsListener(ContainerBuilder $container)
|
||||
private function loadSessionsListener(ContainerBuilder $container): void
|
||||
{
|
||||
$definition = new Definition('Behat\MinkExtension\Listener\SessionsListener', array(
|
||||
$definition = new Definition('Behat\MinkExtension\Listener\SessionsListener', [
|
||||
new Reference(self::MINK_ID),
|
||||
'%mink.default_session%',
|
||||
'%mink.javascript_session%',
|
||||
'%mink.available_javascript_sessions%',
|
||||
));
|
||||
$definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG, array('priority' => 0));
|
||||
]);
|
||||
$definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG, ['priority' => 0]);
|
||||
$container->setDefinition('mink.listener.sessions', $definition);
|
||||
}
|
||||
|
||||
private function loadFailureShowListener(ContainerBuilder $container)
|
||||
private function loadFailureShowListener(ContainerBuilder $container): void
|
||||
{
|
||||
$definition = new Definition('Behat\MinkExtension\Listener\FailureShowListener', array(
|
||||
$definition = new Definition('Behat\MinkExtension\Listener\FailureShowListener', [
|
||||
new Reference(self::MINK_ID),
|
||||
'%mink.parameters%',
|
||||
));
|
||||
$definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG, array('priority' => 0));
|
||||
]);
|
||||
$definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG, ['priority' => 0]);
|
||||
$container->setDefinition('mink.listener.failure_show', $definition);
|
||||
}
|
||||
|
||||
private function processSelectors(ContainerBuilder $container)
|
||||
private function processSelectors(ContainerBuilder $container): void
|
||||
{
|
||||
$handlerDefinition = $container->getDefinition(self::SELECTORS_HANDLER_ID);
|
||||
|
||||
foreach ($container->findTaggedServiceIds(self::SELECTOR_TAG) as $id => $tags) {
|
||||
foreach ($tags as $tag) {
|
||||
if (!isset($tag['alias'])) {
|
||||
throw new ProcessingException(sprintf(
|
||||
'All `%s` tags should have an `alias` attribute, but `%s` service has none.',
|
||||
$tag,
|
||||
$id
|
||||
));
|
||||
if (!is_array($tag) || !isset($tag['alias'])) {
|
||||
throw new ProcessingException(sprintf('All `%s` tags should have an `alias` attribute, but `%s` service has none.', self::SELECTOR_TAG, $id));
|
||||
}
|
||||
$handlerDefinition->addMethodCall(
|
||||
'registerSelector', array($tag['alias'], new Reference($id))
|
||||
'registerSelector', [is_string($tag['alias']) ? $tag['alias'] : '', new Reference($id)]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user