minor #3960 Add tests when a template doesn't have output nodes (fabpot)

This PR was merged into the 3.x branch.

Discussion
----------

Add tests when a template doesn't have output nodes

refs #3950 cc `@smnandre`

Commits
-------

d53509d4 Add tests when a template doesn't have output nodes
This commit is contained in:
Fabien Potencier
2024-01-11 08:39:22 +01:00
+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);