|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the PHP Translation package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) PHP Translation team <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Translation\SymfonyStorage\Tests\Unit\Dumper; |
|
13
|
|
|
|
|
14
|
|
|
use PHPUnit\Framework\TestCase; |
|
15
|
|
|
use Symfony\Component\Translation\MessageCatalogue; |
|
16
|
|
|
use Translation\SymfonyStorage\Dumper\XliffDumper; |
|
17
|
|
|
|
|
18
|
|
|
class XliffDumperTest extends TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
public function testDumpXliff12() |
|
21
|
|
|
{ |
|
22
|
|
|
$catalogue = new MessageCatalogue('en'); |
|
23
|
|
|
$catalogue->set('key0', 'trans0'); |
|
24
|
|
|
$catalogue->set('key1', 'trans1'); |
|
25
|
|
|
|
|
26
|
|
|
$dumper = new XliffDumper(); |
|
27
|
|
|
$output = $dumper->formatCatalogue($catalogue, 'messages', ['xliff_version' => '1.2']); |
|
28
|
|
|
|
|
29
|
|
|
$this->assertContains('<source>key0</source>', $output); |
|
30
|
|
|
$this->assertContains('<target>trans0</target>', $output); |
|
31
|
|
|
$this->assertContains('<source>key1</source>', $output); |
|
32
|
|
|
$this->assertContains('<target>trans1</target>', $output); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testDumpXliff20Meta() |
|
36
|
|
|
{ |
|
37
|
|
|
$catalogue = new MessageCatalogue('en'); |
|
38
|
|
|
$catalogue->set('key0', 'trans0'); |
|
39
|
|
|
$catalogue->setMetadata('key0', ['notes' => [ |
|
40
|
|
|
['content' => 'yes', 'category' => 'approved'], |
|
41
|
|
|
['content' => 'new', 'category' => 'state'], |
|
42
|
|
|
]]); |
|
43
|
|
|
|
|
44
|
|
|
$catalogue->set('key1', 'trans1'); |
|
45
|
|
|
$catalogue->setMetadata('key1', ['notes' => [ |
|
46
|
|
|
['content' => 'cnt', 'priority' => '2'], |
|
47
|
|
|
]]); |
|
48
|
|
|
|
|
49
|
|
|
$dumper = new XliffDumper(); |
|
50
|
|
|
$output = $dumper->formatCatalogue($catalogue, 'messages', ['xliff_version' => '2.0']); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertContains('<note category="approved">yes</note>', $output); |
|
53
|
|
|
$this->assertContains('<note category="state">new</note>', $output); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|