public function testCreator() { //Extract translations $translations1 = Gettext\Extractors\PhpCode::fromFile(__DIR__ . '/files/phpCode-example.php'); $translations2 = Gettext\Translations::fromPhpCodefile(__DIR__ . '/files/phpCode-example.php'); $this->assertInstanceOf('Gettext\\Translations', $translations1); $this->assertInstanceOf('Gettext\\Translations', $translations2); $this->assertEquals($translations1, $translations2); $result = Gettext\Generators\Po::toString($translations1); $this->assertEquals($result, $translations2->toPoString()); }
public function testWordpress() { //Extract translations $translations = Gettext\Extractors\PhpCode::fromFile(__DIR__ . '/files/wordpress-template.php'); $this->assertInstanceOf('Gettext\\Translations', $translations); $po = Gettext\Generators\Po::toString($translations); $assert = file_get_contents(__DIR__ . '/files/wordpress-template.po'); //remove the first 13 lines with temp info $po = explode("\n", $po); $assert = explode("\n", $assert); $po = implode("\n", array_splice($po, 13)); $assert = implode("\n", array_splice($assert, 13)); $this->assertEquals($po, $assert); }