function UrlGeneratorTest::testGenerateWithRouteNameInOptions
Same name and namespace in other branches
- main core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::testGenerateWithRouteNameInOptions()
Tests that route name and parameters are passed to path processors.
@legacy-covers ::generateFromRoute
File
-
core/
tests/ Drupal/ Tests/ Core/ Routing/ UrlGeneratorTest.php, line 582
Class
- UrlGeneratorTest
- Confirm that the UrlGenerator is functioning properly.
Namespace
Drupal\Tests\Core\RoutingCode
public function testGenerateWithRouteNameInOptions() : void {
$path_processor = $this->createMock(OutboundPathProcessorInterface::class);
$path_processor->expects($this->atLeastOnce())
->method('processOutbound')
->willReturnCallback(function ($path, &$options = []) {
// Assert that 'route_name' exists in options and is the expected value.
$this->assertArrayHasKey('route_name', $options);
$this->assertEquals('test_1', $options['route_name']);
// Assert that 'route_parameters' exists in options and
// is the expected value.
$this->assertArrayHasKey('route_parameters', $options);
$this->assertEquals([
'node' => 1,
], $options['route_parameters']);
return $path;
});
$this->processorManager
->addOutbound($path_processor);
$options = [];
$this->assertGenerateFromRoute('test_1', [
'node' => 1,
], $options, '/hello/world?node=1', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.