Skip to content

Commit

Permalink
Fix Guzzle 5 mock, fixes #22
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Jan 10, 2015
1 parent 8192ad2 commit 915edaf
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/Proxy/Adapter/Guzzle/GuzzleAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
namespace Proxy\Proxy\Adapter\Guzzle;

use GuzzleHttp\Subscriber\Mock;
use GuzzleHttp\Client;
use GuzzleHttp\Message\Response;
use GuzzleHttp\Stream\Stream;
use GuzzleHttp\Ring\Client\MockHandler;
use Proxy\Adapter\Guzzle\GuzzleAdapter;
use Symfony\Component\HttpFoundation\Request;

Expand Down Expand Up @@ -32,10 +32,15 @@ class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
$mock = new Mock([$this->createResponse()]);
$response = $this->createResponse();

$client = new Client;
$client->getEmitter()->attach($mock);
$mock = new MockHandler([
'status' => $response->getStatusCode(),
'headers' => $response->getHeaders(),
'body' => $response->getBody(),
]);

$client = new Client(['handler' => $mock]);

$this->adapter = new GuzzleAdapter($client);
}
Expand Down Expand Up @@ -109,7 +114,7 @@ public function adapter_sends_request()
private function sendRequest()
{
$request = Request::createFromGlobals();
return $this->adapter->send($request, '/');
return $this->adapter->send($request, 'http://www.example.com');
}

/**
Expand All @@ -121,5 +126,4 @@ private function createResponse()
return new Response($this->status, $this->headers, $body);
}


}

0 comments on commit 915edaf

Please sign in to comment.