1616use Symfony \Bridge \Twig \Translation \TwigExtractor ;
1717use Symfony \Component \Translation \MessageCatalogue ;
1818use Twig \Environment ;
19- use Twig \Error \Error ;
2019use Twig \Loader \ArrayLoader ;
2120
2221class TwigExtractorTest extends TestCase
@@ -78,23 +77,15 @@ public function getExtractData()
7877 /**
7978 * @dataProvider resourcesWithSyntaxErrorsProvider
8079 */
81- public function testExtractSyntaxError ($ resources )
80+ public function testExtractSyntaxError ($ resources, array $ messages )
8281 {
83- $ this ->expectException ('Twig\Error\Error ' );
8482 $ twig = new Environment ($ this ->getMockBuilder ('Twig\Loader\LoaderInterface ' )->getMock ());
8583 $ twig ->addExtension (new TranslationExtension ($ this ->getMockBuilder ('Symfony\Component\Translation\TranslatorInterface ' )->getMock ()));
8684
8785 $ extractor = new TwigExtractor ($ twig );
88-
89- try {
90- $ extractor ->extract ($ resources , new MessageCatalogue ('en ' ));
91- } catch (Error $ e ) {
92- $ this ->assertSame (\dirname (__DIR__ ).strtr ('/Fixtures/extractor/syntax_error.twig ' , '/ ' , \DIRECTORY_SEPARATOR ), $ e ->getFile ());
93- $ this ->assertSame (1 , $ e ->getLine ());
94- $ this ->assertSame ('Unclosed "block". ' , $ e ->getMessage ());
95-
96- throw $ e ;
97- }
86+ $ catalogue = new MessageCatalogue ('en ' );
87+ $ extractor ->extract ($ resources , $ catalogue );
88+ $ this ->assertSame ($ messages , $ catalogue ->all ());
9889 }
9990
10091 /**
@@ -103,9 +94,9 @@ public function testExtractSyntaxError($resources)
10394 public function resourcesWithSyntaxErrorsProvider ()
10495 {
10596 return [
106- [__DIR__ .'/../Fixtures ' ],
107- [__DIR__ .'/../Fixtures/extractor/syntax_error.twig ' ],
108- [new \SplFileInfo (__DIR__ .'/../Fixtures/extractor/syntax_error.twig ' )],
97+ [__DIR__ .'/../Fixtures ' , [ ' messages ' => [ ' Hi! ' => ' Hi! ' ]] ],
98+ [__DIR__ .'/../Fixtures/extractor/syntax_error.twig ' , [] ],
99+ [new \SplFileInfo (__DIR__ .'/../Fixtures/extractor/syntax_error.twig ' ), [] ],
109100 ];
110101 }
111102
0 commit comments