bug #66 Revert mink parameters autoconfiguration (pamil)

This PR was merged into the 2.0 branch.

Discussion
----------

According to #63 and #54, it looks like the way we used autoconfiguration to bind `$minkParameters` variable was abusing the Symfony's Dependency Injection API and is not officially supported. I'm removing that possibility, because it's very unstable and prevents library adoption.

Commits
-------

717c869ad6 Revert mink parameters autoconfiguration
This commit is contained in:
Kamil Kokot
2019-02-07 12:50:56 +01:00
committed by GitHub
4 changed files with 5 additions and 21 deletions

View File

@@ -13,7 +13,7 @@
"require": { "require": {
"php": "^7.1", "php": "^7.1",
"behat/behat": "^3.4", "behat/behat": "^3.4",
"symfony/dependency-injection": "^3.4.10|^4.1", "symfony/dependency-injection": "^3.4|^4.1",
"symfony/http-kernel": "^3.4|^4.1", "symfony/http-kernel": "^3.4|^4.1",
"symfony/proxy-manager-bridge": "^3.4|^4.1" "symfony/proxy-manager-bridge": "^3.4|^4.1"
}, },
@@ -26,9 +26,6 @@
"symfony/framework-bundle": "^3.4|^4.1", "symfony/framework-bundle": "^3.4|^4.1",
"symfony/yaml": "^3.4|^4.1" "symfony/yaml": "^3.4|^4.1"
}, },
"conflict": {
"symfony/dependency-injection": "4.1.11"
},
"suggest": { "suggest": {
"behat/mink-browserkit-driver": "^1.3" "behat/mink-browserkit-driver": "^1.3"
}, },

View File

@@ -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.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 * **`behat.mink.parameters`** (autowired by `\FriendsOfBehat\SymfonyExtension\Mink\MinkParameters`) - an object
configuration parameters of `MinkExtension` containing the configuration parameters of `MinkExtension` (implementing `\ArrayAccess` so that it can be treated as an array)

View File

@@ -39,22 +39,15 @@ Feature: Mink integration with dependency injection
use Behat\Behat\Context\Context; use Behat\Behat\Context\Context;
use Behat\Mink\Session; use Behat\Mink\Session;
use FriendsOfBehat\SymfonyExtension\Mink\MinkParameters;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
final class SomeContext implements Context { final class SomeContext implements Context {
private $session; private $session;
private $parameters; 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->session = $session;
$this->parameters = $minkParameters; $this->parameters = $minkParameters;
} }

View File

@@ -47,12 +47,6 @@ final class FriendsOfBehatSymfonyExtensionExtension extends Extension implements
{ {
$this->registerMinkDefaultSession($container); $this->registerMinkDefaultSession($container);
$this->registerMinkParameters($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 private function registerMinkDefaultSession(ContainerBuilder $container): void