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

BaseTwigVisitorTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 28
c 0
b 0
f 0
rs 10
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 PHPUnit\Framework\TestCase;
15
use Translation\Extractor\FileExtractor\TwigFileExtractor;
16
use Symfony\Component\Finder\Finder;
17
use Translation\Extractor\Model\SourceCollection;
18
19
/**
20
 * @author Tobias Nyholm <[email protected]>
21
 */
22
abstract class BaseTwigVisitorTest extends TestCase
23
{
24
    protected function getSourceLocations($visitor, $relativePath)
25
    {
26
        $extractor = $this->getExtractor();
27
        $extractor->addVisitor($visitor);
28
29
        $filename = substr($relativePath, 1 + strrpos($relativePath, '/'));
30
        $path = __DIR__.'/../../../Resources/'.substr($relativePath, 0, strrpos($relativePath, '/'));
31
32
        $finder = new Finder();
33
        $finder->files()->name($filename)->in($path);
34
        $collection = new SourceCollection();
35
        foreach ($finder as $file) {
36
            $extractor->getSourceLocations($file, $collection);
37
        }
38
39
        return $collection;
40
    }
41
42
    /**
43
     * @return TwigFileExtractor
44
     */
45
    private function getExtractor()
46
    {
47
        return new TwigFileExtractor(TwigEnvironmentFactory::create());
48
    }
49
}
50