diff --git a/tests/Functional/Visitor/Php/BasePHPVisitorTest.php b/tests/Functional/Visitor/Php/BasePHPVisitorTest.php index b2e89ee..370f27a 100644 --- a/tests/Functional/Visitor/Php/BasePHPVisitorTest.php +++ b/tests/Functional/Visitor/Php/BasePHPVisitorTest.php @@ -31,7 +31,14 @@ abstract class BasePHPVisitorTest extends \PHPUnit_Framework_TestCase protected function getSourceLocations($visitor, $namespaceForTestFile) { $extractor = new PHPFileExtractor(); - $extractor->addVisitor($visitor); + + if (is_array($visitor)) { + foreach($visitor as $nodeVisitor) { + $extractor->addVisitor($nodeVisitor); + } + } else { + $extractor->addVisitor($visitor); + } $currentNamespace = explode('\\', __NAMESPACE__); $fileNamespace = explode('\\', $namespaceForTestFile); diff --git a/tests/Functional/Visitor/Php/Symfony/FormTypePlaceholderTest.php b/tests/Functional/Visitor/Php/Symfony/FormTypePlaceholderTest.php index cf97b8d..f9a2cab 100644 --- a/tests/Functional/Visitor/Php/Symfony/FormTypePlaceholderTest.php +++ b/tests/Functional/Visitor/Php/Symfony/FormTypePlaceholderTest.php @@ -14,6 +14,7 @@ use Translation\Extractor\Tests\Functional\Visitor\Php\BasePHPVisitorTest; use Translation\Extractor\Tests\Resources; use Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder; +use Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans; /** * @author Tobias Nyholm @@ -22,7 +23,8 @@ final class FormTypePlaceholderTest extends BasePHPVisitorTest { public function testExtract() { - $collection = $this->getSourceLocations(new FormTypePlaceholder(), Resources\Php\Symfony\PlaceholderFormType::class); + $collection = $this->getSourceLocations(new FormTypePlaceholder(), + Resources\Php\Symfony\PlaceholderFormType::class); $this->assertCount(3, $collection); $this->assertEquals('form.placeholder.text', $collection->get(0)->getMessage()); @@ -32,9 +34,28 @@ public function testExtract() public function testExtractError() { - $collection = $this->getSourceLocations(new FormTypePlaceholder(), Resources\Php\Symfony\PlaceholderFormErrorType::class); + $collection = $this->getSourceLocations(new FormTypePlaceholder(), + Resources\Php\Symfony\PlaceholderFormErrorType::class); $errors = $collection->getErrors(); $this->assertCount(3, $errors); } + + public function testChildVisitationNotBlocked() + { + $collection = $this->getSourceLocations( + [ + new FormTypePlaceholder(), + new ContainerAwareTrans(), + ], + Resources\Php\Symfony\ContainerAwareTrans::class + ); + + $this->assertCount(4, $collection); + + $this->assertEquals('trans0', $collection->get(0)->getMessage()); + $this->assertEquals('trans1', $collection->get(1)->getMessage()); + $this->assertEquals('trans_line', $collection->get(2)->getMessage()); + $this->assertEquals('variable', $collection->get(3)->getMessage()); + } }