| Total Complexity | 4 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | use Twig\Error\SyntaxError; |
||
| 16 | |||
| 17 | class TemplateTest extends TestCase |
||
| 18 | { |
||
| 19 | public function testSyntax() |
||
| 20 | { |
||
| 21 | $config = Configuration::loadFromArray([ |
||
| 22 | 'language.i18n.backend' => 'gettext/gettext', |
||
| 23 | 'module.enable' => array_fill_keys(Module::getModules(), true), |
||
| 24 | ]); |
||
| 25 | |||
| 26 | Configuration::setPreLoadedConfig($config); |
||
| 27 | $basedir = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'templates'; |
||
| 28 | |||
| 29 | // Base templates |
||
| 30 | $files = array_diff(scandir($basedir), ['.', '..']); |
||
| 31 | foreach ($files as $file) { |
||
| 32 | if (preg_match('/.twig$/', $file)) { |
||
| 33 | $t = new Template($config, 'monitor:'.basename($file)); |
||
| 34 | ob_start(); |
||
| 35 | try { |
||
| 36 | $t->show(); |
||
| 37 | $this->addToAssertionCount(1); |
||
| 38 | } catch (SyntaxError $e) { |
||
| 39 | $this->fail($e->getMessage().' in '.$e->getFile().':'.$e->getLine()); |
||
| 40 | } |
||
| 46 |