I began to think about Continuous Integration for the twig templates in Symfony.
- A template is independent logic.
- There are mistakes in the templates. But in the process of development I do not want to be distracted by visual inspection.
Are there any ready-made solutions for unit testing a twig file in symphony?
Advertisement
Answer
Inside a WebTestCase
(extension of a phpunit TestCase
since Symfony 2.0) / KernelTestCase
(extension of phpunit TestCase
since Symfony 2.5)
$twig = self::$kernel->getContainer()->get('twig'); $html = $twig->render('AppBundle::app/something.html.twig', ['content' => 'I am some variable value']); self::assertEquals($html, $response->getContent());