Skip to content

Commit

Permalink
complete tests for guzzle 6
Browse files Browse the repository at this point in the history
  • Loading branch information
josiasmontag committed Mar 9, 2016
1 parent bba1505 commit 21886cb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tests/ApiTest.php
Expand Up @@ -4,7 +4,10 @@
use CloudConvert\Api;
use CloudConvert\Exceptions\ApiTemporaryUnavailableException;
use GuzzleHttp\Client;
use GuzzleHttp\Subscriber\Mock;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;


/**
* Tests of Api class
Expand Down Expand Up @@ -105,11 +108,16 @@ public function testIfProcessCreationWithInvalidFormatThrowsTheRightException()
*/
public function testIfApiTemporaryUnavailableExceptionIsThrown()
{
$client = new Client();
$mock = new Mock([
"HTTP/1.1 503 Service Unavailable\r\nRetry-After: 30\r\nContent-Type: application/json; charset=utf-8\r\n\r\n{\"message\":\"API unavailable. Please try later.\"}"

$mock = new MockHandler([
new Response(503, ['Retry-After' => 30, 'Content-Type' => 'application/json; charset=utf-8'], "{\"message\":\"API unavailable. Please try later.\"}"),
]);
$client->getEmitter()->attach($mock);

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



$api = new Api($this->api_key, $client);
$invoker = self::getPrivateMethod('rawCall');

Expand Down

0 comments on commit 21886cb

Please sign in to comment.