From ceb2ba07640bb3d362bd4c480e26897302a2b501 Mon Sep 17 00:00:00 2001 From: Mickael Vieira Date: Sun, 2 Oct 2016 20:10:36 +0100 Subject: [PATCH] Add missing spec --- spec/Provider/MailChimpSpec.php | 41 +++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/spec/Provider/MailChimpSpec.php b/spec/Provider/MailChimpSpec.php index 78a36be..266b8b0 100644 --- a/spec/Provider/MailChimpSpec.php +++ b/spec/Provider/MailChimpSpec.php @@ -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'); @@ -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');