Skip to content

Commit

Permalink
Add missing spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelvieira committed Oct 2, 2016
1 parent 8f6eaa0 commit ceb2ba0
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions spec/Provider/MailChimpSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,44 @@ function it_retrieves_the_resource_owner()
$owner->getLoginUrl()->shouldReturn('https://login.mailchimp.com');
}

function it_should_throw_an_exception_when_the_api_return_an_response_containing_a_client_error()
function it_should_not_throw_an_exception_when_the_api_does_not_return_an_response_containing_a_client_error()
{
$fakeClient = (new Prophet())->prophesize('GuzzleHttp\ClientInterface');

$this->beConstructedWith([], ['httpClient' => $fakeClient]);

$request = (new Prophet())->prophesize('Psr\Http\Message\RequestInterface');
$response = (new Prophet())->prophesize('Psr\Http\Message\ResponseInterface');
$response->getHeader('content-type')->willReturn('application/json');

$body = '
{
"apps": [
{
"id": 248682284215,
"name": "MailChimp for Shopify",
"description": "MailChimp for Shopify is a free application that connects your Shopify store with your MailChimp account."
}
]
}
';

$response->getBody()->willReturn($body);

$fakeClient->send($request)->willReturn($response);

$this->getResponse($request)->shouldReturn([
'apps' => [
[
"id" => 248682284215,
"name" => "MailChimp for Shopify",
"description" => "MailChimp for Shopify is a free application that connects your Shopify store with your MailChimp account."
]
]
]);
}

function it_should_throw_an_exception_when_the_api_returns_an_response_containing_a_client_error()
{
$fakeClient = (new Prophet())->prophesize('GuzzleHttp\ClientInterface');

Expand All @@ -131,7 +168,7 @@ function it_should_throw_an_exception_when_the_api_return_an_response_containing
$this->shouldThrow(new IdentityProviderException($message, 405, json_decode($body, true)))->during('getResponse', [$request]);
}

function it_should_throw_an_exception_when_the_api_return_an_response_containing_a_server_error()
function it_should_throw_an_exception_when_the_api_returns_an_response_containing_a_server_error()
{
$fakeClient = (new Prophet())->prophesize('GuzzleHttp\ClientInterface');

Expand Down

0 comments on commit ceb2ba0

Please sign in to comment.