mirror of
https://github.com/shlinkio/shlink.git
synced 2025-01-24 07:16:44 -06:00
Covered new use case on NotFoundRedirectHandlerTest
This commit is contained in:
parent
1bafe54a75
commit
850259290a
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user