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