forked from GlotPress/GlotPress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_format_php.php
72 lines (59 loc) · 2.02 KB
/
test_format_php.php
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
class GP_Test_Format_PHP extends GP_UnitTestCase {
/**
* @var GP_Translation_Set
*/
protected $translation_set;
/**
* @var GP_Locale
*/
protected $locale;
/**
* @var string
*/
protected $format = 'php';
public function setUp(): void {
parent::setUp();
$this->translation_set = $this->factory->translation_set->create_with_project_and_locale( array(), array( 'name' => 'foo_project' ) );
$this->locale = new GP_Locale( array(
'slug' => $this->translation_set->locale,
'nplurals' => 2,
'plural_expression' => 'n != 1',
) );
}
public function test_format_name() {
$this->assertSame( 'PHP (.mo.php)', GP::$formats[ $this->format ]->name );
}
public function test_format_extension() {
$this->assertSame( 'mo.php', GP::$formats[ $this->format ]->extension );
}
public function test_print_exported_file() {
$entries = array(
new Translation_Entry( array( 'singular' => 'foo', 'translations' => array( 'bar' ) ) ),
new Translation_Entry( array(
'context' => 'somecontext',
'singular' => 'bar',
'translations' => array( 'baz' ),
) ),
new Translation_Entry( array(
'singular' => '%d Theme Update',
'translations' => array(
'%d Theme Update',
'%d Theme Updates',
),
) ),
);
$php = GP::$formats[ $this->format ]->print_exported_file( $this->translation_set->project, $this->locale, $this->translation_set, $entries );
$this->assertStringContainsString("'project-id-version'=>'foo_project'", $php );
$this->assertStringContainsString("'language'=>'aa'", $php );
$this->assertStringContainsString("'foo'=>'bar'", $php );
$this->assertStringContainsString("'somecontext\4bar'=>'baz'", $php );
$this->assertStringContainsString("'%d Theme Update'=>'%d Theme Update' . \"\\0\" . '%d Theme Updates'", $php );
}
public function test_read_originals_from_file() {
$this->markTestIncomplete( 'Not implemented' );
}
public function test_read_translations_from_file() {
$this->markTestIncomplete( 'Not implemented' );
}
}