Merge branch '2.8'
* 2.8: [Form] Fix missing choices_as_values=true in tests [HttpFoundation] Deprecate $deep parameter on ParameterBag Conflicts: src/Symfony/Component/HttpFoundation/ParameterBag.php src/Symfony/Component/HttpFoundation/Request.php
This commit is contained in:
commit
aa4bc475ed
@ -212,7 +212,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoice()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
));
|
||||
@ -234,7 +235,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'choice_translation_domain' => false,
|
||||
@ -257,7 +259,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceWithPlaceholderWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'required' => false,
|
||||
@ -283,7 +286,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceAttributes()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -306,7 +310,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceWithPreferred()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'preferred_choices' => array('&b'),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -330,7 +335,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceWithPreferredAndNoSeparator()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'preferred_choices' => array('&b'),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -353,7 +359,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceWithPreferredAndBlankSeparator()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'preferred_choices' => array('&b'),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -377,7 +384,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testChoiceWithOnlyPreferred()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'preferred_choices' => array('&a', '&b'),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -394,7 +402,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceNonRequired()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => false,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -418,7 +427,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceNonRequiredNoneSelected()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => false,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -442,7 +452,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceNonRequiredWithPlaceholder()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'required' => false,
|
||||
@ -467,7 +478,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceRequiredWithPlaceholder()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -492,7 +504,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceRequiredWithPlaceholderViaView()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -517,9 +530,10 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array(
|
||||
'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'Group&2' => array('&c' => 'Choice&C'),
|
||||
'Group&1' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'Group&2' => array('Choice&C' => '&c'),
|
||||
),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
));
|
||||
@ -547,7 +561,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testMultipleChoice()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => true,
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
@ -571,7 +586,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testMultipleChoiceAttributes()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||
'required' => true,
|
||||
'multiple' => true,
|
||||
@ -596,7 +612,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testMultipleChoiceSkipsPlaceholder()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
'placeholder' => 'Test&Me',
|
||||
@ -619,7 +636,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testMultipleChoiceNonRequired()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
@ -642,7 +660,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceExpanded()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
));
|
||||
@ -677,7 +696,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceExpandedWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'choice_translation_domain' => false,
|
||||
@ -713,7 +733,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceExpandedAttributes()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
@ -749,7 +770,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceExpandedWithPlaceholder()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'placeholder' => 'Test&Me',
|
||||
@ -794,7 +816,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'translation_domain' => false,
|
||||
@ -840,7 +863,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testSingleChoiceExpandedWithBooleanValue()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array(
|
||||
'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '1', 'Choice&B' => '0'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
));
|
||||
@ -875,7 +899,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testMultipleChoiceExpanded()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => true,
|
||||
@ -920,7 +945,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testMultipleChoiceExpandedWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => true,
|
||||
@ -966,7 +992,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
public function testMultipleChoiceExpandedAttributes()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
|
||||
'choices_as_values' => true,
|
||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
|
@ -691,7 +691,8 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
public function testChoiceRowWithCustomBlock()
|
||||
{
|
||||
$form = $this->factory->createNamedBuilder('name_c', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', 'a', array(
|
||||
'choices' => array('a' => 'ChoiceA', 'b' => 'ChoiceB'),
|
||||
'choices' => array('ChoiceA' => 'a', 'ChoiceB' => 'b'),
|
||||
'choices_as_values' => true,
|
||||
'expanded' => true,
|
||||
))
|
||||
->getForm();
|
||||
|
@ -487,7 +487,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoice()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
));
|
||||
@ -520,7 +521,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'choice_translation_domain' => false,
|
||||
@ -542,7 +544,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceWithPlaceholderWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'required' => false,
|
||||
@ -567,7 +570,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceAttributes()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -589,7 +593,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceWithPreferred()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'preferred_choices' => array('&b'),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -612,7 +617,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceWithPreferredAndNoSeparator()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'preferred_choices' => array('&b'),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -634,7 +640,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceWithPreferredAndBlankSeparator()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'preferred_choices' => array('&b'),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -657,7 +664,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testChoiceWithOnlyPreferred()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'preferred_choices' => array('&a', '&b'),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -673,7 +681,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceNonRequired()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => false,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -696,7 +705,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceNonRequiredNoneSelected()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => false,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -719,7 +729,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceNonRequiredWithPlaceholder()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'required' => false,
|
||||
@ -743,7 +754,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceRequiredWithPlaceholder()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -770,7 +782,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceRequiredWithPlaceholderViaView()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -797,9 +810,10 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array(
|
||||
'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'Group&2' => array('&c' => 'Choice&C'),
|
||||
'Group&1' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'Group&2' => array('Choice&C' => '&c'),
|
||||
),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
));
|
||||
@ -826,7 +840,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testMultipleChoice()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => true,
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
@ -849,7 +864,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testMultipleChoiceAttributes()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||
'required' => true,
|
||||
'multiple' => true,
|
||||
@ -873,7 +889,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testMultipleChoiceSkipsPlaceholder()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
'placeholder' => 'Test&Me',
|
||||
@ -895,7 +912,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testMultipleChoiceNonRequired()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
@ -917,7 +935,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceExpanded()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
));
|
||||
@ -939,7 +958,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceExpandedWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'choice_translation_domain' => false,
|
||||
@ -962,7 +982,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceExpandedAttributes()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
@ -985,7 +1006,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceExpandedWithPlaceholder()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'placeholder' => 'Test&Me',
|
||||
@ -1010,7 +1032,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'translation_domain' => false,
|
||||
@ -1036,7 +1059,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testSingleChoiceExpandedWithBooleanValue()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array(
|
||||
'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'),
|
||||
'choices' => array('Choice&A' => '1', 'Choice&B' => '0'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
));
|
||||
@ -1058,7 +1082,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testMultipleChoiceExpanded()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => true,
|
||||
@ -1083,7 +1108,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testMultipleChoiceExpandedWithoutTranslation()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
|
||||
'choices_as_values' => true,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => true,
|
||||
@ -1109,7 +1135,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
public function testMultipleChoiceExpandedAttributes()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
|
||||
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
|
||||
'choices_as_values' => true,
|
||||
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
|
@ -163,7 +163,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
public function getDigits($key, $default = '', $deep = false)
|
||||
{
|
||||
// we need to remove - and + because they're allowed in the filter
|
||||
return str_replace(array('-', '+'), '', $this->filter($key, $default, $deep, FILTER_SANITIZE_NUMBER_INT));
|
||||
return str_replace(array('-', '+'), '', $this->filter($key, $default, FILTER_SANITIZE_NUMBER_INT, array(), $deep));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,7 +191,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function getBoolean($key, $default = false, $deep = false)
|
||||
{
|
||||
return $this->filter($key, $default, $deep, FILTER_VALIDATE_BOOLEAN);
|
||||
return $this->filter($key, $default, FILTER_VALIDATE_BOOLEAN, array(), $deep);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,16 +199,31 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @param string $key Key.
|
||||
* @param mixed $default Default = null.
|
||||
* @param bool $deep Default = false.
|
||||
* @param int $filter FILTER_* constant.
|
||||
* @param mixed $options Filter options.
|
||||
* @param bool $deep Default = false.
|
||||
*
|
||||
* @see http://php.net/manual/en/function.filter-var.php
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter($key, $default = null, $deep = false, $filter = FILTER_DEFAULT, $options = array())
|
||||
public function filter($key, $default = null, $filter = FILTER_DEFAULT, $options = array(), $deep = false)
|
||||
{
|
||||
static $filters = null;
|
||||
|
||||
if (null === $filters) {
|
||||
foreach (filter_list() as $tmp) {
|
||||
$filters[filter_id($tmp)] = 1;
|
||||
}
|
||||
}
|
||||
if (is_bool($filter) || !isset($filters[$filter]) || is_array($deep)) {
|
||||
@trigger_error('Passing the $deep boolean as 3rd argument to the '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Remove it altogether as the $deep argument will be removed in 3.0.', E_USER_ERROR);
|
||||
$tmp = $deep;
|
||||
$deep = $filter;
|
||||
$filter = $options;
|
||||
$options = $tmp;
|
||||
}
|
||||
|
||||
$value = $this->get($key, $default, $deep);
|
||||
|
||||
// Always turn $options into an array - this allows filter_var option shortcuts.
|
||||
|
@ -137,26 +137,26 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEmpty($bag->filter('nokey'), '->filter() should return empty by default if no key is found');
|
||||
|
||||
$this->assertEquals('0123', $bag->filter('digits', '', false, FILTER_SANITIZE_NUMBER_INT), '->filter() gets a value of parameter as integer filtering out invalid characters');
|
||||
$this->assertEquals('0123', $bag->filter('digits', '', FILTER_SANITIZE_NUMBER_INT), '->filter() gets a value of parameter as integer filtering out invalid characters');
|
||||
|
||||
$this->assertEquals('example@example.com', $bag->filter('email', '', false, FILTER_VALIDATE_EMAIL), '->filter() gets a value of parameter as email');
|
||||
$this->assertEquals('example@example.com', $bag->filter('email', '', FILTER_VALIDATE_EMAIL), '->filter() gets a value of parameter as email');
|
||||
|
||||
$this->assertEquals('http://example.com/foo', $bag->filter('url', '', false, FILTER_VALIDATE_URL, array('flags' => FILTER_FLAG_PATH_REQUIRED)), '->filter() gets a value of parameter as URL with a path');
|
||||
$this->assertEquals('http://example.com/foo', $bag->filter('url', '', FILTER_VALIDATE_URL, array('flags' => FILTER_FLAG_PATH_REQUIRED)), '->filter() gets a value of parameter as URL with a path');
|
||||
|
||||
// This test is repeated for code-coverage
|
||||
$this->assertEquals('http://example.com/foo', $bag->filter('url', '', false, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as URL with a path');
|
||||
$this->assertEquals('http://example.com/foo', $bag->filter('url', '', FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as URL with a path');
|
||||
|
||||
$this->assertFalse($bag->filter('dec', '', false, FILTER_VALIDATE_INT, array(
|
||||
$this->assertFalse($bag->filter('dec', '', FILTER_VALIDATE_INT, array(
|
||||
'flags' => FILTER_FLAG_ALLOW_HEX,
|
||||
'options' => array('min_range' => 1, 'max_range' => 0xff),
|
||||
)), '->filter() gets a value of parameter as integer between boundaries');
|
||||
|
||||
$this->assertFalse($bag->filter('hex', '', false, FILTER_VALIDATE_INT, array(
|
||||
$this->assertFalse($bag->filter('hex', '', FILTER_VALIDATE_INT, array(
|
||||
'flags' => FILTER_FLAG_ALLOW_HEX,
|
||||
'options' => array('min_range' => 1, 'max_range' => 0xff),
|
||||
)), '->filter() gets a value of parameter as integer between boundaries');
|
||||
|
||||
$this->assertEquals(array('bang'), $bag->filter('array', '', false), '->filter() gets a value of parameter as an array');
|
||||
$this->assertEquals(array('bang'), $bag->filter('array', ''), '->filter() gets a value of parameter as an array');
|
||||
}
|
||||
|
||||
public function testGetIterator()
|
||||
|
Reference in New Issue
Block a user