Skip to content

Commit 437a2e1

Browse files
committed
Improve tests
1 parent f68ad2c commit 437a2e1

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

spec/BatchResultSpec.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,23 @@ function it_is_immutable(RequestInterface $request, ResponseInterface $response)
2222
$new->getResponses()->shouldReturn([$response]);
2323
}
2424

25+
function it_has_a_responses(RequestInterface $request, ResponseInterface $response)
26+
{
27+
$new = $this->addResponse($request, $response);
28+
29+
$this->hasResponses()->shouldReturn(false);
30+
$this->getResponses()->shouldReturn([]);
31+
$new->hasResponses()->shouldReturn(true);
32+
$new->getResponses()->shouldReturn([$response]);
33+
}
34+
2535
function it_has_a_response_for_a_request(RequestInterface $request, ResponseInterface $response)
2636
{
2737
$new = $this->addResponse($request, $response);
2838

2939
$this->getResponseFor($request)->shouldReturn(null);
30-
$this->hasResponses()->shouldReturn(false);
3140
$this->hasResponseFor($request)->shouldReturn(false);
32-
$this->getResponses()->shouldReturn([]);
3341
$new->getResponseFor($request)->shouldReturn($response);
34-
$new->hasResponses()->shouldReturn(true);
3542
$new->hasResponseFor($request)->shouldReturn(true);
36-
$new->getResponses()->shouldReturn([$response]);
3743
}
3844
}

spec/Exception/BatchExceptionSpec.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,32 @@ function it_has_a_result()
3030
function it_has_an_exception_for_a_request(RequestInterface $request, Exception $exception)
3131
{
3232
$this->getExceptionFor($request)->shouldReturn(null);
33-
$this->hasExceptions()->shouldReturn(false);
3433
$this->hasExceptionFor($request)->shouldReturn(false);
35-
$this->getExceptions()->shouldReturn([]);
36-
$this->isSuccessful($request)->shouldReturn(false);
37-
$this->isFailed($request)->shouldReturn(false);
3834

3935
$this->addException($request, $exception);
4036

4137
$this->getExceptionFor($request)->shouldReturn($exception);
42-
$this->hasExceptions()->shouldReturn(true);
4338
$this->hasExceptionFor($request)->shouldReturn(true);
39+
}
40+
41+
function it_has_exceptions(RequestInterface $request, Exception $exception)
42+
{
43+
$this->hasExceptions()->shouldReturn(false);
44+
$this->getExceptions()->shouldReturn([]);
45+
46+
$this->addException($request, $exception);
47+
48+
$this->hasExceptions()->shouldReturn(true);
4449
$this->getExceptions()->shouldReturn([$exception]);
50+
}
51+
52+
function it_checks_if_a_request_failed(RequestInterface $request, Exception $exception)
53+
{
54+
$this->isSuccessful($request)->shouldReturn(false);
55+
$this->isFailed($request)->shouldReturn(false);
56+
57+
$this->addException($request, $exception);
58+
4559
$this->isSuccessful($request)->shouldReturn(false);
4660
$this->isFailed($request)->shouldReturn(true);
4761
}

0 commit comments

Comments
 (0)