Add tests when a template doesn't have output nodes

This commit is contained in:
Fabien Potencier
2024-01-11 08:19:14 +01:00
parent b4c3c1c448
commit d53509d457
+18
View File
@@ -123,6 +123,24 @@ class TemplateTest extends TestCase
];
}
/**
* @dataProvider getRenderTemplateWithoutOutputData
*/
public function testRenderTemplateWithoutOutput(string $template)
{
$twig = new Environment(new ArrayLoader(['index' => $template]));
$this->assertSame('', $twig->render('index'));
}
public function getRenderTemplateWithoutOutputData()
{
return [
[''],
['{% for var in [] %}{% endfor %}'],
['{% if false %}{% endif %}'],
];
}
public function testRenderBlockWithUndefinedBlock()
{
$this->expectException(RuntimeError::class);