function RouterTest::testRouteAliasWithDeprecation
Tests route aliasing with deprecation.
@group legacy
File
-
core/
modules/ system/ tests/ src/ Functional/ Routing/ RouterTest.php, line 375
Class
- RouterTest
- Functional class for the full integrated routing system.
Namespace
Drupal\Tests\system\Functional\RoutingCode
public function testRouteAliasWithDeprecation() : void {
$request = \Drupal::request();
$route_provider = \Drupal::service('router.route_provider');
// Check an aliased route with a deprecation message.
$deprecated_route_url = Url::fromRoute('router_test.deprecated');
$this->expectDeprecation('The "router_test.deprecated" route is deprecated in drupal:11.2.0 and will be removed in drupal:12.0.0. Use the "router_test.1" route instead.');
$this->drupalGet($deprecated_route_url);
$this->assertSession()
->addressEquals($request->getUriForPath('/router_test/test1'));
$routes = $route_provider->getRoutesByNames([
'router_test.deprecated',
]);
$deprecated_route = reset($routes);
$this->assertTrue($deprecated_route instanceof Alias);
$this->assertTrue($deprecated_route->isDeprecated());
$deprecation = $deprecated_route->getDeprecation('router_test.deprecated');
$this->assertEquals('drupal/core', $deprecation['package']);
$this->assertEquals('11.2.0', $deprecation['version']);
$this->assertEquals('The "router_test.deprecated" route is deprecated in drupal:11.2.0 and will be removed in drupal:12.0.0. Use the "router_test.1" route instead.', $deprecation['message']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.