public function TwigExtensionTest::testFileUrl in Drupal 9
Same name and namespace in other branches
- 10 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 182
Class
- TwigExtensionTest
- Tests the twig extension.
Namespace
Drupal\Tests\Core\TemplateCode
public function testFileUrl() {
$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);
}