/** * @test */ public function shouldCreateCorrectRouteObject() { $route = new Route('GET /test/page.html', 'A->index'); $this->assertEquals('|^/test/page.html$|', $route->getPattern()); $this->assertEquals(['GET'], $route->getMethods()); $this->assertEquals('sync', $route->getType()); $this->assertEquals('/test/page.html', $route->getUrl()); }
/** * Match if current Route match to the request url, method and type * * @param Route $route * @return bool */ private function match(Route $route) { if (!in_array($this->routeRequest->getRequestMethod(), $route->getMethods())) { return false; } if (!$this->routeRequest->isAjax() && 'ajax' == $route->getType()) { return false; } if (!preg_match($route->getPattern(), $this->routeRequest->getRequestUrl())) { return false; } return true; }