public function TwigExtensionTest::testEscapeWithGeneratedLink in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testEscapeWithGeneratedLink()
- 10 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testEscapeWithGeneratedLink()
@covers ::escapeFilter @covers ::bubbleArgMetadata
File
- core/
tests/ Drupal/ Tests/ Core/ Template/ TwigExtensionTest.php, line 307
Class
- TwigExtensionTest
- Tests the twig extension.
Namespace
Drupal\Tests\Core\TemplateCode
public function testEscapeWithGeneratedLink() {
$loader = new FilesystemLoader();
$twig = new Environment($loader, [
'debug' => TRUE,
'cache' => FALSE,
'autoescape' => 'html',
'optimizations' => 0,
]);
$twig
->addExtension($this->systemUnderTest);
$link = new GeneratedLink();
$link
->setGeneratedLink('<a href="http://example.com"></a>');
$link
->addCacheTags([
'foo',
]);
$link
->addAttachments([
'library' => [
'system/base',
],
]);
$this->renderer
->expects($this
->atLeastOnce())
->method('render')
->with([
"#cache" => [
"contexts" => [],
"tags" => [
"foo",
],
"max-age" => -1,
],
"#attached" => [
'library' => [
'system/base',
],
],
]);
$result = $this->systemUnderTest
->escapeFilter($twig, $link, 'html', NULL, TRUE);
$this
->assertEquals('<a href="http://example.com"></a>', $result);
}