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\Smoke; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Finder\Finder; |
15
|
|
|
use Translation\Extractor\Extractor; |
16
|
|
|
use Translation\Extractor\FileExtractor\PHPFileExtractor; |
17
|
|
|
use Translation\Extractor\FileExtractor\TwigFileExtractor; |
18
|
|
|
use Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans; |
19
|
|
|
use Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice; |
20
|
|
|
use Translation\Extractor\Visitor\Php\Symfony\FlashMessage; |
21
|
|
|
use Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices; |
22
|
|
|
use Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit; |
23
|
|
|
use Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit; |
24
|
|
|
use Translation\Extractor\Visitor\Twig\TranslationBlock; |
25
|
|
|
use Translation\Extractor\Visitor\Twig\TranslationFilter; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Smoke test to make sure no extractor throws exceptions. |
29
|
|
|
* |
30
|
|
|
* @author Tobias Nyholm <[email protected]> |
31
|
|
|
*/ |
32
|
|
|
class AllExtractorsTest extends \PHPUnit_Framework_TestCase |
33
|
|
|
{ |
34
|
|
|
public function testNoException() |
35
|
|
|
{ |
36
|
|
|
$extractor = new Extractor(); |
37
|
|
|
$extractor->addFileExtractor($this->getPHPFileExtractor()); |
38
|
|
|
$extractor->addFileExtractor($this->getTwigFileExtractor()); |
39
|
|
|
|
40
|
|
|
$finder = new Finder(); |
41
|
|
|
$finder->in(dirname(__DIR__)); |
42
|
|
|
|
43
|
|
|
$extractor->extract($finder); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return PHPFileExtractor |
48
|
|
|
*/ |
49
|
|
|
private function getPHPFileExtractor() |
50
|
|
|
{ |
51
|
|
|
$file = new PHPFileExtractor(); |
52
|
|
|
$file->addVisitor(new ContainerAwareTrans()); |
53
|
|
|
$file->addVisitor(new ContainerAwareTransChoice()); |
54
|
|
|
$file->addVisitor(new FlashMessage()); |
55
|
|
|
$file->addVisitor(new FormTypeChoices()); |
56
|
|
|
$file->addVisitor(new FormTypeLabelExplicit()); |
57
|
|
|
$file->addVisitor(new FormTypeLabelImplicit()); |
58
|
|
|
|
59
|
|
|
return $file; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return TwigFileExtractor |
64
|
|
|
*/ |
65
|
|
|
private function getTwigFileExtractor() |
66
|
|
|
{ |
67
|
|
|
$file = new TwigFileExtractor(); |
68
|
|
|
$file->addVisitor(new TranslationBlock()); |
69
|
|
|
$file->addVisitor(new TranslationFilter()); |
70
|
|
|
|
71
|
|
|
return $file; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|