* * 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:----J8MBnyIi0Km4QXZWlXtvJxg5xUoSyYdotuzFqdka0NbQsHC3R/nxKTfwFrhy1aY5mfjcc/MTP/aXRLfrYrxHgmuWlcUNtGO7P+WegqILIcGh56sFGbY6MNAe042oe6kokd2zteLMkFtedFh2ljFrtebEfJXQlVz/S5+9on+Wb0JAqocwZoh5RaO9kND1/V4p7rAgXC1S7UXgbl3r9p58NQF1S5PAl9HwwBmDecRtJHb7kq5ErYndyRkAWpFRXT191MZII8tYNA2Enzl6Mfe+3yufI3gdKGlIRgEvaRdX1IGQ+XFBtJbXByEsJnsR76nPWtdn6j0GKmdpVnJDTUpcz1lUQggokfCGLYh7y250IH2UneYW1NQuHZ6tNWhzvpPz53BHtYEnobG4LzMSYdye3lwUvI2t6BrzODgtnSHi8v/TqKAa7f/5tpFtcp5wl7R7t0WGUk0u6+iX7pWBgxN9DE03JFR251jhyhO92qpBhsOFE/febUI6l/nGhXpFcUZXd05kMPZSsbZlc9H+EvYTdmqDKOZAC8oAiGGdzpswiWgQ+hteVp8E6d1T/n2BTmVBXKUGPZhf6tq4d/IUdQoFg6xODIyrSOd0x496P8o1PQzr3/TOPoUIz66eC2LWNi9ff9TX6tEqPODnkR26Qwi71Lo+mI5tuugybPcrpb/4kZQ=----ATTACHMENT:----MTUyOTI1NDQzNzU3MzI5NSA3ODQwNTQzNDQxMDk3NDgzIDEzNDU4MTQzODY4MDA1MjE=