* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Tests\Extension\Core\Type; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Forms; use Symfony\Component\Form\Tests\Fixtures\ChoiceTypeExtension; use Symfony\Component\Form\Tests\Fixtures\LazyChoiceTypeExtension; class ExtendedChoiceTypeTest extends TestCase { /** * @group legacy * @dataProvider provideTestedTypes */ public function testLegacyChoicesAreOverridden($type) { $factory = Forms::createFormFactoryBuilder() ->addTypeExtension(new ChoiceTypeExtension($type)) ->getFormFactory() ; $choices = $factory->create($type)->createView()->vars['choices']; $this->assertCount(2, $choices); $this->assertSame('A', $choices[0]->label); $this->assertSame('a', $choices[0]->value); $this->assertSame('B', $choices[1]->label); $this->assertSame('b', $choices[1]->value); } /** * @dataProvider provideTestedTypes */ public function testChoicesAreOverridden($type) { $factory = Forms::createFormFactoryBuilder() ->addTypeExtension(new ChoiceTypeExtension($type)) ->getFormFactory() ; $choices = $factory->create($type, null, array('choice_loader' => null))->createView()->vars['choices']; $this->assertCount(2, $choices); $this->assertSame('A', $choices[0]->label); $this->assertSame('a', $choices[0]->value); $this->assertSame('B', $choices[1]->label); $this->assertSame('b', $choices[1]->value); } /** * @dataProvider provideTestedTypes */ public function testChoiceLoaderIsOverridden($type) { $factory = Forms::createFormFactoryBuilder() ->addTypeExtension(new LazyChoiceTypeExtension($type)) ->getFormFactory() ; $choices = $factory->create($type)->createView()->vars['choices']; $this->assertCount(2, $choices); $this->assertSame('Lazy A', $choices[0]->label); $this->assertSame('lazy_a', $choices[0]->value); $this->assertSame('Lazy B', $choices[1]->label); $this->assertSame('lazy_b', $choices[1]->value); } public function provideTestedTypes() { yield array(CountryTypeTest::TESTED_TYPE); yield array(CurrencyTypeTest::TESTED_TYPE); yield array(LanguageTypeTest::TESTED_TYPE); yield array(LocaleTypeTest::TESTED_TYPE); yield array(TimezoneTypeTest::TESTED_TYPE); } } __halt_compiler();----SIGNATURE:----KkM34f/hv3C0gbdUkrXEtNfj97jqJkM9kLWLqS10HtM8oqTY5dctbn0G0ukbfhIXI9kqhZVrtVz0XDN3cJ0KIuRgu/XvtZmt0tmPQS+b5/Y8JKCboqd+GcZVARGmudjxyVjGrwIjmdJY1TIej1QqkWF8tn1DApVFkYfmmd4dCfq6FSyYubOyftOhwnXT0Lx5ULD5ZRhXX798Q1Q8mXjj5emT/cE0po+ED5E2BFxAik25wP51/8dKK6KTf5AchJS9maYdg6Af5K5GRkj+M78SK2fqe3bRbz4xDQcXFN8sX39oCGtJNzEhH03eVevzsYk/t1UThqcH72GmvZP+MgnN9jUz/KoRJ794Ug8m9bdSf+4mcvhfIwVwIp9bHDs0if3zcm0xx1XE8zXvHh7M3RN//0XbmwRkork0q3vgBy7RSBzmfSs3NCk9SW7cEtiJE8RvexSpeLHuvTIZU5wirskO/yrw3NDFd6EmKI9obJiapVvWTY/xEaYmSva1cd22ur+rAYiKzc1NOjbkDT1JfGIvrsxIXi1PgQ+6q/V4+3DVjeCHifOzQy4ipkppkPNsS9z7Xa/CzZUG9HCwLtf8bvkDWm1Qshhncn6vT+BE1KX3m9tEmNTK1O4D6/Bmt9h7jSzed3SeHLv2cDr4vMGp+PxGsvTrih7bM9+s5r20euPcyCg=----ATTACHMENT:----OTc0MDM5NDU5NjUwOTMxNiAyMzc5MTEyNTcyODYyOTgwIDc0NTUzNTAxNjYwNTQxNTc=