/** * 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; }
/** * @test */ public function shouldBuildRequestObject() { $request = new RouteRequest(); $this->assertEquals('GET', $request->getRequestMethod()); $this->assertEquals('/route/test/666', $request->getRequestUrl()); $this->assertEquals('http', $request->getProtocol()); $this->assertEquals([], $request->getQueryParams()); $this->assertFalse($request->isAjax()); }