From 7a53a02c5f800ad0d351ad6cbc6cc78d57f70902 Mon Sep 17 00:00:00 2001 From: PJ Dietz Date: Thu, 7 May 2015 22:49:39 -0400 Subject: [PATCH] RouteMap: Remove check for captures (push this into regex route's dispatch) --- src/Routing/RouteMap.php | 7 +------ test/tests/unit/Routing/RouteMapTest.php | 5 ++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Routing/RouteMap.php b/src/Routing/RouteMap.php index fb15067..9636835 100644 --- a/src/Routing/RouteMap.php +++ b/src/Routing/RouteMap.php @@ -81,12 +81,7 @@ class RouteMap implements RouteMapInterface // Try each of the routes. foreach ($this->patternRoutes as $route) { - if ($route->matchesRequestTarget($requestTarget, $captures)) { - if (is_array($captures)) { - foreach ($captures as $key => $value) { - $request = $request->withAttribute($key, $value); - } - } + if ($route->matchesRequestTarget($requestTarget)) { $route->dispatch($request, $response); return; } diff --git a/test/tests/unit/Routing/RouteMapTest.php b/test/tests/unit/Routing/RouteMapTest.php index 3358e01..07a0891 100644 --- a/test/tests/unit/Routing/RouteMapTest.php +++ b/test/tests/unit/Routing/RouteMapTest.php @@ -3,6 +3,9 @@ namespace WellRESTed\Test\Unit\Routing; use Prophecy\Argument; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use WellRESTed\Routing\MethodMapInterface; use WellRESTed\Routing\Route\RouteInterface; use WellRESTed\Routing\RouteMap; @@ -31,7 +34,6 @@ class RouteMapTest extends \PHPUnit_Framework_TestCase $this->route->getMethodMap()->willReturn($this->methodMap->reveal()); $this->route->getType()->willReturn(RouteInterface::TYPE_STATIC); $this->route->getTarget()->willReturn("/"); - $this->route->matchesRequestTarget(Argument::cetera())->willReturn(true); $this->factory = $this->prophesize('WellRESTed\Routing\Route\RouteFactory'); $this->factory->create(Argument::any())->willReturn($this->route->reveal()); @@ -186,6 +188,7 @@ class RouteMapTest extends \PHPUnit_Framework_TestCase $this->request->getRequestTarget()->willReturn($target); $this->route->getTarget()->willReturn($target); $this->route->getType()->willReturn(RouteInterface::TYPE_PATTERN); + $this->route->matchesRequestTarget(Argument::cetera())->willReturn(true); $this->routeMap->add("GET", $target, "middleware");