Skip to content

Commit 9e2bcb5

Browse files
committed
refactor interator test that was still assuming a tree
1 parent ceb9ab4 commit 9e2bcb5

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/Symfony/Component/Routing/Tests/RouteCollectionTest.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,19 @@ public function testDeepOverriddenRoute()
5454
$this->assertEquals('/foo2', $collection->get('foo')->getPath());
5555
}
5656

57-
public function testIteratorWithOverriddenRoutes()
57+
public function testIterator()
5858
{
5959
$collection = new RouteCollection();
6060
$collection->add('foo', new Route('/foo'));
6161

6262
$collection1 = new RouteCollection();
63-
$collection1->add('foo', new Route('/foo1'));
63+
$collection1->add('bar', $bar = new Route('/bar'));
64+
$collection1->add('foo', $foo = new Route('/foo-new'));
6465
$collection->addCollection($collection1);
66+
$collection->add('last', $last = new Route('/last'));
6567

66-
$this->assertEquals('/foo1', $this->getFirstNamedRoute($collection, 'foo')->getPath());
68+
$this->assertInstanceOf('\ArrayIterator', $collection->getIterator());
69+
$this->assertSame(array('bar' => $bar, 'foo' => $foo, 'last' => $last), $collection->getIterator()->getArrayCopy());
6770
}
6871

6972
public function testCount()
@@ -72,25 +75,12 @@ public function testCount()
7275
$collection->add('foo', new Route('/foo'));
7376

7477
$collection1 = new RouteCollection();
75-
$collection1->add('foo1', new Route('/foo1'));
78+
$collection1->add('bar', new Route('/bar'));
7679
$collection->addCollection($collection1);
7780

7881
$this->assertCount(2, $collection);
7982
}
8083

81-
protected function getFirstNamedRoute(RouteCollection $routeCollection, $name)
82-
{
83-
foreach ($routeCollection as $key => $route) {
84-
if ($route instanceof RouteCollection) {
85-
return $this->getFirstNamedRoute($route, $name);
86-
}
87-
88-
if ($name === $key) {
89-
return $route;
90-
}
91-
}
92-
}
93-
9484
public function testAddCollection()
9585
{
9686
if (!class_exists('Symfony\Component\Config\Resource\FileResource')) {

0 commit comments

Comments
 (0)