diff --git a/composer.json b/composer.json index 83a9e23..2c3c87c 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "require": { "php": "^7.1", "behat/behat": "^3.4", - "symfony/dependency-injection": "^3.4.10|^4.2", + "symfony/dependency-injection": "^3.4|^4.2", "symfony/http-kernel": "^3.4|^4.2", "symfony/proxy-manager-bridge": "^3.4|^4.2" }, diff --git a/docs/02_usage.md b/docs/02_usage.md index 321616f..a886d1e 100644 --- a/docs/02_usage.md +++ b/docs/02_usage.md @@ -10,7 +10,7 @@ Feature: Using SymfonyExtension Then the application's kernel should use "test" environment ``` -There are two methods to check the kernel's environment - either by calling `getEnviornment()` method on the kernel itself +There are two methods to check the kernel's environment - either by calling `getEnvironment()` method on the kernel itself or by injecting `%kernel.environment%` parameter. We'll need also a dummy context implementation: diff --git a/docs/03_mink_integration.md b/docs/03_mink_integration.md index f60724e..a6ac71a 100644 --- a/docs/03_mink_integration.md +++ b/docs/03_mink_integration.md @@ -31,5 +31,5 @@ This integration provides two services to use inside Symfony container: * **`behat.mink.default_session`** (autowired by `\Behat\Mink\Session`) - the default Mink session for the current scenario - * **`behat.mink.parameters`** (autoconfigured by `$minkParameters`) - an array (`\ArrayAccess` object) containing the - configuration parameters of `MinkExtension` + * **`behat.mink.parameters`** (autowired by `\FriendsOfBehat\SymfonyExtension\Mink\MinkParameters`) - an object + containing the configuration parameters of `MinkExtension` (implementing `\ArrayAccess` so that it can be treated as an array) diff --git a/features/mink_integration/mink_integration_with_dependency_injection.feature b/features/mink_integration/mink_integration_with_dependency_injection.feature index 808e413..3318d94 100644 --- a/features/mink_integration/mink_integration_with_dependency_injection.feature +++ b/features/mink_integration/mink_integration_with_dependency_injection.feature @@ -39,22 +39,15 @@ Feature: Mink integration with dependency injection use Behat\Behat\Context\Context; use Behat\Mink\Session; + use FriendsOfBehat\SymfonyExtension\Mink\MinkParameters; use Psr\Container\ContainerInterface; final class SomeContext implements Context { private $session; private $parameters; - public function __construct(Session $session, $minkParameters) + public function __construct(Session $session, MinkParameters $minkParameters) { - if (!is_array($minkParameters) && !$minkParameters instanceof \ArrayAccess) { - throw new \InvalidArgumentException(sprintf( - '"$parameters" passed to "%s" has to be an array or implement "%s".', - self::class, - \ArrayAccess::class - )); - } - $this->session = $session; $this->parameters = $minkParameters; } diff --git a/src/Bundle/DependencyInjection/FriendsOfBehatSymfonyExtensionExtension.php b/src/Bundle/DependencyInjection/FriendsOfBehatSymfonyExtensionExtension.php index a80a6d7..7e081e0 100644 --- a/src/Bundle/DependencyInjection/FriendsOfBehatSymfonyExtensionExtension.php +++ b/src/Bundle/DependencyInjection/FriendsOfBehatSymfonyExtensionExtension.php @@ -47,12 +47,6 @@ final class FriendsOfBehatSymfonyExtensionExtension extends Extension implements { $this->registerMinkDefaultSession($container); $this->registerMinkParameters($container); - - $autoconfiguredContextPrototype = $container->registerForAutoconfiguration(Context::class); - $autoconfiguredContextPrototype->setBindings(array_merge( - $autoconfiguredContextPrototype->getBindings(), - ['$minkParameters' => new Reference('behat.mink.parameters')] - )); } private function registerMinkDefaultSession(ContainerBuilder $container): void