function TwigTransTest::testEmptyTwigTransTags
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Theme/TwigTransTest.php \Drupal\Tests\system\Functional\Theme\TwigTransTest::testEmptyTwigTransTags()
- 8.9.x core/modules/system/tests/src/Functional/Theme/TwigTransTest.php \Drupal\Tests\system\Functional\Theme\TwigTransTest::testEmptyTwigTransTags()
- 10 core/modules/system/tests/src/Functional/Theme/TwigTransTest.php \Drupal\Tests\system\Functional\Theme\TwigTransTest::testEmptyTwigTransTags()
Tests empty Twig "trans" tags.
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ TwigTransTest.php, line 106
Class
- TwigTransTest
- Tests Twig "trans" tags.
Namespace
Drupal\Tests\system\Functional\ThemeCode
public function testEmptyTwigTransTags() : void {
$elements = [
'#type' => 'inline_template',
'#template' => '{% trans %}{% endtrans %}',
];
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
try {
$renderer->renderInIsolation($elements);
$this->fail('{% trans %}{% endtrans %} did not throw an exception.');
} catch (SyntaxError $e) {
$this->assertStringContainsString('{% trans %} tag cannot be empty', $e->getMessage());
} catch (\Exception) {
$this->fail('{% trans %}{% endtrans %} threw an unexpected exception.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.