function LinkGeneratorTest::testGenerateQuery
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::testGenerateQuery()
- 8.9.x core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::testGenerateQuery()
- 11.x core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::testGenerateQuery()
Tests the link method with passed query options.
See also
\Drupal\Core\Utility\LinkGenerator::generate()
File
-
core/
tests/ Drupal/ Tests/ Core/ Utility/ LinkGeneratorTest.php, line 340
Class
- LinkGeneratorTest
- @coversDefaultClass \Drupal\Core\Utility\LinkGenerator @group Utility
Namespace
Drupal\Tests\Core\UtilityCode
public function testGenerateQuery() : void {
$this->urlGenerator
->expects($this->once())
->method('generateFromRoute')
->with('test_route_1', [], [
'query' => [
'test' => 'value',
],
] + $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1?test=value'));
$url = new Url('test_route_1', [], [
'query' => [
'test' => 'value',
],
]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator
->generate('Test', $url);
$this->assertLink([
'attributes' => [
'href' => '/test-route-1?test=value',
],
], $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.