Merge pull request #16 from SwenVanZanten/goutte-client-4-compatibility
Add goutte/client 4 compatibility
This commit is contained in:
@@ -68,7 +68,21 @@ 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')) {
|
||||
$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']);
|
||||
@@ -76,10 +90,11 @@ class GoutteFactory implements DriverFactory
|
||||
$guzzleClient = $this->buildGuzzle4Client($config['guzzle_parameters']);
|
||||
}
|
||||
|
||||
$clientDefinition = new Definition('Behat\Mink\Driver\Goutte\Client', array(
|
||||
$config['server_parameters'],
|
||||
));
|
||||
$clientDefinition->addMethodCall('setClient', array($guzzleClient));
|
||||
$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 +127,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