/** * Named route should have unique name */ public function testAddNamedRouteWithDuplicateKey() { $this->setExpectedException('RuntimeException'); $router = new \Slim\Router(); $route = new \Slim\Route('/foo', function () { }); $router->addNamedRoute('foo', $route); $router->addNamedRoute('foo', $route); }
/** * Test external iterator for Router's named routes * * Pre-conditions: * Slim app instantiated; * Named routes created; * * Post-conditions: * Array iterator returned for named routes; */ public function testGetNamedRoutes() { $router = new \Slim\Router(); $router->setResourceUri($this->req->getResourceUri()); $route1 = $router->map('/foo', function () { })->via('GET'); $route2 = $router->map('/bar', function () { })->via('POST'); $router->addNamedRoute('foo', $route1); $router->addNamedRoute('bar', $route2); $namedRoutesIterator = $router->getNamedRoutes(); $this->assertInstanceOf('ArrayIterator', $namedRoutesIterator); $this->assertEquals(2, $namedRoutesIterator->count()); }