function TwigExtensionTest::testFileUrl
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testFileUrl()
- 11.x core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testFileUrl()
Tests the file_url filter.
File
-
core/
tests/ Drupal/ Tests/ Core/ Template/ TwigExtensionTest.php, line 190
Class
- TwigExtensionTest
- Tests the twig extension.
Namespace
Drupal\Tests\Core\TemplateCode
public function testFileUrl() : void {
$this->fileUrlGenerator
->expects($this->once())
->method('generateString')
->with('public://picture.jpg')
->willReturn('sites/default/files/picture.jpg');
$loader = new StringLoader();
$twig = new Environment($loader);
$twig->addExtension($this->systemUnderTest);
$result = $twig->render('{{ file_url(file) }}', [
'file' => 'public://picture.jpg',
]);
$this->assertEquals('sites/default/files/picture.jpg', $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.