public function LinkGeneratorTest::testGenerateHrefs in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 111 - Contains \Drupal\Tests\Core\Utility\LinkGeneratorTest.
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, array(
'absolute' => $absolute,
) + $this->defaultOptions)
->willReturn((new GeneratedUrl())
->setGeneratedUrl($expected_url));
$this->moduleHandler
->expects($this
->once())
->method('alter');
$url = new Url($route_name, $parameters, array(
'absolute' => $absolute,
));
$url
->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator
->generate('Test', $url);
$this
->assertLink(array(
'attributes' => array(
'href' => $expected_url,
),
), $result);
}