public function testCreate() { $endPoint = new Point\ControllerDynamicAction(['controller' => 'DemoController']); $route = new Route('demo/{:id}/', $endPoint, ['id' => '\\d+'], Route::ONLY_XHR, ['get']); self::assertTrue($route->getPoint() instanceof Point\IPoint); self::assertEquals('demo/{:id}/', $route->getPath()); self::assertCount(1, $route->getMethods()); self::assertEquals(['GET'], $route->getMethods()); self::assertCount(1, $route->getRestrictions()); self::assertEquals(['id' => '\\d+'], $route->getRestrictions()); self::assertEquals(Route::ONLY_XHR, $route->typeRequest); }
/** * @param string $method * @param Route $route * @return bool */ protected function isAllowHttpMethod($method, Route $route) { return count($route->getMethods()) === 0 ? true : in_array(strtoupper($method), $route->getMethods(), true); }