Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop' into complete-composer-migration

  • Loading branch information...
commit b43e647f9f2e866999a6b7f3a9e83d1b014ff831 2 parents 2237b42 + 3ce1f0c
@everzet everzet authored
View
7 README.md
@@ -16,15 +16,16 @@ Usage Example
use Behat\Mink\Mink,
Behat\Mink\Session,
Behat\Mink\Driver\GoutteDriver,
+ Behat\Mink\Driver\Goutte\Client as GoutteClient,
Behat\Mink\Driver\SahiDriver;
$startUrl = 'http://example.com';
// init Mink and register sessions
$mink = new Mink(array(
- 'goutte1' => new Session(new GoutteDriver($startUrl)),
- 'goutte2' => new Session(new GoutteDriver($startUrl)),
- 'javascript' => new Session(new SahiDriver($startUrl, 'firefox')),
+ 'goutte1' => new Session(new GoutteDriver(GoutteClient($startUrl))),
+ 'goutte2' => new Session(new GoutteDriver(GoutteClient($startUrl))),
+ 'javascript' => new Session(new SahiDriver('firefox')),
'custom' => new Session(new MyCustomDriver($startUrl))
));
View
2  src/Behat/Mink/Compiler/PearCompiler.php
@@ -70,9 +70,9 @@ public function compile($version, $stability)
->in($this->libPath . '/vendor/alexandresalome')
->in($this->libPath . '/vendor/behat')
->in($this->libPath . '/vendor/fabpot')
- ->in($this->libPath . '/vendor/facebook')
->in($this->libPath . '/vendor/kriswallsmith')
->in($this->libPath . '/vendor/guzzle')
+ ->in($this->libPath . '/vendor/instaclick')
;
$xmlSourceFiles = '';
View
4 src/Behat/Mink/Compiler/PharCompiler.php
@@ -70,14 +70,14 @@ public function compile($version)
'vendor',
))
->in($this->libPath . '/src')
- ->in($this->libPath . '/vendor/composer')
->in($this->libPath . '/vendor/symfony')
+ ->in($this->libPath . '/vendor/composer')
->in($this->libPath . '/vendor/alexandresalome')
->in($this->libPath . '/vendor/behat')
->in($this->libPath . '/vendor/fabpot')
- ->in($this->libPath . '/vendor/facebook')
->in($this->libPath . '/vendor/kriswallsmith')
->in($this->libPath . '/vendor/guzzle')
+ ->in($this->libPath . '/vendor/instaclick')
;
foreach ($finder as $file) {
View
83 src/Behat/Mink/Driver/Goutte/Client.php
@@ -2,83 +2,28 @@
namespace Behat\Mink\Driver\Goutte;
+use Goutte\Client as BaseClient;
+
use Symfony\Component\BrowserKit\Response;
-use Goutte\Client as BaseClient;
+use Guzzle\Http\Message\Response as GuzzleResponse;
-use Guzzle\Http\Message\Response as GuzzleResponse,
- Guzzle\Http\Exception\BadResponseException,
- Guzzle\Http\Exception\CurlException;
+/*
+ * This file is part of the Behat\Mink.
+ * (c) Konstantin Kudryashov <ever.zet@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
/**
- * Goutte extension point.
+ * Client overrides to support Mink functionality.
*/
class Client extends BaseClient
{
- protected function doRequest($request)
- {
- $headers = array();
- foreach ($request->getServer() as $key => $val) {
- $key = ucfirst(strtolower(str_replace(array('_', 'HTTP-'), array('-', ''), $key)));
- if (!isset($headers[$key])) {
- $headers[$key] = $val;
- }
- }
-
- $guzzleRequest = $this->getClient()->createRequest(
- strtoupper($request->getMethod()),
- $request->getUri(),
- array_merge($this->headers, $headers),
- $request->getParameters()
- );
-
- if ($this->auth !== null) {
- $guzzleRequest->setAuth(
- $this->auth['user'],
- $this->auth['password'],
- $this->auth['type']
- );
- }
-
- foreach ($this->getCookieJar()->allRawValues($request->getUri()) as $name => $value) {
- $guzzleRequest->addCookie($name, $value);
- }
-
- if ('POST' == $request->getMethod()) {
- $postFiles = array();
- foreach ($request->getFiles() as $name => $info) {
- if (isset($info['tmp_name']) && '' !== $info['tmp_name']) {
- $postFiles[$name] = $info['tmp_name'];
- }
- }
- if (!empty($postFiles)) {
- $guzzleRequest->addPostFiles($postFiles);
- }
- }
-
- $guzzleRequest->setHeader('User-Agent', $this->server['HTTP_USER_AGENT']);
-
- $guzzleRequest->getCurlOptions()
- ->set(CURLOPT_FOLLOWLOCATION, false)
- ->set(CURLOPT_MAXREDIRS, 0)
- ->set(CURLOPT_TIMEOUT, 30);
-
- // Let BrowserKit handle redirects
- try {
- $response = $guzzleRequest->send();
- } catch (CurlException $e) {
- if (!strpos($e->getMessage(), 'redirects')) {
- throw $e;
- }
-
- $response = $e->getResponse();
- } catch (BadResponseException $e) {
- $response = $e->getResponse();
- }
-
- return $this->createResponse($response);
- }
-
+ /**
+ * Reads response meta tags to guess content-type charset.
+ */
protected function createResponse(GuzzleResponse $response)
{
$body = $response->getBody(true);
Please sign in to comment.
Something went wrong with that request. Please try again.