public function testUniqueRouteWithGivenName() {
$collection1 = new RouteCollection();
$collection1
->add('foo', new Route('/old'));
$collection2 = new RouteCollection();
$collection3 = new RouteCollection();
$collection3
->add('foo', $new = new Route('/new'));
$collection1
->addCollection($collection2);
$collection2
->addCollection($collection3);
$collection1
->add('stay', new Route('/stay'));
$iterator = $collection1
->getIterator();
$this
->assertSame($new, $collection1
->get('foo'), '->get() returns new route that overrode previous one');
// size of 2 because collection1 contains collection2 and /stay but not /old anymore
$this
->assertCount(2, $iterator, '->addCollection() removes previous routes when adding new routes with the same name');
$this
->assertInstanceOf('Symfony\\Component\\Routing\\RouteCollection', $iterator
->current(), '->getIterator returns both Routes and RouteCollections');
$iterator
->next();
$this
->assertInstanceOf('Symfony\\Component\\Routing\\Route', $iterator
->current(), '->getIterator returns both Routes and RouteCollections');
}