|
| 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 | + public function testNoException() |
| 36 | + { |
| 37 | + $extractor = new Extractor(); |
| 38 | + $extractor->addFileExtractor($this->getPHPFileExtractor()); |
| 39 | + $extractor->addFileExtractor($this->getTwigFileExtractor()); |
| 40 | + |
| 41 | + $finder = new Finder(); |
| 42 | + $finder->in(dirname(__DIR__)); |
| 43 | + |
| 44 | + $extractor->extract($finder); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @return PHPFileExtractor |
| 49 | + */ |
| 50 | + private function getPHPFileExtractor() |
| 51 | + { |
| 52 | + $file = new PHPFileExtractor(); |
| 53 | + $file->addVisitor(new ContainerAwareTrans()); |
| 54 | + $file->addVisitor(new ContainerAwareTransChoice()); |
| 55 | + $file->addVisitor(new FlashMessage()); |
| 56 | + $file->addVisitor(new FormTypeChoices()); |
| 57 | + $file->addVisitor(new FormTypeLabelExplicit()); |
| 58 | + $file->addVisitor(new FormTypeLabelImplicit()); |
| 59 | + |
| 60 | + return $file; |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * @return TwigFileExtractor |
| 65 | + */ |
| 66 | + private function getTwigFileExtractor() |
| 67 | + { |
| 68 | + $file = new TwigFileExtractor(TwigEnvironmentFactory::create()); |
| 69 | + $file->addVisitor(new TranslationBlock()); |
| 70 | + $file->addVisitor(new TranslationFilter()); |
| 71 | + |
| 72 | + return $file; |
| 73 | + } |
| 74 | +} |
0 commit comments