function LinkGeneratorTest::testGenerateHrefs
Tests the link method with certain hrefs.
Attributes
#[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 117  
Class
Namespace
Drupal\Tests\Core\UtilityCode
public function testGenerateHrefs($route_name, array $parameters, $absolute, $expected_url) : void {
  $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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.