Skip to content

Commit

Permalink
Forward port test from v2 series regarding path truncation
Browse files Browse the repository at this point in the history
In zendframework#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.
  • Loading branch information
weierophinney committed Apr 16, 2018
1 parent c390cd4 commit 26afcbd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/Middleware/PathMiddlewareDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 26afcbd

Please sign in to comment.