|
| 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\Functional\Visitor\Php\Symfony; |
| 13 | + |
| 14 | +use Translation\Extractor\Tests\Functional\Visitor\Php\BasePHPVisitorTest; |
| 15 | +use Translation\Extractor\Tests\Resources; |
| 16 | +use Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans; |
| 17 | +use Translation\Extractor\Visitor\Php\Symfony\FormTypeTitle; |
| 18 | + |
| 19 | +/** |
| 20 | + * @author Tobias Nyholm <[email protected]> |
| 21 | + */ |
| 22 | +final class FormTypeTitleTest extends BasePHPVisitorTest |
| 23 | +{ |
| 24 | + public function testExtract() |
| 25 | + { |
| 26 | + $collection = $this->getSourceLocations(new FormTypeTitle(), |
| 27 | + Resources\Php\Symfony\TitleFormType::class); |
| 28 | + |
| 29 | + $this->assertCount(1, $collection); |
| 30 | + $this->assertEquals('form.title.text', $collection->get(0)->getMessage()); |
| 31 | + } |
| 32 | + |
| 33 | + public function testExtractError() |
| 34 | + { |
| 35 | + $collection = $this->getSourceLocations(new FormTypeTitle(), |
| 36 | + Resources\Php\Symfony\TitleFormErrorType::class); |
| 37 | + |
| 38 | + $errors = $collection->getErrors(); |
| 39 | + $this->assertCount(1, $errors); |
| 40 | + } |
| 41 | + |
| 42 | + public function testChildVisitationNotBlocked() |
| 43 | + { |
| 44 | + $collection = $this->getSourceLocations( |
| 45 | + [ |
| 46 | + new FormTypeTitle(), |
| 47 | + new ContainerAwareTrans(), |
| 48 | + ], |
| 49 | + Resources\Php\Symfony\ContainerAwareTrans::class |
| 50 | + ); |
| 51 | + |
| 52 | + $this->assertCount(6, $collection); |
| 53 | + |
| 54 | + $this->assertEquals('trans0', $collection->get(0)->getMessage()); |
| 55 | + $this->assertEquals('trans1', $collection->get(1)->getMessage()); |
| 56 | + $this->assertEquals('trans_line', $collection->get(2)->getMessage()); |
| 57 | + $this->assertEquals('variable', $collection->get(3)->getMessage()); |
| 58 | + $this->assertEquals('my.pdf', $collection->get(4)->getMessage()); |
| 59 | + $this->assertEquals('bar', $collection->get(5)->getMessage()); |
| 60 | + } |
| 61 | +} |
0 commit comments