From f04162c1b566b15e16bbaadda24e87603ed68a18 Mon Sep 17 00:00:00 2001 From: Alan Poulain Date: Tue, 23 Mar 2021 10:46:53 +0100 Subject: [PATCH] test(router): match duplicated base URL --- tests/Bridge/Symfony/Routing/RouterTest.php | 30 ++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/Bridge/Symfony/Routing/RouterTest.php b/tests/Bridge/Symfony/Routing/RouterTest.php index 69318e33617..52dc0d2e613 100644 --- a/tests/Bridge/Symfony/Routing/RouterTest.php +++ b/tests/Bridge/Symfony/Routing/RouterTest.php @@ -96,7 +96,7 @@ public function testMatch() $this->assertEquals(['bar'], $router->match('/app_dev.php/foo')); } - public function testWithinvalidContext() + public function testMatchWithInvalidContext() { $this->expectException(RoutingExceptionInterface::class); $this->expectExceptionMessage('Invalid request context.'); @@ -108,4 +108,32 @@ public function testWithinvalidContext() $router = new Router($mockedRouter->reveal()); $router->match('28-01-2018 10:10'); } + + public function testMatchDuplicatedBaseUrl() + { + $context = new RequestContext('/app', 'GET', 'localhost', 'https'); + + $mockedRouter = $this->prophesize(RouterInterface::class); + $mockedRouter->getContext()->willReturn($context); + $mockedRouter->setContext(Argument::type(RequestContext::class))->willReturn(); + $mockedRouter->match('/api/app_crm/resource')->willReturn(['bar']); + + $router = new Router($mockedRouter->reveal()); + + $this->assertEquals(['bar'], $router->match('/app/api/app_crm/resource')); + } + + public function testMatchEmptyBaseUrl() + { + $context = new RequestContext('', 'GET', 'localhost', 'https'); + + $mockedRouter = $this->prophesize(RouterInterface::class); + $mockedRouter->getContext()->willReturn($context); + $mockedRouter->setContext(Argument::type(RequestContext::class))->willReturn(); + $mockedRouter->match('/foo')->willReturn(['bar']); + + $router = new Router($mockedRouter->reveal()); + + $this->assertEquals(['bar'], $router->match('/foo')); + } }