Skip to content

Commit 31e87a7

Browse files
committed
update to gettext/gettext 5.1.0
1 parent ac173ef commit 31e87a7

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
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",

tests/PhpScannerTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Gettext\Tests;
44

5+
use Exception;
56
use Gettext\Scanner\PhpScanner;
67
use Gettext\Translations;
78
use 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
}

0 commit comments

Comments
 (0)