public function testCfarExceptionisThrown() { $route = $this->route->path('/users/10/adelowo')->attributes(["10", "adelowo"])->handler(UnKnownController::class)->extras(["listener" => "showUser"]); //This is discarded as of >=1.2 and the `indexAction` method would be invoked. try { $cfar = $this->getCfar($route); $cfar->dispatch(); } catch (CfarException $e) { $this->assertStringStartsWith("Invalid route declaration", $e->getMessage()); $this->assertEquals("indexAction", $cfar->getMethod()); } }
public static function singleRoute($controller, string $path = null, string $name = null) { $route = new Route(); $route->handler($controller); if ($path !== null) { $route->path($path); } if ($name !== null) { $route->name($name); } return new static([$route]); }
private function prepareRoute(Route $route, string $path) : Route { if (!$route->allows) { $route->allows('GET'); } $route->path($path); return $route; }