public function LazyRouteCollectionTest::testGetName in Drupal 10
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php \Drupal\Tests\Core\Routing\LazyRouteCollectionTest::testGetName()
Search for a both an existing and a non-existing route.
@covers ::get
File
- core/
tests/ Drupal/ Tests/ Core/ Routing/ LazyRouteCollectionTest.php, line 75
Class
- LazyRouteCollectionTest
- @coversDefaultClass \Drupal\Core\Routing\LazyRouteCollection
Namespace
Drupal\Tests\Core\RoutingCode
public function testGetName() {
// Hit.
$this->routeProvider
->method('getRouteByName')
->with('route_1')
->will($this
->returnValue($this->testRoutes['route_1']));
$lazyRouteCollection = new LazyRouteCollection($this->routeProvider);
$this
->assertEquals($lazyRouteCollection
->get('route_1'), $this->testRoutes['route_1']);
// Miss.
$this->routeProvider
->method('getRouteByName')
->with('does_not_exist')
->will($this
->throwException(new RouteNotFoundException()));
$lazyRouteCollectionFail = new LazyRouteCollection($this->routeProvider);
$this
->assertNull($lazyRouteCollectionFail
->get('does_not_exist'));
}