Introduce failing test case when a SplFileInfo object is passed to the extract() method in the TwigExtractor.

The problem is that when there's a twig error, symfony expects the `getRelativePath` method that the native object doesn't have.
This commit is contained in:
Marcos Sánchez 2015-07-22 16:34:23 -03:00 committed by Christian Flothmann
parent 38b9a88968
commit aa7cbbd205

View File

@ -74,14 +74,26 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
/** /**
* @expectedException \Twig_Error * @expectedException \Twig_Error
* @expectedExceptionMessageRegExp /Unclosed "block" in "extractor(\/|\\)syntax_error\.twig" at line 1/ * @expectedExceptionMessageRegExp /Unclosed "block" in "extractor(\/|\\)syntax_error\.twig" at line 1/
* @dataProvider resourcesWithSyntaxErrorsProvider
*/ */
public function testExtractSyntaxError() public function testExtractSyntaxError($resources)
{ {
$twig = new \Twig_Environment(new \Twig_Loader_Array(array())); $twig = new \Twig_Environment(new \Twig_Loader_Array(array()));
$twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface'))); $twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));
$extractor = new TwigExtractor($twig); $extractor = new TwigExtractor($twig);
$extractor->extract(__DIR__.'/../Fixtures', new MessageCatalogue('en')); $extractor->extract($resources, new MessageCatalogue('en'));
}
/**
* @return array
*/
public function resourcesWithSyntaxErrorsProvider()
{
return array(
array(__DIR__.'/../Fixtures'),
array(new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')),
);
} }
/** /**