Completed
Push — master ( aed006...631b86 )
by Tobias
02:33
created

BladeTest::testExtractTransChoice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
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\Extractor\Tests\Functional;
13
14
use Symfony\Component\Finder\Finder;
15
use Translation\Extractor\FileExtractor\BladeFileExtractor;
16
use Translation\Extractor\Model\SourceCollection;
17
18
class BladeTest extends \PHPUnit_Framework_TestCase
19
{
20 3
    private function getSourceLocations($relativePath)
21
    {
22 3
        $extractor = new BladeFileExtractor();
23
24 3
        $filename = substr($relativePath, 1 + strrpos($relativePath, '/'));
25 3
        $path = __DIR__.'/../Resources/'.substr($relativePath, 0, strrpos($relativePath, '/'));
26
27 3
        $finder = new Finder();
28 3
        $finder->files()->name($filename)->in($path);
29 3
        $collection = new SourceCollection();
30 3
        foreach ($finder as $file) {
31 3
            $extractor->getSourceLocations($file, $collection);
32 3
        }
33
34 3
        return $collection;
35
    }
36
37 1 View Code Duplication
    public function testExtractLang()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
38
    {
39 1
        $collection = $this->getSourceLocations('Blade/lang.blade.php');
40
41 1
        $this->assertCount(1, $collection);
42 1
        $source = $collection->first();
43 1
        $this->assertEquals('foo.bar', $source->getMessage());
44 1
    }
45
46 1 View Code Duplication
    public function testExtractTrans()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
47
    {
48 1
        $collection = $this->getSourceLocations('Blade/trans.blade.php');
49
50 1
        $this->assertCount(1, $collection);
51 1
        $source = $collection->first();
52 1
        $this->assertEquals('foo.bar', $source->getMessage());
53 1
    }
54
55 1 View Code Duplication
    public function testExtractTransChoice()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
56
    {
57 1
        $collection = $this->getSourceLocations('Blade/trans_choice.blade.php');
58
59 1
        $this->assertCount(1, $collection);
60 1
        $source = $collection->first();
61 1
        $this->assertEquals('foo.bar', $source->getMessage());
62 1
    }
63
}
64