diff --git a/src/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactory.php b/src/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactory.php index 2bb3416..fb10d88 100644 --- a/src/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactory.php +++ b/src/Behat/MinkExtension/ServiceContainer/Driver/GoutteFactory.php @@ -70,6 +70,8 @@ class GoutteFactory implements DriverFactory if ($this->isGoutte1()) { $guzzleClient = $this->buildGuzzle3Client($config['guzzle_parameters']); + } elseif ($this->isGuzzle6()) { + $guzzleClient = $this->buildGuzzle6Client($config['guzzle_parameters']); } else { $guzzleClient = $this->buildGuzzle4Client($config['guzzle_parameters']); } @@ -84,14 +86,22 @@ class GoutteFactory implements DriverFactory )); } - private function buildGuzzle4Client(array $parameters) + 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) @@ -112,4 +122,10 @@ class GoutteFactory implements DriverFactory return false; } + + private function isGuzzle6() + { + return interface_exists('GuzzleHttp\ClientInterface') && + version_compare(\GuzzleHttp\ClientInterface::VERSION, '6.0.0', '>='); + } }