mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Covered new use case on NotFoundRedirectHandlerTest
This commit is contained in:
parent
1bafe54a75
commit
850259290a
1 changed files with 20 additions and 1 deletions
|
@ -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…
Add table
Reference in a new issue