|
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 PHPUnit\Framework\TestCase; |
|
15
|
|
|
use Symfony\Component\Finder\Finder; |
|
16
|
|
|
use Translation\Extractor\FileExtractor\BladeFileExtractor; |
|
17
|
|
|
use Translation\Extractor\Model\SourceCollection; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @author Tobias Nyholm <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
final class BladeTest extends TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
private function getSourceLocations($relativePath) |
|
25
|
|
|
{ |
|
26
|
|
|
$extractor = new BladeFileExtractor(); |
|
27
|
|
|
|
|
28
|
|
|
$filename = substr($relativePath, 1 + strrpos($relativePath, '/')); |
|
29
|
|
|
$path = __DIR__.'/../Resources/'.substr($relativePath, 0, strrpos($relativePath, '/')); |
|
30
|
|
|
|
|
31
|
|
|
$finder = new Finder(); |
|
32
|
|
|
$finder->files()->name($filename)->in($path); |
|
33
|
|
|
$collection = new SourceCollection(); |
|
34
|
|
|
foreach ($finder as $file) { |
|
35
|
|
|
$extractor->getSourceLocations($file, $collection); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
return $collection; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testExtractLang() |
|
42
|
|
|
{ |
|
43
|
|
|
$collection = $this->getSourceLocations('Blade/lang.blade.php'); |
|
44
|
|
|
|
|
45
|
|
|
$this->assertCount(1, $collection); |
|
46
|
|
|
$source = $collection->first(); |
|
47
|
|
|
$this->assertEquals('foo.bar', $source->getMessage()); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function testExtractTrans() |
|
51
|
|
|
{ |
|
52
|
|
|
$collection = $this->getSourceLocations('Blade/trans.blade.php'); |
|
53
|
|
|
|
|
54
|
|
|
$this->assertCount(1, $collection); |
|
55
|
|
|
$source = $collection->first(); |
|
56
|
|
|
$this->assertEquals('foo.bar', $source->getMessage()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function testExtractTransChoice() |
|
60
|
|
|
{ |
|
61
|
|
|
$collection = $this->getSourceLocations('Blade/trans_choice.blade.php'); |
|
62
|
|
|
|
|
63
|
|
|
$this->assertCount(1, $collection); |
|
64
|
|
|
$source = $collection->first(); |
|
65
|
|
|
$this->assertEquals('foo.bar', $source->getMessage()); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|