public function LinkGeneratorTest::testGenerateHrefs in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::testGenerateHrefs()
- 9 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::testGenerateHrefs()
Tests the link method with certain hrefs.
@dataProvider providerTestGenerateHrefs
See also
\Drupal\Core\Utility\LinkGenerator::generate()
\Drupal\Tests\Core\Utility\LinkGeneratorTest::providerTestGenerate()
File
- core/
tests/ Drupal/ Tests/ Core/ Utility/ LinkGeneratorTest.php, line 110
Class
- LinkGeneratorTest
- @coversDefaultClass \Drupal\Core\Utility\LinkGenerator @group Utility
Namespace
Drupal\Tests\Core\UtilityCode
public function testGenerateHrefs($route_name, array $parameters, $absolute, $expected_url) {
$this->urlGenerator
->expects($this
->once())
->method('generateFromRoute')
->with($route_name, $parameters, [
'absolute' => $absolute,
] + $this->defaultOptions)
->willReturn((new GeneratedUrl())
->setGeneratedUrl($expected_url));
$this->moduleHandler
->expects($this
->once())
->method('alter');
$url = new Url($route_name, $parameters, [
'absolute' => $absolute,
]);
$url
->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator
->generate('Test', $url);
$this
->assertLink([
'attributes' => [
'href' => $expected_url,
],
], $result);
}