Skip to content

Commit

Permalink
[TwigBundle] added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Nov 2, 2014
1 parent b1bffc0 commit 97a8f7e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,17 @@ public function getExtractData()
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'));
}
}
3 changes: 2 additions & 1 deletion src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function extract($directory, MessageCatalogue $catalogue)
try {
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
} catch (\Twig_Error $e) {
$e->setTemplateFile($file->getPathname());
$e->setTemplateFile($file->getRelativePathname());

throw $e;
}
}
Expand Down

0 comments on commit 97a8f7e

Please sign in to comment.