| 1 | <?php |
||
| 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 |