You are here

public function RouteCollectionTest::testUniqueRouteWithGivenName in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/routing/Tests/RouteCollectionTest.php \Symfony\Component\Routing\Tests\RouteCollectionTest::testUniqueRouteWithGivenName()

File

vendor/symfony/routing/Tests/RouteCollectionTest.php, line 186

Class

RouteCollectionTest

Namespace

Symfony\Component\Routing\Tests

Code

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'));
  $collection2
    ->addCollection($collection3);
  $collection1
    ->addCollection($collection2);
  $this
    ->assertSame($new, $collection1
    ->get('foo'), '->get() returns new route that overrode previous one');

  // size of 1 because collection1 contains /new but not /old anymore
  $this
    ->assertCount(1, $collection1
    ->getIterator(), '->addCollection() removes previous routes when adding new routes with the same name');
}