Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
qa: Move expectException() calls to immediately prior to exceptiona…
Browse files Browse the repository at this point in the history
…l statements

Ensures that the expected exception occurs _when_ we expect it.
  • Loading branch information
weierophinney committed Jun 12, 2019
1 parent e641576 commit e227feb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/NextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ public function testMiddlewareReturningResponseShortCircuitsProcess()

public function testNextHandlerCannotBeInvokedTwice()
{
$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);

$fallbackHandler = $this->prophesize(RequestHandlerInterface::class);
$fallbackHandler
->handle(Argument::any())
Expand All @@ -231,13 +229,13 @@ public function testNextHandlerCannotBeInvokedTwice()

$next = new Next($this->queue, $fallbackHandler->reveal());
$next->handle($this->request);

$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);
$next->handle($this->request);
}

public function testSecondInvocationAttemptDoesNotInvokeFinalHandler()
{
$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);

$fallBackHandler = $this->prophesize(RequestHandlerInterface::class);
$fallBackHandler
->handle(Argument::any())
Expand All @@ -248,13 +246,13 @@ public function testSecondInvocationAttemptDoesNotInvokeFinalHandler()

$next = new Next($this->queue, $fallBackHandler->reveal());
$next->handle($this->request);

$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);
$next->handle($this->request);
}

public function testSecondInvocationAttemptDoesNotInvokeMiddleware()
{
$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);

$fallBackHandler = $this->prophesize(RequestHandlerInterface::class);
$fallBackHandler
->handle(Argument::any())
Expand All @@ -275,13 +273,13 @@ public function testSecondInvocationAttemptDoesNotInvokeMiddleware()

$next = new Next($this->queue, $fallBackHandler->reveal());
$next->handle($this->request);

$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);
$next->handle($this->request);
}

public function testShortCircuitingMiddlewareDoesNotEnableSecondInvocation()
{
$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);

$fallBackHandler = $this->prophesize(RequestHandlerInterface::class);
$fallBackHandler
->handle(Argument::any())
Expand All @@ -296,13 +294,13 @@ public function testShortCircuitingMiddlewareDoesNotEnableSecondInvocation()

$next = new Next($this->queue, $fallBackHandler->reveal());
$next->handle($this->request);

$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);
$next->handle($this->request);
}

public function testSecondInvocationAttemptWithEmptyQueueDoesNotInvokeFinalHandler()
{
$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);

$fallBackHandler = $this->prophesize(RequestHandlerInterface::class);
$fallBackHandler
->handle(Argument::any())
Expand All @@ -312,6 +310,8 @@ public function testSecondInvocationAttemptWithEmptyQueueDoesNotInvokeFinalHandl
$next = new Next($this->queue, $fallBackHandler->reveal());

$next->handle($this->request);

$this->expectException(MiddlewarePipeNextHandlerAlreadyCalledException::class);
$next->handle($this->request);
}
}

0 comments on commit e227feb

Please sign in to comment.