add goutte/client 4 compatibility
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
"behat/mink-extension": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"behat/mink-goutte-driver": "^1.1",
|
||||
"behat/mink-goutte-driver": "^1.1 || ^2.0",
|
||||
"phpspec/phpspec": "^6.0 || ^7.0 || 7.1.x-dev"
|
||||
},
|
||||
"extra": {
|
||||
|
||||
@@ -68,7 +68,20 @@ class GoutteFactory implements DriverFactory
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->isGoutte1()) {
|
||||
$clientArguments = array(
|
||||
$config['server_parameters'],
|
||||
);
|
||||
$guzzleClient = null;
|
||||
|
||||
if ($this->isGoutte4()) {
|
||||
$clientArguments = array();
|
||||
|
||||
if (class_exists('Symfony\Component\HttpClient\HttpClient')) {
|
||||
$clientArguments = array(
|
||||
\Symfony\Component\HttpClient\HttpClient::create($config['server_parameters'])
|
||||
);
|
||||
}
|
||||
} elseif ($this->isGoutte1()) {
|
||||
$guzzleClient = $this->buildGuzzle3Client($config['guzzle_parameters']);
|
||||
} elseif ($this->isGuzzle6()) {
|
||||
$guzzleClient = $this->buildGuzzle6Client($config['guzzle_parameters']);
|
||||
@@ -76,10 +89,11 @@ class GoutteFactory implements DriverFactory
|
||||
$guzzleClient = $this->buildGuzzle4Client($config['guzzle_parameters']);
|
||||
}
|
||||
|
||||
$clientDefinition = new Definition('Behat\Mink\Driver\Goutte\Client', array(
|
||||
$config['server_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,
|
||||
@@ -112,6 +126,13 @@ class GoutteFactory implements DriverFactory
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user