/** * @covers AltoRouter::map */ public function testMapWithName() { $method = 'POST'; $route = '/[:controller]/[:action]'; $target = function () { }; $name = 'myroute'; $this->router->map($method, $route, $target, $name); $routes = $this->router->getRoutes(); $this->assertEquals(array($method, $route, $target, $name), $routes[0]); $named_routes = $this->router->getNamedRoutes(); $this->assertEquals($route, $named_routes[$name]); try { $this->router->map($method, $route, $target, $name); $this->fail('Should not be able to add existing named route'); } catch (Exception $e) { $this->assertEquals("Can not redeclare route '{$name}'", $e->getMessage()); } }