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

XliffConverterTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 37.5%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 25
ccs 6
cts 16
cp 0.375
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testContentToCatalogue() 0 13 2
A testCatalogueToContent() 0 8 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