RouteMap: Remove check for captures (push this into regex route's dispatch)
This commit is contained in:
parent
1a49a4ac6c
commit
7a53a02c5f
|
|
@ -81,12 +81,7 @@ class RouteMap implements RouteMapInterface
|
||||||
|
|
||||||
// Try each of the routes.
|
// Try each of the routes.
|
||||||
foreach ($this->patternRoutes as $route) {
|
foreach ($this->patternRoutes as $route) {
|
||||||
if ($route->matchesRequestTarget($requestTarget, $captures)) {
|
if ($route->matchesRequestTarget($requestTarget)) {
|
||||||
if (is_array($captures)) {
|
|
||||||
foreach ($captures as $key => $value) {
|
|
||||||
$request = $request->withAttribute($key, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$route->dispatch($request, $response);
|
$route->dispatch($request, $response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
namespace WellRESTed\Test\Unit\Routing;
|
namespace WellRESTed\Test\Unit\Routing;
|
||||||
|
|
||||||
use Prophecy\Argument;
|
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\Route\RouteInterface;
|
||||||
use WellRESTed\Routing\RouteMap;
|
use WellRESTed\Routing\RouteMap;
|
||||||
|
|
||||||
|
|
@ -31,7 +34,6 @@ class RouteMapTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->route->getMethodMap()->willReturn($this->methodMap->reveal());
|
$this->route->getMethodMap()->willReturn($this->methodMap->reveal());
|
||||||
$this->route->getType()->willReturn(RouteInterface::TYPE_STATIC);
|
$this->route->getType()->willReturn(RouteInterface::TYPE_STATIC);
|
||||||
$this->route->getTarget()->willReturn("/");
|
$this->route->getTarget()->willReturn("/");
|
||||||
$this->route->matchesRequestTarget(Argument::cetera())->willReturn(true);
|
|
||||||
|
|
||||||
$this->factory = $this->prophesize('WellRESTed\Routing\Route\RouteFactory');
|
$this->factory = $this->prophesize('WellRESTed\Routing\Route\RouteFactory');
|
||||||
$this->factory->create(Argument::any())->willReturn($this->route->reveal());
|
$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->request->getRequestTarget()->willReturn($target);
|
||||||
$this->route->getTarget()->willReturn($target);
|
$this->route->getTarget()->willReturn($target);
|
||||||
$this->route->getType()->willReturn(RouteInterface::TYPE_PATTERN);
|
$this->route->getType()->willReturn(RouteInterface::TYPE_PATTERN);
|
||||||
|
$this->route->matchesRequestTarget(Argument::cetera())->willReturn(true);
|
||||||
|
|
||||||
$this->routeMap->add("GET", $target, "middleware");
|
$this->routeMap->add("GET", $target, "middleware");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue