Skip to content

Commit

Permalink
update to gettext/gettext 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Nov 11, 2019
1 parent ac173ef commit 31e87a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require": {
"php": "^7.2",
"nikic/php-parser": "^4.2",
"gettext/gettext": "^5.0"
"gettext/gettext": "^5.1"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
Expand Down
24 changes: 24 additions & 0 deletions tests/PhpScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Gettext\Tests;

use Exception;
use Gettext\Scanner\PhpScanner;
use Gettext\Translations;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -35,4 +36,27 @@ public function testPhpCodeScanner()
$this->assertCount(4, $domain2);
$this->assertCount(1, $domain3);
}

public function testInvalidFunction()
{
$this->expectException(Exception::class);

$scanner = new PhpScanner(Translations::create('messages'));
$scanner->scanString('<?php __(ucfirst("invalid function"));', 'file.php');

list($translations) = array_values($scanner->getTranslations());

$this->assertCount(0, $translations);
}

public function testIgnoredInvalidFunction()
{
$scanner = new PhpScanner(Translations::create('messages'));
$scanner->ignoreInvalidFunctions();
$scanner->scanString('<?php __(ucfirst("invalid function"));', 'file.php');

list($translations) = array_values($scanner->getTranslations());

$this->assertCount(0, $translations);
}
}

0 comments on commit 31e87a7

Please sign in to comment.