From 5f0a8b885a53057e8e7dce6646e8a9314f3495d8 Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Sat, 24 Oct 2015 20:34:26 +0200 Subject: [PATCH 1/2] Add spec for sending request with underlying client --- spec/HttpMethodsClientSpec.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/HttpMethodsClientSpec.php b/spec/HttpMethodsClientSpec.php index da95c5f..d30d101 100644 --- a/spec/HttpMethodsClientSpec.php +++ b/spec/HttpMethodsClientSpec.php @@ -2,10 +2,13 @@ namespace spec\Http\Client\Utils; +use Http\Client\BatchResult; use Http\Client\HttpClient; use Http\Client\Utils\HttpMethodsClient; use Http\Message\MessageFactory; use PhpSpec\ObjectBehavior; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; class HttpMethodsClientSpec extends ObjectBehavior { @@ -74,6 +77,22 @@ function it_sends_a_options_request() $this->options($data['uri'], $data['headers'], $data['body'])->shouldReturn(true); } + + function it_should_send_request_with_underlying_client(HttpClient $client, MessageFactory $messageFactory, RequestInterface $request, ResponseInterface $response) + { + $client->sendRequest($request)->shouldBeCalled()->willReturn($response); + + $this->beConstructedWith($client, $messageFactory); + $this->sendRequest($request)->shouldReturn($response); + } + + function it_should_send_requests_with_underlying_client(HttpClient $client, MessageFactory $messageFactory, RequestInterface $request1, RequestInterface $request2, BatchResult $batchResult) + { + $client->sendRequests([$request1, $request2])->shouldBeCalled()->willReturn($batchResult); + + $this->beConstructedWith($client, $messageFactory); + $this->sendRequests([$request1, $request2])->shouldReturn($batchResult); + } } class HttpMethodsClientStub extends HttpMethodsClient From 88f5fe953c66631270ad1482484d955647800379 Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Sat, 24 Oct 2015 20:50:49 +0200 Subject: [PATCH 2/2] Follow naming convention --- spec/HttpMethodsClientSpec.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/HttpMethodsClientSpec.php b/spec/HttpMethodsClientSpec.php index d30d101..1c9e059 100644 --- a/spec/HttpMethodsClientSpec.php +++ b/spec/HttpMethodsClientSpec.php @@ -78,7 +78,7 @@ function it_sends_a_options_request() $this->options($data['uri'], $data['headers'], $data['body'])->shouldReturn(true); } - function it_should_send_request_with_underlying_client(HttpClient $client, MessageFactory $messageFactory, RequestInterface $request, ResponseInterface $response) + function it_sends_request_with_underlying_client(HttpClient $client, MessageFactory $messageFactory, RequestInterface $request, ResponseInterface $response) { $client->sendRequest($request)->shouldBeCalled()->willReturn($response); @@ -86,7 +86,7 @@ function it_should_send_request_with_underlying_client(HttpClient $client, Messa $this->sendRequest($request)->shouldReturn($response); } - function it_should_send_requests_with_underlying_client(HttpClient $client, MessageFactory $messageFactory, RequestInterface $request1, RequestInterface $request2, BatchResult $batchResult) + function it_sends_requests_with_underlying_client(HttpClient $client, MessageFactory $messageFactory, RequestInterface $request1, RequestInterface $request2, BatchResult $batchResult) { $client->sendRequests([$request1, $request2])->shouldBeCalled()->willReturn($batchResult);