function TwigTransTest::testEmptyTwigTransTags
Tests empty Twig "trans" tags.
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ TwigTransTest.php, line 103
Class
- TwigTransTest
- Tests Twig "trans" tags.
Namespace
Drupal\Tests\system\Functional\ThemeCode
public function testEmptyTwigTransTags() {
$elements = [
'#type' => 'inline_template',
'#template' => '{% trans %}{% endtrans %}',
];
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
try {
$renderer->renderPlain($elements);
$this->fail('{% trans %}{% endtrans %} did not throw an exception.');
} catch (SyntaxError $e) {
$this->assertStringContainsString('{% trans %} tag cannot be empty', $e->getMessage());
} catch (\Exception $e) {
$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.