Merge branch '2.8' into 3.0

* 2.8:
  make tests compatible with Symfony 2.8 and 3.0
This commit is contained in:
Fabien Potencier 2016-01-21 07:33:42 +01:00
commit 78c8543d25
2 changed files with 6 additions and 14 deletions

View File

@ -13,7 +13,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\Tests\Fixtures\ChoiceSubType;
class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
{
@ -1491,14 +1490,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';
}
}