public function TwigExtensionTest::testTemplateFunction in Components! 3.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/TwigExtensionTest.php \Drupal\Tests\components\Kernel\TwigExtensionTest::testTemplateFunction()
Ensures the Twig template() function works inside a Drupal instance.
@covers ::template
Throws
\Exception
File
- tests/
src/ Kernel/ TwigExtensionTest.php, line 29
Class
- TwigExtensionTest
- @coversDefaultClass \Drupal\components\Template\TwigExtension @group components
Namespace
Drupal\Tests\components\KernelCode
public function testTemplateFunction() {
try {
$element = [
'#theme' => 'components_twig_extension_test_template_function',
'#items' => [
'first item',
'second item',
],
];
$result = $this
->render($element);
} catch (\Exception $e) {
$this
->fail('No Exception expected; "' . $e
->getMessage() . '" thrown during: ' . $this
->getName());
}
$this
->assertStringContainsString('<ul><li>first item</li><li>second item</li></ul>', $result);
}