Permalink
Browse files

refactor interator test that was still assuming a tree

  • Loading branch information...
1 parent 2760844 commit bc216872551b04e7b06764b19da027c622151e04 @Tobion Tobion committed Dec 7, 2012
Showing with 7 additions and 17 deletions.
  1. +7 −17 Tests/RouteCollectionTest.php
@@ -54,16 +54,19 @@ public function testDeepOverriddenRoute()
$this->assertEquals('/foo2', $collection->get('foo')->getPath());
}
- public function testIteratorWithOverriddenRoutes()
+ public function testIterator()
{
$collection = new RouteCollection();
$collection->add('foo', new Route('/foo'));
$collection1 = new RouteCollection();
- $collection1->add('foo', new Route('/foo1'));
+ $collection1->add('bar', $bar = new Route('/bar'));
+ $collection1->add('foo', $foo = new Route('/foo-new'));
$collection->addCollection($collection1);
+ $collection->add('last', $last = new Route('/last'));
- $this->assertEquals('/foo1', $this->getFirstNamedRoute($collection, 'foo')->getPath());
+ $this->assertInstanceOf('\ArrayIterator', $collection->getIterator());
+ $this->assertSame(array('bar' => $bar, 'foo' => $foo, 'last' => $last), $collection->getIterator()->getArrayCopy());
}
public function testCount()
@@ -72,25 +75,12 @@ public function testCount()
$collection->add('foo', new Route('/foo'));
$collection1 = new RouteCollection();
- $collection1->add('foo1', new Route('/foo1'));
+ $collection1->add('bar', new Route('/bar'));
$collection->addCollection($collection1);
$this->assertCount(2, $collection);
}
- protected function getFirstNamedRoute(RouteCollection $routeCollection, $name)
- {
- foreach ($routeCollection as $key => $route) {
- if ($route instanceof RouteCollection) {
- return $this->getFirstNamedRoute($route, $name);
- }
-
- if ($name === $key) {
- return $route;
- }
- }
- }
-
public function testAddCollection()
{
if (!class_exists('Symfony\Component\Config\Resource\FileResource')) {

0 comments on commit bc21687

Please sign in to comment.