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 20
20
"require" : {
21
21
"php" : " ^7.2" ,
22
22
"nikic/php-parser" : " ^4.2" ,
23
- "gettext/gettext" : " ^5.0 "
23
+ "gettext/gettext" : " ^5.1 "
24
24
},
25
25
"require-dev" : {
26
26
"phpunit/phpunit" : " ^8.0" ,
Original file line number Diff line number Diff line change 2
2
3
3
namespace Gettext \Tests ;
4
4
5
+ use Exception ;
5
6
use Gettext \Scanner \PhpScanner ;
6
7
use Gettext \Translations ;
7
8
use PHPUnit \Framework \TestCase ;
@@ -35,4 +36,27 @@ public function testPhpCodeScanner()
35
36
$ this ->assertCount (4 , $ domain2 );
36
37
$ this ->assertCount (1 , $ domain3 );
37
38
}
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
+ }
38
62
}
You can’t perform that action at this time.
0 commit comments