public function RouteCollectionTest::testGet

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php, line 210

Class

RouteCollectionTest

Namespace

Symfony\Component\Routing\Tests

Code

public function testGet() {
  $collection1 = new RouteCollection();
  $collection1
    ->add('a', $a = new Route('/a'));
  $collection2 = new RouteCollection();
  $collection2
    ->add('b', $b = new Route('/b'));
  $collection1
    ->addCollection($collection2);
  $collection1
    ->add('$péß^a|', $c = new Route('/special'));
  $this
    ->assertSame($b, $collection1
    ->get('b'), '->get() returns correct route in child collection');
  $this
    ->assertSame($c, $collection1
    ->get('$péß^a|'), '->get() can handle special characters');
  $this
    ->assertNull($collection2
    ->get('a'), '->get() does not return the route defined in parent collection');
  $this
    ->assertNull($collection1
    ->get('non-existent'), '->get() returns null when route does not exist');
  $this
    ->assertNull($collection1
    ->get(0), '->get() does not disclose internal child RouteCollection');
}