From 26afcbd68b29e869a271acb3f01e6d7bb104388f Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 16 Apr 2018 12:16:12 -0500 Subject: [PATCH] Forward port test from v2 series regarding path truncation In #168, we received a report indicating that path matching within `PathMiddlewareDecorator` fails if the path is the same, but using a different case. This patch forward-ports the test from patch 44f8885 to the 3.0 series; the 3.0 series was already working correctly. --- .../PathMiddlewareDecoratorTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/Middleware/PathMiddlewareDecoratorTest.php b/test/Middleware/PathMiddlewareDecoratorTest.php index bc580dd..3219c29 100644 --- a/test/Middleware/PathMiddlewareDecoratorTest.php +++ b/test/Middleware/PathMiddlewareDecoratorTest.php @@ -457,4 +457,30 @@ public function testUpdatesInPathInsideNestedMiddlewareAreRespected() $middleware->process($request, $handler->reveal()); } + + public function testProcessesMatchedPathsWithoutCaseSensitivity() + { + $finalHandler = $this->prophesize(RequestHandlerInterface::class); + $finalHandler->handle(Argument::any())->willReturn(new Response()); + + // Note that the path requested is ALL CAPS: + $request = new ServerRequest([], [], 'http://local.example.com/MYADMIN', 'GET', 'php://memory'); + + $middleware = $this->prophesize(MiddlewareInterface::class); + $middleware + ->process( + Argument::that(function (ServerRequestInterface $req) { + Assert::assertSame('', $req->getUri()->getPath()); + + return true; + }), + Argument::any() + ) + ->willReturn(new Response()) + ->shouldBeCalledTimes(1); + + // Note that the path to match is lowercase: + $decorator = new PathMiddlewareDecorator('/myadmin', $middleware->reveal()); + $decorator->process($request, $finalHandler->reveal()); + } }