public function LinkGeneratorTest::testGenerateOptions in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::testGenerateOptions()
Tests the link method with arbitrary passed options.
See also
\Drupal\Core\Utility\LinkGenerator::generate()
File
- core/
tests/ Drupal/ Tests/ Core/ Utility/ LinkGeneratorTest.php, line 381
Class
- LinkGeneratorTest
- @coversDefaultClass \Drupal\Core\Utility\LinkGenerator @group Utility
Namespace
Drupal\Tests\Core\UtilityCode
public function testGenerateOptions() {
$this->urlGenerator
->expects($this
->once())
->method('generateFromRoute')
->with('test_route_1', [], [
'key' => 'value',
] + $this->defaultOptions)
->willReturn((new GeneratedUrl())
->setGeneratedUrl('/test-route-1?test=value'));
$url = new Url('test_route_1', [], [
'key' => 'value',
]);
$url
->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator
->generate('Test', $url);
$this
->assertLink([
'attributes' => [
'href' => '/test-route-1?test=value',
],
], $result);
}