Completed
Pull Request — master (#17)
by Tobias
03:13 queued 01:27
created

BladeTest::getSourceLocations()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 16
ccs 11
cts 11
cp 1
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
crap 2
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