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
|
<?php
/**
* Tests for XliffFFS
*
* @file
* @author Niklas Laxström
* @license GPL-2.0+
*/
class XliffFFSTest extends MediaWikiTestCase {
protected $groupConfiguration = array(
'BASIC' => array(
'class' => 'FileBasedMessageGroup',
'id' => 'test-id',
'label' => 'Test Label',
'namespace' => 'NS_MEDIAWIKI',
'description' => 'Test description',
),
'FILES' => array(
'class' => 'XliffFFS',
'sourcePattern' => '',
),
);
public function testParsing() {
$group = MessageGroupBase::factory( $this->groupConfiguration );
$ffs = new XliffFFS( $group );
$file = file_get_contents( __DIR__ . '/../data/minimal.xlf' );
$parsed = $ffs->readFromVariable( $file, 'target' );
$expected = array(
'1' => 'Hei maailma',
'2' => TRANSLATE_FUZZY . 'Fuzzy translation',
'3' => 'Tämä on <g id="1" ctype="bold">paksu</g>.',
);
$expected = array( 'MESSAGES' => $expected );
$this->assertEquals( $expected, $parsed );
$parsed = $ffs->readFromVariable( $file, 'source' );
$expected = array(
'1' => 'Hello world',
'2' => 'Fuzzy message',
'3' => 'This is <g id="1" ctype="bold">bold</g>.',
);
$expected = array( 'MESSAGES' => $expected );
$this->assertEquals( $expected, $parsed );
}
}
|