|
12 | 12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; |
13 | 13 |
|
14 | 14 | use Symfony\Component\Form\ChoiceList\View\ChoiceView; |
| 15 | +use Symfony\Component\Form\Exception\LogicException; |
15 | 16 | use Symfony\Component\Intl\Util\IntlTestHelper; |
16 | 17 |
|
17 | 18 | class LanguageTypeTest extends BaseTypeTest |
@@ -97,22 +98,35 @@ public function testChoiceSelfTranslationOption() |
97 | 98 | ]) |
98 | 99 | ->createView()->vars['choices']; |
99 | 100 |
|
100 | | - // Don't check objects for identity |
101 | | - $this->assertContains(new ChoiceView('cs', 'cs', 'čeština'), $choices, '', false, false); |
102 | | - $this->assertContains(new ChoiceView('es', 'es', 'español'), $choices, '', false, false); |
103 | | - $this->assertContains(new ChoiceView('fr', 'fr', 'français'), $choices, '', false, false); |
104 | | - $this->assertContains(new ChoiceView('ta', 'ta', 'தமிழ்'), $choices, '', false, false); |
105 | | - $this->assertContains(new ChoiceView('uk', 'uk', 'українська'), $choices, '', false, false); |
106 | | - $this->assertContains(new ChoiceView('yi', 'yi', 'ייִדיש'), $choices, '', false, false); |
107 | | - $this->assertContains(new ChoiceView('zh', 'zh', '中文'), $choices, '', false, false); |
108 | | - $this->assertContains(new ChoiceView('zh_Hant', 'zh_Hant', '繁體中文'), $choices, '', false, false); |
| 101 | + $this->assertContainsEquals(new ChoiceView('cs', 'cs', 'čeština'), $choices); |
| 102 | + $this->assertContainsEquals(new ChoiceView('es', 'es', 'español'), $choices); |
| 103 | + $this->assertContainsEquals(new ChoiceView('fr', 'fr', 'français'), $choices); |
| 104 | + $this->assertContainsEquals(new ChoiceView('ta', 'ta', 'தமிழ்'), $choices); |
| 105 | + $this->assertContainsEquals(new ChoiceView('uk', 'uk', 'українська'), $choices); |
| 106 | + $this->assertContainsEquals(new ChoiceView('yi', 'yi', 'ייִדיש'), $choices); |
| 107 | + $this->assertContainsEquals(new ChoiceView('zh', 'zh', '中文'), $choices); |
<
8000
tr class="diff-line-row">109 | 108 | } | 110 | 109 |
|
111 | 110 | /** |
112 | | - * @expectedException \Symfony\Component\Form\Exception\LogicException |
| 111 | + * @requires extension intl |
113 | 112 | */ |
| 113 | + public function testChoiceSelfTranslationAndAlpha3Options() |
| 114 | + { |
| 115 | + $choices = $this->factory |
| 116 | + ->create(static::TESTED_TYPE, null, [ |
| 117 | + 'alpha3' => true, |
| 118 | + 'choice_self_translation' => true, |
| 119 | + ]) |
| 120 | + ->createView()->vars['choices']; |
| 121 | + |
| 122 | + $this->assertContainsEquals(new ChoiceView('spa', 'spa', 'español'), $choices, '', false, false); |
| 123 | + $this->assertContainsEquals(new ChoiceView('yid', 'yid', 'ייִדיש'), $choices, '', false, false); |
| 124 | + } |
| 125 | + |
114 | 126 | public function testSelfTranslationNotAllowedWithChoiceTranslation() |
115 | 127 | { |
| 128 | + $this->expectException(LogicException::class); |
| 129 | + |
116 | 130 | $this->factory->create(static::TESTED_TYPE, null, [ |
117 | 131 | 'choice_translation_locale' => 'es', |
118 | 132 | 'choice_self_translation' => true, |
|
0 commit comments