Completed
Push — master ( 269a50...019c60 )
by Tobias
04:32
created

TranslationBlockTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 86.21 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 25
loc 29
rs 10

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Extractor\Tests\Functional\Visitor\Twig;
13
14
use Translation\Extractor\Visitor\Twig\TwigVisitorFactory;
15
16
/**
17
 * @author Tobias Nyholm <[email protected]>
18
 */
19
final class TranslationBlockTest extends BaseTwigVisitorTest
20
{
21
    public function testTrans()
22
    {
23
        $collection = $this->getSourceLocations(TwigVisitorFactory::create(), 'Twig/TranslationBlock/trans.html.twig');
24
25
        $this->assertCount(3, $collection);
26
        $source = $collection->get(0);
27
        $this->assertEquals('foobar', $source->getMessage());
28
        $this->assertEquals('domain', $source->getContext()['domain']);
29
30
        $source = $collection->get(1);
31
        $this->assertEquals('no-domain', $source->getMessage());
32
        $this->assertEquals('messages', $source->getContext()['domain']);
33
34
        $source = $collection->get(2);
35
        $this->assertEquals('trans-count', $source->getMessage());
36
        $this->assertEquals('messages', $source->getContext()['domain']);
37
    }
38
39
    public function testTranschoice()
40
    {
41
        $collection = $this->getSourceLocations(TwigVisitorFactory::create(), 'Twig/TranslationBlock/transchoice.html.twig');
42
43
        $this->assertCount(1, $collection);
44
        $source = $collection->first();
45
        $this->assertEquals('foobar', $source->getMessage());
46
    }
47
}
48