[TwigBundle] added a test

This commit is contained in:
Fabien Potencier 2014-11-02 01:54:43 +01:00
parent b1bffc0516
commit 97a8f7e395
2 changed files with 15 additions and 1 deletions

View File

@ -78,4 +78,17 @@ class TwigExtractorTest extends TestCase
array('{{ "new key" | transchoice(domain="domain", count=1) }}', array('new key' => 'domain')),
);
}
/**
* @expectedException \Twig_Error
* @expectedExceptionMessage Unclosed "block" in "extractor/syntax_error.twig" at line 1
*/
public function testExtractSyntaxError()
{
$twig = new \Twig_Environment(new \Twig_Loader_Array(array()));
$twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));
$extractor = new TwigExtractor($twig);
$extractor->extract(__DIR__.'/../Fixtures', new MessageCatalogue('en'));
}
}

View File

@ -61,7 +61,8 @@ class TwigExtractor implements ExtractorInterface
try {
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
} catch (\Twig_Error $e) {
$e->setTemplateFile($file->getPathname());
$e->setTemplateFile($file->getRelativePathname());
throw $e;
}
}