File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 2020 "require" : {
2121 "php" : " ^7.2" ,
2222 "nikic/php-parser" : " ^4.2" ,
23- "gettext/gettext" : " ^5.0 "
23+ "gettext/gettext" : " ^5.1 "
2424 },
2525 "require-dev" : {
2626 "phpunit/phpunit" : " ^8.0" ,
Original file line number Diff line number Diff line change 22
33namespace Gettext \Tests ;
44
5+ use Exception ;
56use Gettext \Scanner \PhpScanner ;
67use Gettext \Translations ;
78use PHPUnit \Framework \TestCase ;
@@ -35,4 +36,27 @@ public function testPhpCodeScanner()
3536 $ this ->assertCount (4 , $ domain2 );
3637 $ this ->assertCount (1 , $ domain3 );
3738 }
39+
40+ public function testInvalidFunction ()
41+ {
42+ $ this ->expectException (Exception::class);
43+
44+ $ scanner = new PhpScanner (Translations::create ('messages ' ));
45+ $ scanner ->scanString ('<?php __(ucfirst("invalid function")); ' , 'file.php ' );
46+
47+ list ($ translations ) = array_values ($ scanner ->getTranslations ());
48+
49+ $ this ->assertCount (0 , $ translations );
50+ }
51+
52+ public function testIgnoredInvalidFunction ()
53+ {
54+ $ scanner = new PhpScanner (Translations::create ('messages ' ));
55+ $ scanner ->ignoreInvalidFunctions ();
56+ $ scanner ->scanString ('<?php __(ucfirst("invalid function")); ' , 'file.php ' );
57+
58+ list ($ translations ) = array_values ($ scanner ->getTranslations ());
59+
60+ $ this ->assertCount (0 , $ translations );
61+ }
3862}
You can’t perform that action at this time.
0 commit comments