|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the PHP Translation package. |
| 5 | + * |
| 6 | + * (c) PHP Translation team <tobias.nyholm@gmail.com> |
| 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\FormTypeChoices; |
| 17 | +use Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue; |
| 18 | +use Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage; |
| 19 | +use Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit; |
| 20 | +use Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit; |
| 21 | +use Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder; |
| 22 | + |
| 23 | +/** |
| 24 | + * @author Rein Baarsma <rein@solidwebcode.com> |
| 25 | + */ |
| 26 | +class FormTypeLabelTest extends BasePHPVisitorTest |
| 27 | +{ |
| 28 | + private $allFormVisitors; |
| 29 | + |
| 30 | + public function __construct() |
| 31 | + { |
| 32 | + $this->allFormVisitors = [ |
| 33 | + new FormTypeChoices(), |
| 34 | + new FormTypeEmptyValue(), |
| 35 | + new FormTypeInvalidMessage(), |
| 36 | + new FormTypeLabelExplicit(), |
| 37 | + new FormTypeLabelImplicit(), |
| 38 | + new FormTypePlaceholder(), |
| 39 | + ]; |
| 40 | + |
| 41 | + parent::__construct(); |
| 42 | + } |
| 43 | + |
| 44 | + public function testTranslationDomain() |
| 45 | + { |
| 46 | + $collection = $this->getSourceLocations($this->allFormVisitors, Resources\Php\Symfony\FormDomainType::class); |
| 47 | + |
| 48 | + $messageA = $collection->get(0); |
| 49 | + $this->assertEquals('label1', $messageA->getMessage()); |
| 50 | + $this->assertEquals('admin0', $messageA->getContext()['domain']); |
| 51 | + |
| 52 | + $messageB = $collection->get(1); |
| 53 | + $this->assertEquals('test_b', $messageB->getMessage()); |
| 54 | + $this->assertEquals('admin1', $messageB->getContext()['domain']); |
| 55 | + |
| 56 | + $messageC = $collection->get(2); |
| 57 | + $this->assertEquals('test_c', $messageC->getMessage()); |
| 58 | + $this->assertNull($messageC->getContext()['domain']); |
| 59 | + |
| 60 | + // We should not have "test_d" or "test_e" |
| 61 | + $this->assertEquals(3, $collection->count(), 'We should ignore choices where "translation_domain" is "false"'); |
| 62 | + } |
| 63 | +} |
0 commit comments