make tests compatible with Symfony 2.8 and 3.0

This commit is contained in:
Christian Flothmann 2016-01-20 20:58:57 +01:00
parent fd50be95d9
commit 4d2930e52a
2 changed files with 6 additions and 14 deletions

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
use Symfony\Component\Form\Tests\Fixtures\ChoiceSubType;
class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
{
@ -1914,14 +1913,15 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
public function testCustomChoiceTypeDoesNotInheritChoiceLabels()
{
$builder = $this->factory->createBuilder();
$builder->add('choice', 'choice', array(
$builder->add('choice', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
'choices' => array(
'1' => '1',
'2' => '2',
),
'choices_as_values' => true,
)
);
$builder->add('subChoice', new ChoiceSubType());
$builder->add('subChoice', 'Symfony\Component\Form\Tests\Fixtures\ChoiceSubType');
$form = $builder->getForm();
// The default 'choices' normalizer would fill the $choiceLabels, but it has been replaced

View File

@ -16,7 +16,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Paráda József <joczy.parada@gmail.com>
*/
*/
class ChoiceSubType extends AbstractType
{
/**
@ -24,7 +24,7 @@ class ChoiceSubType extends AbstractType
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array('expanded' => true));
$resolver->setDefaults(array('expanded' => true, 'choices_as_values' => true));
$resolver->setNormalizer('choices', function () {
return array(
'attr1' => 'Attribute 1',
@ -33,19 +33,11 @@ class ChoiceSubType extends AbstractType
});
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sub_choice';
}
/**
* {@inheritdoc}
*/
public function getParent()
{
return 'choice';
return 'Symfony\Component\Form\Extension\Core\Type\ChoiceType';
}
}