function UrlGeneratorTest::testRouteObjectDeprecation
Tests URL generation deprecations.
@group legacy
File
-
core/
tests/ Drupal/ Tests/ Core/ Routing/ UrlGeneratorTest.php, line 300
Class
- UrlGeneratorTest
- Confirm that the UrlGenerator is functioning properly.
Namespace
Drupal\Tests\Core\RoutingCode
public function testRouteObjectDeprecation() : void {
$this->expectDeprecation('Passing a route object to Drupal\\Core\\Routing\\UrlGenerator::getPathFromRoute() is deprecated in drupal:10.1.0 and will not be supported in drupal:11.0.0. Pass the route name instead. See https://www.drupal.org/node/3172280');
$path = $this->generator
->getPathFromRoute(new Route('/test/one'));
$this->assertSame($this->generator
->getPathFromRoute('test_1'), $path);
$this->expectDeprecation('Passing a route object to Drupal\\Core\\Routing\\UrlGenerator::generateFromRoute() is deprecated in drupal:10.1.0 and will not be supported in drupal:11.0.0. Pass the route name instead. See https://www.drupal.org/node/3172280');
$url = $this->generator
->generateFromRoute(new Route('/test/one'));
$this->assertSame($this->generator
->generateFromRoute('test_1'), $url);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.