function UrlGeneratorTest::testAliasGenerationUsingInterfaceConstants
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::testAliasGenerationUsingInterfaceConstants()
- 8.9.x core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::testAliasGenerationUsingInterfaceConstants()
- 11.x core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::testAliasGenerationUsingInterfaceConstants()
Confirms that generated routes will have aliased paths using interface constants.
File
-
core/
tests/ Drupal/ Tests/ Core/ Routing/ UrlGeneratorTest.php, line 230
Class
- UrlGeneratorTest
- Confirm that the UrlGenerator is functioning properly.
Namespace
Drupal\Tests\Core\RoutingCode
public function testAliasGenerationUsingInterfaceConstants() : void {
$url = $this->generator
->generate('test_1', [], UrlGenerator::ABSOLUTE_PATH);
$this->assertEquals('/hello/world', $url);
// No cacheability to test; UrlGenerator::generate() doesn't support
// collecting cacheability metadata.
$this->routeProcessorManager
->expects($this->exactly(3))
->method('processOutbound')
->with($this->anything());
// Check that the two generate methods return the same result.
$this->assertGenerateFromRoute('test_1', [], [], $url, (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
$path = $this->generator
->getPathFromRoute('test_1');
$this->assertEquals('test/one', $path);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.