Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/Functional/Visitor/Php/BasePHPVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 23 additions & 2 deletions tests/Functional/Visitor/Php/Symfony/FormTypePlaceholderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tobias.nyholm@gmail.com>
Expand All @@ -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());
Expand All @@ -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());
}
}