Completed
Push — master ( e4a30a...1a3d0b )
by Tobias
07:42
created

XliffConverterTest::testCatalogueToContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 1
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;
13
14
use Symfony\Component\HttpKernel\Kernel;
15
use Symfony\Component\Translation\MessageCatalogue;
16
use Translation\SymfonyStorage\XliffConverter;
17
18
/**
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21
class XliffConverterTest extends \PHPUnit_Framework_TestCase
22
{
23
    public function testContentToCatalogue()
24
    {
25
        if (Kernel::VERSION_ID < 20800) {
26
            $this->markTestSkipped('Symfony <2.8 is not supported. ');
27
        }
28
29
        $content = file_get_contents(__DIR__.'/messages.en.xlf');
30
        $catalogue = XliffConverter::contentToCatalogue($content, 'en', 'messages');
31
32
        $this->assertEquals('en', $catalogue->getLocale());
33
        $this->assertEquals(['messages'], $catalogue->getDomains());
34
        $this->assertCount(2, $catalogue->all('messages'));
35
    }
36
37 1
    public function testCatalogueToContent()
38
    {
39 1
        $catalogue = new MessageCatalogue('en');
40 1
        $catalogue->add(['foobar' => 'bar']);
41 1
        $content = XliffConverter::catalogueToContent($catalogue, 'messages');
42
43 1
        $this->assertRegExp('|foobar|', $content);
44 1
    }
45
}
46