diff --git a/spec/ClientSpec.php b/spec/ClientSpec.php index dbead07..40e81d2 100644 --- a/spec/ClientSpec.php +++ b/spec/ClientSpec.php @@ -84,4 +84,26 @@ function it_returns_false_when_there_is_no_last_request() { $this->getLastRequest()->shouldReturn(false); } + + function it_reset( + ResponseFactory $responseFactory, + RequestInterface $request, + ResponseInterface $response, + ResponseInterface $newResponse + ) { + $this->addResponse($response); + $this->setDefaultResponse($response); + $this->addException(new \Exception()); + $this->setDefaultException(new \Exception()); + + $responseFactory->createResponse()->willReturn($newResponse); + + $this->reset(); + + $this->sendRequest($request)->shouldReturn($newResponse); + + $this->reset(); + + $this->getRequests()->shouldReturn([]); + } } diff --git a/src/Client.php b/src/Client.php index 998517d..68a7ae3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -135,4 +135,13 @@ public function getLastRequest() { return end($this->requests); } + + public function reset() + { + $this->responses = []; + $this->exceptions = []; + $this->requests = []; + $this->setDefaultException(); + $this->setDefaultResponse(); + } }