[Routing] fixed previous merge

This commit is contained in:
Fabien Potencier 2012-06-25 13:50:03 +02:00
parent db9a8c1e4e
commit c67cf8b56b
2 changed files with 7 additions and 2 deletions

View File

@ -95,7 +95,12 @@ class RouteCollection implements \IteratorAggregate, \Countable
*/
public function count()
{
return count($this->routes->all());
$count = 0;
foreach ($this->routes as $route) {
$count += $route instanceof RouteCollection ? count($route) : 1;
}
return $count;
}
/**

View File

@ -83,7 +83,7 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase
$collection1 = new RouteCollection();
$collection->addCollection($collection1);
$collection1->add('foo', new Route('/foo1'));
$collection1->add('foo1', new Route('/foo1'));
$this->assertCount(2, $collection);
}