From 850259290aef8de687220be9dc0663a8a1d16cd0 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 23 Nov 2019 10:28:58 +0100 Subject: [PATCH] Covered new use case on NotFoundRedirectHandlerTest --- .../NotFoundRedirectHandlerTest.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php b/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php index d2776179..b7796e61 100644 --- a/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php +++ b/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php @@ -42,10 +42,14 @@ class NotFoundRedirectHandlerTest extends TestCase $this->redirectOptions->regular404 = 'regular404'; $this->redirectOptions->baseUrl = 'baseUrl'; - $resp = $this->middleware->process($request, $this->prophesize(RequestHandlerInterface::class)->reveal()); + $next = $this->prophesize(RequestHandlerInterface::class); + $handle = $next->handle($request)->willReturn(new Response()); + + $resp = $this->middleware->process($request, $next->reveal()); $this->assertInstanceOf(Response\RedirectResponse::class, $resp); $this->assertEquals($expectedRedirectTo, $resp->getHeaderLine('Location')); + $handle->shouldNotHaveBeenCalled(); } public function provideRedirects(): iterable @@ -79,4 +83,19 @@ class NotFoundRedirectHandlerTest extends TestCase 'invalidShortUrl', ]; } + + /** @test */ + public function nextMiddlewareIsInvokedWhenNotRedirectNeedsToOccur(): void + { + $req = ServerRequestFactory::fromGlobals(); + $resp = new Response(); + + $next = $this->prophesize(RequestHandlerInterface::class); + $handle = $next->handle($req)->willReturn($resp); + + $result = $this->middleware->process($req, $next->reveal()); + + $this->assertSame($resp, $result); + $handle->shouldHaveBeenCalledOnce(); + } }