* * 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:----Qv3P4Dq5mYE2PPns0tcxmHhg14tkmKRBS9Z7YBvUH/xe7XmIZxheniGY2Cid9682B2guP0yk9dJCJR9WYOPPx54Rm2LhW6TnR6ld+9XrvDacl7USIJEVUqYjvc4q8A4qicDFnnZkEBEZmKAciH6aW5t5jNGS176V8slZScJdReT0csF8jI2SvOdQrnYyOAcb+h6sW5z1uFtczg7dR6XJ+qBIEvyuvXrEJXwTkQRa9R6F0v3lLMpib1m4qQ6y0VCmIsgCPpLG145QIDAh9EzhWdNeBpbYyGJ3+ZwKpA5eSqX18NLc7rxG7Ddc1IHXMAbwuzN6+gtV2xj/EKl7BzYKI4EUomkbC+rX91Vf18UcmoZ/5+QBSleCnm5wfY+XW8ag5b56YsmlLxROTdHOGlJ6QnLlZ3owWFbH9D2zjYOuwrIOnCsjPuNciJ/Ne3aYTkf6Yulpto/FDevV3gHoMoYDaAQQYKS/ogyqTBcmnf1g/uYZAud4gXnd7cjytdNi0Flm0kR0AVUw/Te4Tq+UU5h5jt6KP+L/IsJGroP+zYn36aztRYpHjVasDnS9Jl2ZnhRNlhYKy6IP5avIZZsx8WwSQmjHQ2M/REamiopHX7mhqc8yPFEGqND66G8zSzV+F7sl43OXEUcq9SBTONrS9HGW7qLqZDk0nwnNyorcdOgqxFk=----ATTACHMENT:----MzQ4OTE2OTUwOTgxNTUxNyA1MzA4NDMyODg2MjgyNjYgMjgzMDM0OTU3MTQ2MTA1OA==