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\TranslationBlock; |
15
|
|
|
use Translation\Extractor\Visitor\Twig\TwigVisitor; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Tobias Nyholm <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
final class TranslationBlockTest extends BaseTwigVisitorTest |
21
|
|
|
{ |
22
|
1 |
|
public function testTrans() |
23
|
|
|
{ |
24
|
1 |
|
$collection = $this->getSourceLocations(TwigVisitor::create(), 'Twig/TranslationBlock/trans.html.twig'); |
25
|
|
|
|
26
|
1 |
|
$this->assertCount(3, $collection); |
27
|
1 |
|
$source = $collection->get(0); |
28
|
1 |
|
$this->assertEquals('foobar', $source->getMessage()); |
29
|
1 |
|
$this->assertEquals('domain', $source->getContext()['domain']); |
30
|
|
|
|
31
|
1 |
|
$source = $collection->get(1); |
32
|
1 |
|
$this->assertEquals('no-domain', $source->getMessage()); |
33
|
1 |
|
$this->assertEquals('messages', $source->getContext()['domain']); |
34
|
|
|
|
35
|
1 |
|
$source = $collection->get(2); |
36
|
1 |
|
$this->assertEquals('trans-count', $source->getMessage()); |
37
|
1 |
|
$this->assertEquals('messages', $source->getContext()['domain']); |
38
|
1 |
|
} |
39
|
|
|
|
40
|
2 |
View Code Duplication |
public function testTranschoice() |
|
|
|
|
41
|
|
|
{ |
42
|
1 |
|
$collection = $this->getSourceLocations(TwigVisitor::create(), 'Twig/TranslationBlock/transchoice.html.twig'); |
43
|
|
|
|
44
|
1 |
|
$this->assertCount(1, $collection); |
45
|
2 |
|
$source = $collection->first(); |
46
|
2 |
|
$this->assertEquals('foobar', $source->getMessage()); |
47
|
1 |
|
} |
48
|
|
|
} |
49
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.