forked from php-gettext/Gettext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoGeneratorTest.php
More file actions
57 lines (44 loc) · 1.81 KB
/
MoGeneratorTest.php
File metadata and controls
57 lines (44 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types = 1);
namespace Gettext\Tests;
use Gettext\Generator\MoGenerator;
use Gettext\Loader\MoLoader;
use Gettext\Translation;
use Gettext\Translations;
use PHPUnit\Framework\TestCase;
class MoGeneratorTest extends TestCase
{
public function testMoGenerator(): void
{
$generator = (new MoGenerator())->includeHeaders();
$loader = new MoLoader();
$translations = Translations::create('my-domain');
$translations->setLanguage('gl_ES');
$translations->getHeaders()
->set('Content-Type', 'text/plain; charset=UTF-8')
->set('X-Generator', 'PHP-Gettext');
$translation = Translation::create('context-1', 'Original');
$translation->translate('Orixinal');
$translations->add($translation);
$translation = Translation::create('context-1', 'Other comment');
$translation->translate('Outro comentario');
$translation->translatePlural('Outros comentarios');
$translations->add($translation);
$translation = Translation::create(null, 'Disabled comment');
$translation->disable();
$translation->translate('Comentario deshabilitado');
$translations->add($translation);
$translation = Translation::create(null, '15');
$translation->translate('15');
$translations->add($translation);
$translation = Translation::create(null, '123456');
$translation->translate('12345');
$translations->add($translation);
$mo = $generator->generateString($translations);
$expected = file_get_contents(__DIR__.'/assets/mo-generator-result.mo');
$this->assertSame($expected, $mo);
$result = $loader->loadString($mo);
$this->assertCount(4, $result);
$this->assertCount(5, $result->getHeaders());
}
}