public function LinkGeneratorTest::testGenerateNone in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::testGenerateNone()
- 10 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::testGenerateNone()
Tests the generate() method with the <none> route.
The set_active_class option is set to TRUE to ensure we do not get the active class and the data-drupal-link-system-path attribute.
@covers ::generate
File
- core/
tests/ Drupal/ Tests/ Core/ Utility/ LinkGeneratorTest.php, line 193
Class
- LinkGeneratorTest
- @coversDefaultClass \Drupal\Core\Utility\LinkGenerator @group Utility
Namespace
Drupal\Tests\Core\UtilityCode
public function testGenerateNone() {
$this->urlGenerator
->expects($this
->once())
->method('generateFromRoute')
->with('<none>', [], [
'set_active_class' => TRUE,
] + $this->defaultOptions)
->willReturn((new GeneratedUrl())
->setGeneratedUrl(''));
$this->moduleHandler
->expects($this
->once())
->method('alter')
->with('link', $this
->isType('array'));
$url = Url::fromRoute('<none>');
$url
->setUrlGenerator($this->urlGenerator);
$url
->setOption('set_active_class', TRUE);
$result = $this->linkGenerator
->generate('Test', $url);
$this
->assertSame('<a href="">Test</a>', (string) $result);
}