From ed0e26a620978f5173bc83bf3cd7ca8f6829c12c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 27 Nov 2015 17:52:10 +0100 Subject: [PATCH] [Form] Remove choices_as_values option on ChoiceType --- .../Doctrine/Form/Type/DoctrineType.php | 1 - src/Symfony/Bridge/Doctrine/composer.json | 2 +- .../Form/ChoiceList/ArrayKeyChoiceList.php | 190 --------------- .../Factory/CachingFactoryDecorator.php | 29 --- .../Factory/ChoiceListFactoryInterface.php | 22 -- .../Factory/DefaultChoiceListFactory.php | 16 -- .../Factory/PropertyAccessDecorator.php | 19 -- .../Form/Extension/Core/Type/ChoiceType.php | 18 +- .../Form/Extension/Core/Type/CountryType.php | 1 - .../Form/Extension/Core/Type/CurrencyType.php | 1 - .../Form/Extension/Core/Type/DateType.php | 3 - .../Form/Extension/Core/Type/LanguageType.php | 1 - .../Form/Extension/Core/Type/LocaleType.php | 1 - .../Form/Extension/Core/Type/TimeType.php | 3 - .../Form/Extension/Core/Type/TimezoneType.php | 1 - .../Tests/AbstractBootstrap3LayoutTest.php | 27 --- .../Form/Tests/AbstractDivLayoutTest.php | 1 - .../Form/Tests/AbstractLayoutTest.php | 27 --- .../ChoiceList/ArrayKeyChoiceListTest.php | 183 --------------- .../Extension/Core/Type/ChoiceTypeTest.php | 218 ------------------ 20 files changed, 9 insertions(+), 755 deletions(-) delete mode 100644 src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php delete mode 100644 src/Symfony/Component/Form/Tests/ChoiceList/ArrayKeyChoiceListTest.php diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index c6612246804b2..353c18528710f 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -259,7 +259,6 @@ public function configureOptions(OptionsResolver $resolver) 'em' => null, 'query_builder' => null, 'choices' => null, - 'choices_as_values' => true, 'choice_loader' => $choiceLoader, 'choice_label' => array(__CLASS__, 'createChoiceLabel'), 'choice_name' => $choiceName, diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 0e686e1ccee2e..d1443b369858d 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -22,7 +22,7 @@ "require-dev": { "symfony/stopwatch": "~2.8|~3.0", "symfony/dependency-injection": "~2.8|~3.0", - "symfony/form": "~2.8|~3.0", + "symfony/form": "~3.0,>3.0-BETA1", "symfony/http-kernel": "~2.8|~3.0", "symfony/property-access": "~2.8|~3.0", "symfony/property-info": "~2.8|3.0", diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php deleted file mode 100644 index 183b849fe9a8c..0000000000000 --- a/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php +++ /dev/null @@ -1,190 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\ChoiceList; - -@trigger_error('The '.__NAMESPACE__.'\ArrayKeyChoiceList class is deprecated since version 2.8 and will be removed in 3.0. Use '.__NAMESPACE__.'\ArrayChoiceList instead.', E_USER_DEPRECATED); - -use Symfony\Component\Form\Exception\InvalidArgumentException; - -/** - * A list of choices that can be stored in the keys of a PHP array. - * - * PHP arrays accept only strings and integers as array keys. Other scalar types - * are cast to integers and strings according to the description of - * {@link toArrayKey()}. This implementation applies the same casting rules for - * the choices passed to the constructor and to {@link getValuesForChoices()}. - * - * By default, the choices are cast to strings and used as values. Optionally, - * you may pass custom values. The keys of the value array must match the keys - * of the choice array. - * - * Example: - * - * ```php - * $choices = array('' => 'Don\'t know', 0 => 'No', 1 => 'Yes'); - * $choiceList = new ArrayKeyChoiceList(array_keys($choices)); - * - * $values = $choiceList->getValues() - * // => array('', '0', '1') - * - * $selectedValues = $choiceList->getValuesForChoices(array(true)); - * // => array('1') - * ``` - * - * @author Bernhard Schussek - * - * @deprecated since version 2.8, to be removed in 3.0. Use ArrayChoiceList instead. - */ -class ArrayKeyChoiceList extends ArrayChoiceList -{ - /** - * Whether the choices are used as values. - * - * @var bool - */ - private $useChoicesAsValues = false; - - /** - * Casts the given choice to an array key. - * - * PHP arrays accept only strings and integers as array keys. Integer - * strings such as "42" are automatically cast to integers. The boolean - * values "true" and "false" are cast to the integers 1 and 0. Every other - * scalar value is cast to a string. - * - * @param mixed $choice The choice - * - * @return int|string The choice as PHP array key - * - * @throws InvalidArgumentException If the choice is not scalar - * - * @internal Must not be used outside this class - */ - public static function toArrayKey($choice) - { - if (!is_scalar($choice) && null !== $choice) { - throw new InvalidArgumentException(sprintf( - 'The value of type "%s" cannot be converted to a valid array key.', - gettype($choice) - )); - } - - if (is_bool($choice) || (string) (int) $choice === (string) $choice) { - return (int) $choice; - } - - return (string) $choice; - } - - /** - * Creates a list with the given choices and values. - * - * The given choice array must have the same array keys as the value array. - * Each choice must be castable to an integer/string according to the - * casting rules described in {@link toArrayKey()}. - * - * If no values are given, the choices are cast to strings and used as - * values. - * - * @param array|\Traversable $choices The selectable choices - * @param callable $value The callable for creating the value - * for a choice. If `null` is passed, the - * choices are cast to strings and used - * as values - * - * @throws InvalidArgumentException If the keys of the choices don't match - * the keys of the values or if any of the - * choices is not scalar - */ - public function __construct($choices, callable $value = null) - { - // If no values are given, use the choices as values - // Since the choices are stored in the collection keys, i.e. they are - // strings or integers, we are guaranteed to be able to convert them - // to strings - if (null === $value) { - $value = function ($choice) { - return (string) $choice; - }; - - $this->useChoicesAsValues = true; - } - - parent::__construct($choices, $value); - } - - /** - * {@inheritdoc} - */ - public function getChoicesForValues(array $values) - { - if ($this->useChoicesAsValues) { - $values = array_map('strval', $values); - - // If the values are identical to the choices, so we can just return - // them to improve performance a little bit - return array_map(array(__CLASS__, 'toArrayKey'), array_intersect($values, array_keys($this->choices))); - } - - return parent::getChoicesForValues($values); - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - $choices = array_map(array(__CLASS__, 'toArrayKey'), $choices); - - if ($this->useChoicesAsValues) { - // If the choices are identical to the values, we can just return - // them to improve performance a little bit - return array_map('strval', array_intersect($choices, $this->choices)); - } - - return parent::getValuesForChoices($choices); - } - - /** - * Flattens and flips an array into the given output variable. - * - * @param array $choices The array to flatten - * @param callable $value The callable for generating choice values - * @param array $choicesByValues The flattened choices indexed by the - * corresponding values - * @param array $keysByValues The original keys indexed by the - * corresponding values - * - * @internal Must not be used by user-land code - */ - protected function flatten(array $choices, $value, &$choicesByValues, &$keysByValues, &$structuredValues) - { - if (null === $choicesByValues) { - $choicesByValues = array(); - $keysByValues = array(); - $structuredValues = array(); - } - - foreach ($choices as $choice => $key) { - if (is_array($key)) { - $this->flatten($key, $value, $choicesByValues, $keysByValues, $structuredValues[$choice]); - - continue; - } - - $choiceValue = (string) call_user_func($value, $choice); - $choicesByValues[$choiceValue] = $choice; - $keysByValues[$choiceValue] = $key; - $structuredValues[$key] = $choiceValue; - } - } -} diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php index ae7f2375bb896..6580e661d4d66 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php @@ -135,35 +135,6 @@ public function createListFromChoices($choices, $value = null) return $this->lists[$hash]; } - /** - * {@inheritdoc} - * - * @deprecated Added for backwards compatibility in Symfony 2.7, to be - * removed in Symfony 3.0. - */ - public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true) - { - if ($choices instanceof \Traversable) { - $choices = iterator_to_array($choices); - } - - // The value is not validated on purpose. The decorated factory may - // decide which values to accept and which not. - - // We ignore the choice groups for caching. If two choice lists are - // requested with the same choices, but a different grouping, the same - // choice list is returned. - self::flatten($choices, $flatChoices); - - $hash = self::generateHash(array($flatChoices, $value), 'fromFlippedChoices'); - - if (!isset($this->lists[$hash])) { - $this->lists[$hash] = $this->decoratedFactory->createListFromFlippedChoices($choices, $value, $triggerDeprecationNotice); - } - - return $this->lists[$hash]; - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php b/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php index 7933dd91d48d7..1c6f24d6986f8 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php @@ -39,28 +39,6 @@ interface ChoiceListFactoryInterface */ public function createListFromChoices($choices, $value = null); - /** - * Creates a choice list for the given choices. - * - * The choices should be passed in the keys of the choices array. Since the - * choices array will be flipped, the entries of the array must be strings - * or integers. - * - * Optionally, a callable can be passed for generating the choice values. - * The callable receives the choice as first and the array key as the second - * argument. - * - * @param array|\Traversable $choices The choices - * @param null|callable $value The callable generating the choice - * values - * - * @return ChoiceListInterface The choice list - * - * @deprecated Added for backwards compatibility in Symfony 2.7, to be - * removed in Symfony 3.0. - */ - public function createListFromFlippedChoices($choices, $value = null); - /** * Creates a choice list that is loaded with the given loader. * diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php index f49be10c36392..e632c1238c861 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Form\ChoiceList\Factory; -use Symfony\Component\Form\ChoiceList\ArrayKeyChoiceList; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\LazyChoiceList; @@ -35,21 +34,6 @@ public function createListFromChoices($choices, $value = null) return new ArrayChoiceList($choices, $value); } - /** - * {@inheritdoc} - * - * @deprecated Added for backwards compatibility in Symfony 2.7, to be - * removed in Symfony 3.0. - */ - public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true) - { - if ($triggerDeprecationNotice) { - @trigger_error('The '.__METHOD__.' is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED); - } - - return new ArrayKeyChoiceList($choices, $value); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php index 1b68fd8924284..130cd49f78bd2 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php @@ -104,25 +104,6 @@ public function createListFromChoices($choices, $value = null) return $this->decoratedFactory->createListFromChoices($choices, $value); } - /** - * {@inheritdoc} - * - * @param array|\Traversable $choices The choices - * @param null|callable|string|PropertyPath $value The callable or path for - * generating the choice values - * - * @return ChoiceListInterface The choice list - * - * @deprecated Added for backwards compatibility in Symfony 2.7, to be - * removed in Symfony 3.0. - */ - public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true) - { - // Property paths are not supported here, because array keys can never - // be objects - return $this->decoratedFactory->createListFromFlippedChoices($choices, $value, $triggerDeprecationNotice); - } - /** * {@inheritdoc} * diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 4d3ad7719595a..6c4cf9ccaae36 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -260,20 +260,19 @@ public function configureOptions(OptionsResolver $resolver) // Harden against NULL values (like in EntityType and ModelType) $choices = null !== $options['choices'] ? $options['choices'] : array(); - // BC when choices are in the keys, not in the values - if (!$options['choices_as_values']) { - return $choiceListFactory->createListFromFlippedChoices($choices, $options['choice_value'], false); - } - return $choiceListFactory->createListFromChoices($choices, $options['choice_value']); }; $choicesAsValuesNormalizer = function (Options $options, $choicesAsValues) { - if (true !== $choicesAsValues) { - @trigger_error('The value "false" for the "choices_as_values" option is deprecated since version 2.8 and will not be supported anymore in 3.0. Set this option to "true" and flip the contents of the "choices" option instead.', E_USER_DEPRECATED); + if (null !== $choicesAsValues) { + if (true !== $choicesAsValues) { + throw new \RuntimeException('The "choices_as_values" option should not be used. Remove it and flip the contents of the "choices" option instead.'); + } + // To be uncommented in 3.1 + //@trigger_error('The "choices_as_values" option is deprecated since version 3.1 and will be removed in 4.0. You should not use it anymore.', E_USER_DEPRECATED); } - return $choicesAsValues; + return true; }; $placeholderNormalizer = function (Options $options, $placeholder) { @@ -309,7 +308,7 @@ public function configureOptions(OptionsResolver $resolver) 'expanded' => false, 'choice_list' => null, // deprecated 'choices' => array(), - 'choices_as_values' => false, + 'choices_as_values' => null, // to be deprecated in 3.1 'choice_loader' => null, 'choice_label' => null, 'choice_name' => null, @@ -336,7 +335,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('choice_list', array('null', 'Symfony\Component\Form\ChoiceList\ChoiceListInterface')); $resolver->setAllowedTypes('choices', array('null', 'array', '\Traversable')); $resolver->setAllowedTypes('choice_translation_domain', array('null', 'bool', 'string')); - $resolver->setAllowedTypes('choices_as_values', 'bool'); $resolver->setAllowedTypes('choice_loader', array('null', 'Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')); $resolver->setAllowedTypes('choice_label', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); $resolver->setAllowedTypes('choice_name', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php index 4e8bb6f6a5113..b4a65f2978b64 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php @@ -24,7 +24,6 @@ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'choices' => array_flip(Intl::getRegionBundle()->getCountryNames()), - 'choices_as_values' => true, 'choice_translation_domain' => false, )); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php index 5086b0d4deb1a..7e0497fcc92fc 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php @@ -24,7 +24,6 @@ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'choices' => array_flip(Intl::getCurrencyBundle()->getCurrencyNames()), - 'choices_as_values' => true, 'choice_translation_domain' => false, )); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 2dd0ab4c5328c..be96084e21f33 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -93,15 +93,12 @@ public function buildForm(FormBuilderInterface $builder, array $options) if ('choice' === $options['widget']) { // Only pass a subset of the options to children $yearOptions['choices'] = $this->formatTimestamps($formatter, '/y+/', $this->listYears($options['years'])); - $yearOptions['choices_as_values'] = true; $yearOptions['placeholder'] = $options['placeholder']['year']; $yearOptions['choice_translation_domain'] = $options['choice_translation_domain']['year']; $monthOptions['choices'] = $this->formatTimestamps($formatter, '/[M|L]+/', $this->listMonths($options['months'])); - $monthOptions['choices_as_values'] = true; $monthOptions['placeholder'] = $options['placeholder']['month']; $monthOptions['choice_translation_domain'] = $options['choice_translation_domain']['month']; $dayOptions['choices'] = $this->formatTimestamps($formatter, '/d+/', $this->listDays($options['days'])); - $dayOptions['choices_as_values'] = true; $dayOptions['placeholder'] = $options['placeholder']['day']; $dayOptions['choice_translation_domain'] = $options['choice_translation_domain']['day']; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php index 08bab70280588..022ab24a8bda3 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php @@ -24,7 +24,6 @@ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'choices' => array_flip(Intl::getLanguageBundle()->getLanguageNames()), - 'choices_as_values' => true, 'choice_translation_domain' => false, )); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php index 4763ea4bc491b..86ff038b74a74 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php @@ -24,7 +24,6 @@ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'choices' => array_flip(Intl::getLocaleBundle()->getLocaleNames()), - 'choices_as_values' => true, 'choice_translation_domain' => false, )); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index 5461071621f4e..8b148b685dcdc 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -68,7 +68,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) // Only pass a subset of the options to children $hourOptions['choices'] = $hours; - $hourOptions['choices_as_values'] = true; $hourOptions['placeholder'] = $options['placeholder']['hour']; $hourOptions['choice_translation_domain'] = $options['choice_translation_domain']['hour']; @@ -78,7 +77,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) } $minuteOptions['choices'] = $minutes; - $minuteOptions['choices_as_values'] = true; $minuteOptions['placeholder'] = $options['placeholder']['minute']; $minuteOptions['choice_translation_domain'] = $options['choice_translation_domain']['minute']; } @@ -91,7 +89,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) } $secondOptions['choices'] = $seconds; - $secondOptions['choices_as_values'] = true; $secondOptions['placeholder'] = $options['placeholder']['second']; $secondOptions['choice_translation_domain'] = $options['choice_translation_domain']['second']; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php index 1bb82ac694aee..f0e3ad4443a9a 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php @@ -37,7 +37,6 @@ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'choices' => self::getFlippedTimezones(), - 'choices_as_values' => true, 'choice_translation_domain' => false, )); } diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php index 7f49c5091dae7..32a4af7dde8c6 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php @@ -213,7 +213,6 @@ public function testSingleChoice() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, )); @@ -236,7 +235,6 @@ public function testSingleChoiceWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, 'choice_translation_domain' => false, @@ -260,7 +258,6 @@ public function testSingleChoiceWithPlaceholderWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, 'required' => false, @@ -287,7 +284,6 @@ public function testSingleChoiceAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( '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, @@ -311,7 +307,6 @@ public function testSingleChoiceWithPreferred() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'preferred_choices' => array('&b'), 'multiple' => false, 'expanded' => false, @@ -336,7 +331,6 @@ public function testSingleChoiceWithPreferredAndNoSeparator() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'preferred_choices' => array('&b'), 'multiple' => false, 'expanded' => false, @@ -360,7 +354,6 @@ public function testSingleChoiceWithPreferredAndBlankSeparator() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'preferred_choices' => array('&b'), 'multiple' => false, 'expanded' => false, @@ -385,7 +378,6 @@ public function testChoiceWithOnlyPreferred() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'preferred_choices' => array('&a', '&b'), 'multiple' => false, 'expanded' => false, @@ -403,7 +395,6 @@ public function testSingleChoiceNonRequired() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => false, 'multiple' => false, 'expanded' => false, @@ -428,7 +419,6 @@ public function testSingleChoiceNonRequiredNoneSelected() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => false, 'multiple' => false, 'expanded' => false, @@ -453,7 +443,6 @@ public function testSingleChoiceNonRequiredWithPlaceholder() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, 'required' => false, @@ -479,7 +468,6 @@ public function testSingleChoiceRequiredWithPlaceholder() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => true, 'multiple' => false, 'expanded' => false, @@ -505,7 +493,6 @@ public function testSingleChoiceRequiredWithPlaceholderViaView() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => true, 'multiple' => false, 'expanded' => false, @@ -533,7 +520,6 @@ public function testSingleChoiceGrouped() 'Group&1' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'Group&2' => array('Choice&C' => '&c'), ), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, )); @@ -562,7 +548,6 @@ public function testMultipleChoice() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => true, 'multiple' => true, 'expanded' => false, @@ -587,7 +572,6 @@ public function testMultipleChoiceAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( '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, @@ -613,7 +597,6 @@ public function testMultipleChoiceSkipsPlaceholder() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => true, 'expanded' => false, 'placeholder' => 'Test&Me', @@ -637,7 +620,6 @@ public function testMultipleChoiceNonRequired() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => false, 'multiple' => true, 'expanded' => false, @@ -661,7 +643,6 @@ public function testSingleChoiceExpanded() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, )); @@ -697,7 +678,6 @@ public function testSingleChoiceExpandedWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, 'choice_translation_domain' => false, @@ -734,7 +714,6 @@ public function testSingleChoiceExpandedAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( '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, @@ -771,7 +750,6 @@ public function testSingleChoiceExpandedWithPlaceholder() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, 'placeholder' => 'Test&Me', @@ -817,7 +795,6 @@ public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, 'translation_domain' => false, @@ -864,7 +841,6 @@ public function testSingleChoiceExpandedWithBooleanValue() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array( 'choices' => array('Choice&A' => '1', 'Choice&B' => '0'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, )); @@ -900,7 +876,6 @@ public function testMultipleChoiceExpanded() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), - 'choices_as_values' => true, 'multiple' => true, 'expanded' => true, 'required' => true, @@ -946,7 +921,6 @@ public function testMultipleChoiceExpandedWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), - 'choices_as_values' => true, 'multiple' => true, 'expanded' => true, 'required' => true, @@ -993,7 +967,6 @@ public function testMultipleChoiceExpandedAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( '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, diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php index 461c885795fa6..b5f6017084369 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php @@ -692,7 +692,6 @@ public function testChoiceRowWithCustomBlock() { $form = $this->factory->createNamedBuilder('name_c', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', 'a', array( 'choices' => array('ChoiceA' => 'a', 'ChoiceB' => 'b'), - 'choices_as_values' => true, 'expanded' => true, )) ->getForm(); diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 92f3ea7e24bb9..7bade490f9b2b 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -488,7 +488,6 @@ public function testSingleChoice() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, )); @@ -522,7 +521,6 @@ public function testSingleChoiceWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, 'choice_translation_domain' => false, @@ -545,7 +543,6 @@ public function testSingleChoiceWithPlaceholderWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, 'required' => false, @@ -571,7 +568,6 @@ public function testSingleChoiceAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( '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, @@ -594,7 +590,6 @@ public function testSingleChoiceWithPreferred() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'preferred_choices' => array('&b'), 'multiple' => false, 'expanded' => false, @@ -618,7 +613,6 @@ public function testSingleChoiceWithPreferredAndNoSeparator() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'preferred_choices' => array('&b'), 'multiple' => false, 'expanded' => false, @@ -641,7 +635,6 @@ public function testSingleChoiceWithPreferredAndBlankSeparator() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'preferred_choices' => array('&b'), 'multiple' => false, 'expanded' => false, @@ -665,7 +658,6 @@ public function testChoiceWithOnlyPreferred() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'preferred_choices' => array('&a', '&b'), 'multiple' => false, 'expanded' => false, @@ -682,7 +674,6 @@ public function testSingleChoiceNonRequired() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => false, 'multiple' => false, 'expanded' => false, @@ -706,7 +697,6 @@ public function testSingleChoiceNonRequiredNoneSelected() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => false, 'multiple' => false, 'expanded' => false, @@ -730,7 +720,6 @@ public function testSingleChoiceNonRequiredWithPlaceholder() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, 'required' => false, @@ -755,7 +744,6 @@ public function testSingleChoiceRequiredWithPlaceholder() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => true, 'multiple' => false, 'expanded' => false, @@ -783,7 +771,6 @@ public function testSingleChoiceRequiredWithPlaceholderViaView() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => true, 'multiple' => false, 'expanded' => false, @@ -813,7 +800,6 @@ public function testSingleChoiceGrouped() 'Group&1' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'Group&2' => array('Choice&C' => '&c'), ), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => false, )); @@ -841,7 +827,6 @@ public function testMultipleChoice() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => true, 'multiple' => true, 'expanded' => false, @@ -865,7 +850,6 @@ public function testMultipleChoiceAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( '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, @@ -890,7 +874,6 @@ public function testMultipleChoiceSkipsPlaceholder() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => true, 'expanded' => false, 'placeholder' => 'Test&Me', @@ -913,7 +896,6 @@ public function testMultipleChoiceNonRequired() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'required' => false, 'multiple' => true, 'expanded' => false, @@ -936,7 +918,6 @@ public function testSingleChoiceExpanded() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, )); @@ -959,7 +940,6 @@ public function testSingleChoiceExpandedWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, 'choice_translation_domain' => false, @@ -983,7 +963,6 @@ public function testSingleChoiceExpandedAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( '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, @@ -1007,7 +986,6 @@ public function testSingleChoiceExpandedWithPlaceholder() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, 'placeholder' => 'Test&Me', @@ -1033,7 +1011,6 @@ public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, 'translation_domain' => false, @@ -1060,7 +1037,6 @@ public function testSingleChoiceExpandedWithBooleanValue() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array( 'choices' => array('Choice&A' => '1', 'Choice&B' => '0'), - 'choices_as_values' => true, 'multiple' => false, 'expanded' => true, )); @@ -1083,7 +1059,6 @@ public function testMultipleChoiceExpanded() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), - 'choices_as_values' => true, 'multiple' => true, 'expanded' => true, 'required' => true, @@ -1109,7 +1084,6 @@ public function testMultipleChoiceExpandedWithoutTranslation() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), - 'choices_as_values' => true, 'multiple' => true, 'expanded' => true, 'required' => true, @@ -1136,7 +1110,6 @@ public function testMultipleChoiceExpandedAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( '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, diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayKeyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayKeyChoiceListTest.php deleted file mode 100644 index 1f1643158d48d..0000000000000 --- a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayKeyChoiceListTest.php +++ /dev/null @@ -1,183 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\ChoiceList; - -use Symfony\Component\Form\ChoiceList\ArrayKeyChoiceList; - -/** - * @author Bernhard Schussek - * - * @group legacy - */ -class ArrayKeyChoiceListTest extends AbstractChoiceListTest -{ - private $object; - - protected function setUp() - { - parent::setUp(); - - $this->object = new \stdClass(); - } - - protected function createChoiceList() - { - return new ArrayKeyChoiceList(array_flip($this->getChoices())); - } - - protected function getChoices() - { - return array(0, 1, 'a', 'b', ''); - } - - protected function getValues() - { - return array('0', '1', 'a', 'b', ''); - } - - public function testUseChoicesAsValuesByDefault() - { - $list = new ArrayKeyChoiceList(array('' => 'Empty', 0 => 'Zero', 1 => 'One', '1.23' => 'Float')); - - $this->assertSame(array('', '0', '1', '1.23'), $list->getValues()); - $this->assertSame(array('' => '', 0 => 0, 1 => 1, '1.23' => '1.23'), $list->getChoices()); - $this->assertSame(array('' => 'Empty', 0 => 'Zero', 1 => 'One', '1.23' => 'Float'), $list->getOriginalKeys()); - } - - public function testNoChoices() - { - $list = new ArrayKeyChoiceList(array()); - - $this->assertSame(array(), $list->getValues()); - } - - public function testGetChoicesForValuesConvertsValuesToStrings() - { - $this->assertSame(array(0), $this->list->getChoicesForValues(array(0))); - $this->assertSame(array(0), $this->list->getChoicesForValues(array('0'))); - $this->assertSame(array(1), $this->list->getChoicesForValues(array(1))); - $this->assertSame(array(1), $this->list->getChoicesForValues(array('1'))); - $this->assertSame(array('a'), $this->list->getChoicesForValues(array('a'))); - $this->assertSame(array('b'), $this->list->getChoicesForValues(array('b'))); - $this->assertSame(array(''), $this->list->getChoicesForValues(array(''))); - // "1" === (string) true - $this->assertSame(array(1), $this->list->getChoicesForValues(array(true))); - // "" === (string) false - $this->assertSame(array(''), $this->list->getChoicesForValues(array(false))); - // "" === (string) null - $this->assertSame(array(''), $this->list->getChoicesForValues(array(null))); - $this->assertSame(array(), $this->list->getChoicesForValues(array(1.23))); - } - - public function testGetValuesForChoicesConvertsChoicesToArrayKeys() - { - $this->assertSame(array('0'), $this->list->getValuesForChoices(array(0))); - $this->assertSame(array('0'), $this->list->getValuesForChoices(array('0'))); - $this->assertSame(array('1'), $this->list->getValuesForChoices(array(1))); - $this->assertSame(array('1'), $this->list->getValuesForChoices(array('1'))); - $this->assertSame(array('a'), $this->list->getValuesForChoices(array('a'))); - $this->assertSame(array('b'), $this->list->getValuesForChoices(array('b'))); - // Always cast booleans to 0 and 1, because: - // array(true => 'Yes', false => 'No') === array(1 => 'Yes', 0 => 'No') - // see ChoiceTypeTest::testSetDataSingleNonExpandedAcceptsBoolean - $this->assertSame(array('0'), $this->list->getValuesForChoices(array(false))); - $this->assertSame(array('1'), $this->list->getValuesForChoices(array(true))); - } - - /** - * @dataProvider provideConvertibleChoices - */ - public function testConvertChoicesIfNecessary(array $choices, array $converted) - { - $list = new ArrayKeyChoiceList($choices); - - $this->assertSame($converted, $list->getChoices()); - } - - public function provideConvertibleChoices() - { - return array( - array(array(0 => 'Label'), array(0 => 0)), - array(array(1 => 'Label'), array(1 => 1)), - array(array('1.23' => 'Label'), array('1.23' => '1.23')), - array(array('foobar' => 'Label'), array('foobar' => 'foobar')), - // The default value of choice fields is NULL. It should be treated - // like the empty value for this choice list type - array(array(null => 'Label'), array('' => '')), - array(array('1.23' => 'Label'), array('1.23' => '1.23')), - // Always cast booleans to 0 and 1, because: - // array(true => 'Yes', false => 'No') === array(1 => 'Yes', 0 => 'No') - // see ChoiceTypeTest::testSetDataSingleNonExpandedAcceptsBoolean - array(array(true => 'Label'), array(1 => 1)), - array(array(false => 'Label'), array(0 => 0)), - ); - } - - /** - * @dataProvider provideInvalidChoices - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - */ - public function testGetValuesForChoicesFailsIfInvalidChoices(array $choices) - { - $this->list->getValuesForChoices($choices); - } - - public function provideInvalidChoices() - { - return array( - array(array(new \stdClass())), - array(array(array(1, 2))), - ); - } - - /** - * @dataProvider provideConvertibleValues - */ - public function testConvertValuesToStrings($value, $converted) - { - $callback = function () use ($value) { - return $value; - }; - - $list = new ArrayKeyChoiceList(array('choice' => 'Label'), $callback); - - $this->assertSame(array($converted), $list->getValues()); - } - - public function provideConvertibleValues() - { - return array( - array(0, '0'), - array(1, '1'), - array('0', '0'), - array('1', '1'), - array('1.23', '1.23'), - array('foobar', 'foobar'), - array('', ''), - ); - } - - public function testCreateChoiceListWithValueCallback() - { - $callback = function ($choice) { - return ':'.$choice; - }; - - $choiceList = new ArrayKeyChoiceList(array('foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz'), $callback); - - $this->assertSame(array(':foo', ':bar', ':baz'), $choiceList->getValues()); - $this->assertSame(array(':foo' => 'foo', ':bar' => 'bar', ':baz' => 'baz'), $choiceList->getChoices()); - $this->assertSame(array(':foo' => 'Foo', ':bar' => 'Bar', ':baz' => 'Baz'), $choiceList->getOriginalKeys()); - $this->assertSame(array(1 => 'foo', 2 => 'baz'), $choiceList->getChoicesForValues(array(1 => ':foo', 2 => ':baz'))); - $this->assertSame(array(1 => ':foo', 2 => ':baz'), $choiceList->getValuesForChoices(array(1 => 'foo', 2 => 'baz'))); - } -} diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 5d989ec6aaca6..fc61e3b044cfe 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; use Symfony\Component\Form\ChoiceList\View\ChoiceView; -use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { @@ -25,14 +24,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase 'Roman' => 'e', ); - private $numericChoicesFlipped = array( - 0 => 'Bernhard', - 1 => 'Fabien', - 2 => 'Kris', - 3 => 'Jon', - 4 => 'Roman', - ); - private $objectChoices; protected $groupedChoices = array( @@ -47,18 +38,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase ), ); - protected $groupedChoicesFlipped = array( - 'Symfony' => array( - 'a' => 'Bernhard', - 'b' => 'Fabien', - 'c' => 'Kris', - ), - 'Doctrine' => array( - 'd' => 'Jon', - 'e' => 'Roman', - ), - ); - protected function setUp() { parent::setUp(); @@ -112,7 +91,6 @@ public function testChoiceLoaderOptionExpectsChoiceLoaderInterface() public function testChoiceListAndChoicesCanBeEmpty() { $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( - 'choices_as_values' => true, )); } @@ -121,20 +99,6 @@ public function testExpandedChoicesOptionsTurnIntoChildren() $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'expanded' => true, 'choices' => $this->choices, - 'choices_as_values' => true, - )); - - $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); - } - - /** - * @group legacy - */ - public function testExpandedFlippedChoicesOptionsTurnIntoChildren() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( - 'expanded' => true, - 'choices' => array_flip($this->choices), )); $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); @@ -147,7 +111,6 @@ public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice() 'expanded' => true, 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $this->assertTrue(isset($form['placeholder'])); @@ -161,7 +124,6 @@ public function testPlaceholderNotPresentIfRequired() 'expanded' => true, 'required' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $this->assertFalse(isset($form['placeholder'])); @@ -175,7 +137,6 @@ public function testPlaceholderNotPresentIfMultiple() 'expanded' => true, 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $this->assertFalse(isset($form['placeholder'])); @@ -192,7 +153,6 @@ public function testPlaceholderNotPresentIfEmptyChoice() 'Empty' => '', 'Not empty' => 1, ), - 'choices_as_values' => true, )); $this->assertFalse(isset($form['placeholder'])); @@ -204,29 +164,6 @@ public function testExpandedChoicesOptionsAreFlattened() $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'expanded' => true, 'choices' => $this->groupedChoices, - 'choices_as_values' => true, - )); - - $flattened = array(); - foreach ($this->groupedChoices as $choices) { - $flattened = array_merge($flattened, array_keys($choices)); - } - - $this->assertCount($form->count(), $flattened, 'Each nested choice should become a new field, not the groups'); - - foreach ($flattened as $value => $choice) { - $this->assertTrue($form->has($value), 'Flattened choice is named after it\'s value'); - } - } - - /** - * @group legacy - */ - public function testExpandedChoicesFlippedOptionsAreFlattened() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( - 'expanded' => true, - 'choices' => $this->groupedChoicesFlipped, )); $flattened = array(); @@ -255,7 +192,6 @@ public function testExpandedChoicesOptionsAreFlattenedObjectChoices() 'Symfony' => array($obj1, $obj2, $obj3), 'Doctrine' => array($obj4, $obj5), ), - 'choices_as_values' => true, 'choice_name' => 'id', )); @@ -274,7 +210,6 @@ public function testExpandedCheckboxesAreNeverRequired() 'expanded' => true, 'required' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); foreach ($form as $child) { @@ -289,7 +224,6 @@ public function testExpandedRadiosAreRequiredIfChoiceChildIsRequired() 'expanded' => true, 'required' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); foreach ($form as $child) { @@ -304,7 +238,6 @@ public function testExpandedRadiosAreNotRequiredIfChoiceChildIsNotRequired() 'expanded' => true, 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); foreach ($form as $child) { @@ -318,7 +251,6 @@ public function testSubmitSingleNonExpanded() 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit('b'); @@ -334,7 +266,6 @@ public function testSubmitSingleNonExpandedInvalidChoice() 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit('foobar'); @@ -350,7 +281,6 @@ public function testSubmitSingleNonExpandedNull() 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(null); @@ -369,7 +299,6 @@ public function testSubmitSingleNonExpandedNullNoChoices() 'multiple' => false, 'expanded' => false, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(null); @@ -385,7 +314,6 @@ public function testSubmitSingleNonExpandedEmpty() 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(''); @@ -403,7 +331,6 @@ public function testSubmitSingleNonExpandedEmptyExplicitEmptyChoice() 'choices' => array( 'Empty' => 'EMPTY_CHOICE', ), - 'choices_as_values' => true, 'choice_value' => function () { return ''; }, @@ -425,7 +352,6 @@ public function testSubmitSingleNonExpandedEmptyNoChoices() 'multiple' => false, 'expanded' => false, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(''); @@ -441,7 +367,6 @@ public function testSubmitSingleNonExpandedFalse() 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(false); @@ -460,7 +385,6 @@ public function testSubmitSingleNonExpandedFalseNoChoices() 'multiple' => false, 'expanded' => false, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(false); @@ -476,7 +400,6 @@ public function testSubmitSingleNonExpandedObjectChoices() 'multiple' => false, 'expanded' => false, 'choices' => $this->objectChoices, - 'choices_as_values' => true, 'choice_label' => 'name', 'choice_value' => 'id', )); @@ -495,7 +418,6 @@ public function testSubmitMultipleNonExpanded() 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(array('a', 'b')); @@ -511,7 +433,6 @@ public function testSubmitMultipleNonExpandedEmpty() 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(array()); @@ -530,7 +451,6 @@ public function testSubmitMultipleNonExpandedEmptyNoChoices() 'multiple' => true, 'expanded' => false, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(array()); @@ -546,7 +466,6 @@ public function testSubmitMultipleNonExpandedInvalidScalarChoice() 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit('foobar'); @@ -562,7 +481,6 @@ public function testSubmitMultipleNonExpandedInvalidArrayChoice() 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(array('a', 'foobar')); @@ -578,7 +496,6 @@ public function testSubmitMultipleNonExpandedObjectChoices() 'multiple' => true, 'expanded' => false, 'choices' => $this->objectChoices, - 'choices_as_values' => true, 'choice_label' => 'name', 'choice_value' => 'id', )); @@ -597,7 +514,6 @@ public function testSubmitSingleExpandedRequired() 'expanded' => true, 'required' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit('b'); @@ -626,7 +542,6 @@ public function testSubmitSingleExpandedRequiredInvalidChoice() 'expanded' => true, 'required' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit('foobar'); @@ -655,7 +570,6 @@ public function testSubmitSingleExpandedNonRequired() 'expanded' => true, 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit('b'); @@ -686,7 +600,6 @@ public function testSubmitSingleExpandedNonRequiredInvalidChoice() 'expanded' => true, 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit('foobar'); @@ -715,7 +628,6 @@ public function testSubmitSingleExpandedRequiredNull() 'expanded' => true, 'required' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(null); @@ -747,7 +659,6 @@ public function testSubmitSingleExpandedRequiredNullNoChoices() 'expanded' => true, 'required' => true, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(null); @@ -765,7 +676,6 @@ public function testSubmitSingleExpandedRequiredEmpty() 'expanded' => true, 'required' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(''); @@ -797,7 +707,6 @@ public function testSubmitSingleExpandedRequiredEmptyNoChoices() 'expanded' => true, 'required' => true, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(''); @@ -815,7 +724,6 @@ public function testSubmitSingleExpandedRequiredFalse() 'expanded' => true, 'required' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(false); @@ -847,7 +755,6 @@ public function testSubmitSingleExpandedRequiredFalseNoChoices() 'expanded' => true, 'required' => true, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(false); @@ -865,7 +772,6 @@ public function testSubmitSingleExpandedNonRequiredNull() 'expanded' => true, 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(null); @@ -899,7 +805,6 @@ public function testSubmitSingleExpandedNonRequiredNullNoChoices() 'expanded' => true, 'required' => false, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(null); @@ -917,7 +822,6 @@ public function testSubmitSingleExpandedNonRequiredEmpty() 'expanded' => true, 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(''); @@ -951,7 +855,6 @@ public function testSubmitSingleExpandedNonRequiredEmptyNoChoices() 'expanded' => true, 'required' => false, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(''); @@ -969,7 +872,6 @@ public function testSubmitSingleExpandedNonRequiredFalse() 'expanded' => true, 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(false); @@ -1003,7 +905,6 @@ public function testSubmitSingleExpandedNonRequiredFalseNoChoices() 'expanded' => true, 'required' => false, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(false); @@ -1023,7 +924,6 @@ public function testSubmitSingleExpandedWithEmptyChild() 'Empty' => '', 'Not empty' => 1, ), - 'choices_as_values' => true, )); $form->submit(''); @@ -1043,7 +943,6 @@ public function testSubmitSingleExpandedObjectChoices() 'multiple' => false, 'expanded' => true, 'choices' => $this->objectChoices, - 'choices_as_values' => true, 'choice_label' => 'name', 'choice_value' => 'id', )); @@ -1065,38 +964,12 @@ public function testSubmitSingleExpandedObjectChoices() $this->assertNull($form[4]->getViewData()); } - public function testSubmitSingleExpandedNumericChoices() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( - 'multiple' => false, - 'expanded' => true, - 'choices' => $this->numericChoicesFlipped, - )); - - $form->submit('1'); - - $this->assertSame(1, $form->getData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertTrue($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertSame('1', $form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - public function testSubmitMultipleExpanded() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(array('a', 'c')); @@ -1124,7 +997,6 @@ public function testSubmitMultipleExpandedInvalidScalarChoice() 'multiple' => true, 'expanded' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit('foobar'); @@ -1152,7 +1024,6 @@ public function testSubmitMultipleExpandedInvalidArrayChoice() 'multiple' => true, 'expanded' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(array('a', 'foobar')); @@ -1180,7 +1051,6 @@ public function testSubmitMultipleExpandedEmpty() 'multiple' => true, 'expanded' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $form->submit(array()); @@ -1209,7 +1079,6 @@ public function testSubmitMultipleExpandedEmptyNoChoices() 'multiple' => true, 'expanded' => true, 'choices' => array(), - 'choices_as_values' => true, )); $form->submit(array()); @@ -1228,7 +1097,6 @@ public function testSubmitMultipleExpandedWithEmptyChild() 'Not Empty' => 1, 'Not Empty 2' => 2, ), - 'choices_as_values' => true, )); $form->submit(array('', '2')); @@ -1250,7 +1118,6 @@ public function testSubmitMultipleExpandedObjectChoices() 'multiple' => true, 'expanded' => true, 'choices' => $this->objectChoices, - 'choices_as_values' => true, 'choice_label' => 'name', 'choice_value' => 'id', )); @@ -1272,38 +1139,12 @@ public function testSubmitMultipleExpandedObjectChoices() $this->assertNull($form[4]->getViewData()); } - public function testSubmitMultipleExpandedNumericChoices() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( - 'multiple' => true, - 'expanded' => true, - 'choices' => $this->numericChoicesFlipped, - )); - - $form->submit(array('1', '2')); - - $this->assertSame(array(1, 2), $form->getData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertTrue($form[1]->getData()); - $this->assertTrue($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertSame('1', $form[1]->getViewData()); - $this->assertSame('2', $form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - public function testSingleSelectedObjectChoices() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', $this->objectChoices[3], array( 'multiple' => false, 'expanded' => false, 'choices' => $this->objectChoices, - 'choices_as_values' => true, 'choice_label' => 'name', 'choice_value' => 'id', )); @@ -1321,7 +1162,6 @@ public function testMultipleSelectedObjectChoices() 'multiple' => true, 'expanded' => false, 'choices' => $this->objectChoices, - 'choices_as_values' => true, 'choice_label' => 'name', 'choice_value' => 'id', )); @@ -1333,50 +1173,10 @@ public function testMultipleSelectedObjectChoices() $this->assertFalse($selectedChecker($view->vars['choices'][1]->value, $view->vars['value'])); } - /** - * We need this functionality to create choice fields for Boolean types, - * e.g. false => 'No', true => 'Yes'. - * - * @group legacy - */ - public function testSetDataSingleNonExpandedAcceptsBoolean() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( - 'multiple' => false, - 'expanded' => false, - 'choices' => $this->numericChoicesFlipped, - )); - - $form->setData(false); - - $this->assertFalse($form->getData()); - $this->assertEquals('0', $form->getViewData()); - $this->assertTrue($form->isSynchronized()); - } - - /** - * @group legacy - */ - public function testSetDataMultipleNonExpandedAcceptsBoolean() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( - 'multiple' => true, - 'expanded' => false, - 'choices' => $this->numericChoicesFlipped, - )); - - $form->setData(array(false, true)); - - $this->assertEquals(array(false, true), $form->getData()); - $this->assertEquals(array('0', '1'), $form->getViewData()); - $this->assertTrue($form->isSynchronized()); - } - public function testPassRequiredToView() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1388,7 +1188,6 @@ public function testPassNonRequiredToView() $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1400,7 +1199,6 @@ public function testPassMultipleToView() $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1412,7 +1210,6 @@ public function testPassExpandedToView() $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'expanded' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1423,7 +1220,6 @@ public function testPassChoiceTranslationDomainToView() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1434,7 +1230,6 @@ public function testChoiceTranslationDomainWithTrueValueToView() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->choices, - 'choices_as_values' => true, 'choice_translation_domain' => true, )); $view = $form->createView(); @@ -1446,7 +1241,6 @@ public function testDefaultChoiceTranslationDomainIsSameAsTranslationDomainToVie { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->choices, - 'choices_as_values' => true, 'translation_domain' => 'foo', )); $view = $form->createView(); @@ -1462,7 +1256,6 @@ public function testInheritChoiceTranslationDomainFromParent() )) ->add('child', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'choices' => array(), - 'choices_as_values' => true, )) ->getForm() ->createView(); @@ -1476,7 +1269,6 @@ public function testPlaceholderIsNullByDefaultIfRequired() 'multiple' => false, 'required' => true, 'choices' => $this->choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1489,7 +1281,6 @@ public function testPlaceholderIsEmptyStringByDefaultIfNotRequired() 'multiple' => false, 'required' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1507,7 +1298,6 @@ public function testPassPlaceholderToView($multiple, $expanded, $required, $plac 'required' => $required, 'placeholder' => $placeholder, 'choices' => $this->choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1526,7 +1316,6 @@ public function testDontPassPlaceholderIfContainedInChoices($multiple, $expanded 'required' => $required, 'placeholder' => $placeholder, 'choices' => array('A' => 'a', 'Empty' => ''), - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1583,7 +1372,6 @@ public function testPassChoicesToView() $choices = array('A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd'); $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1600,7 +1388,6 @@ public function testPassPreferredChoicesToView() $choices = array('A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd'); $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $choices, - 'choices_as_values' => true, 'preferred_choices' => array('b', 'd'), )); $view = $form->createView(); @@ -1619,7 +1406,6 @@ public function testPassHierarchicalChoicesToView() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->groupedChoices, - 'choices_as_values' => true, 'preferred_choices' => array('b', 'd'), )); $view = $form->createView(); @@ -1651,7 +1437,6 @@ public function testPassChoiceDataToView() $obj4 = (object) array('value' => 'd', 'label' => 'D'); $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array($obj1, $obj2, $obj3, $obj4), - 'choices_as_values' => true, 'choice_label' => 'label', 'choice_value' => 'value', )); @@ -1671,7 +1456,6 @@ public function testAdjustFullNameForMultipleNonExpanded() 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, - 'choices_as_values' => true, )); $view = $form->createView(); @@ -1683,7 +1467,6 @@ public function testInitializeWithEmptyChoices() { $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array(), - 'choices_as_values' => true, )); } @@ -1696,7 +1479,6 @@ public function testInitializeWithDefaultObjectChoice() $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array($obj1, $obj2, $obj3, $obj4), - 'choices_as_values' => true, 'choice_label' => 'label', 'choice_value' => 'value', // Used to break because "data_class" was inferred, which needs to pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy