diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index 1c8936995c..9f5e6e23e7 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -1,6 +1,19 @@ CHANGELOG ========= +4.0.0 +----- + + * using the `choices` option in `CountryType`, `CurrencyType`, `LanguageType`, + `LocaleType`, and `TimezoneType` when the `choice_loader` option is not `null` + is not supported anymore and the configured choices will be ignored + * callable strings that are passed to the options of the `ChoiceType` are + treated as property paths + * the `choices_as_values` option of the `ChoiceType` has been removed + * removed the support for caching loaded choice lists in `LazyChoiceList`, + cache the choice list in the used `ChoiceLoaderInterface` implementation + instead + 3.3.0 ----- diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php index 0e282f7083..5604e6910b 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php @@ -84,10 +84,8 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface */ public function createListFromChoices($choices, $value = null) { - if (is_string($value) && !is_callable($value)) { + if (is_string($value)) { $value = new PropertyPath($value); - } elseif (is_string($value) && is_callable($value)) { - @trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED); } if ($value instanceof PropertyPath) { @@ -117,10 +115,8 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface */ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null) { - if (is_string($value) && !is_callable($value)) { + if (is_string($value)) { $value = new PropertyPath($value); - } elseif (is_string($value) && is_callable($value)) { - @trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED); } if ($value instanceof PropertyPath) { @@ -155,10 +151,8 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface { $accessor = $this->propertyAccessor; - if (is_string($label) && !is_callable($label)) { + if (is_string($label)) { $label = new PropertyPath($label); - } elseif (is_string($label) && is_callable($label)) { - @trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED); } if ($label instanceof PropertyPath) { @@ -167,10 +161,8 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface }; } - if (is_string($preferredChoices) && !is_callable($preferredChoices)) { + if (is_string($preferredChoices)) { $preferredChoices = new PropertyPath($preferredChoices); - } elseif (is_string($preferredChoices) && is_callable($preferredChoices)) { - @trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED); } if ($preferredChoices instanceof PropertyPath) { @@ -184,10 +176,8 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface }; } - if (is_string($index) && !is_callable($index)) { + if (is_string($index)) { $index = new PropertyPath($index); - } elseif (is_string($index) && is_callable($index)) { - @trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED); } if ($index instanceof PropertyPath) { @@ -196,10 +186,8 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface }; } - if (is_string($groupBy) && !is_callable($groupBy)) { + if (is_string($groupBy)) { $groupBy = new PropertyPath($groupBy); - } elseif (is_string($groupBy) && is_callable($groupBy)) { - @trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED); } if ($groupBy instanceof PropertyPath) { @@ -212,10 +200,8 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface }; } - if (is_string($attr) && !is_callable($attr)) { + if (is_string($attr)) { $attr = new PropertyPath($attr); - } elseif (is_string($attr) && is_callable($attr)) { - @trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED); } if ($attr instanceof PropertyPath) { diff --git a/src/Symfony/Component/Form/ChoiceList/LazyChoiceList.php b/src/Symfony/Component/Form/ChoiceList/LazyChoiceList.php index e8e37b3595..9e759afa6e 100644 --- a/src/Symfony/Component/Form/ChoiceList/LazyChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/LazyChoiceList.php @@ -43,20 +43,6 @@ class LazyChoiceList implements ChoiceListInterface */ private $value; - /** - * @var ChoiceListInterface|null - * - * @deprecated Since 3.1, to be removed in 4.0. Cache the choice list in the {@link ChoiceLoaderInterface} instead. - */ - private $loadedList; - - /** - * @var bool - * - * @deprecated Flag used for BC layer since 3.1. To be removed in 4.0. - */ - private $loaded = false; - /** * Creates a lazily-loaded list using the given loader. * @@ -79,23 +65,7 @@ class LazyChoiceList implements ChoiceListInterface */ public function getChoices() { - if ($this->loaded) { - // We can safely invoke the {@link ChoiceLoaderInterface} assuming it has the list - // in cache when the lazy list is already loaded - if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) { - @trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED); - } - - return $this->loadedList->getChoices(); - } - - // BC - $this->loadedList = $this->loader->loadChoiceList($this->value); - $this->loaded = true; - - return $this->loadedList->getChoices(); - // In 4.0 keep the following line only: - // return $this->loader->loadChoiceList($this->value)->getChoices() + return $this->loader->loadChoiceList($this->value)->getChoices(); } /** @@ -103,22 +73,7 @@ class LazyChoiceList implements ChoiceListInterface */ public function getValues() { - if ($this->loaded) { - // Check whether the loader has the same cache - if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) { - @trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED); - } - - return $this->loadedList->getValues(); - } - - // BC - $this->loadedList = $this->loader->loadChoiceList($this->value); - $this->loaded = true; - - return $this->loadedList->getValues(); - // In 4.0 keep the following line only: - // return $this->loader->loadChoiceList($this->value)->getValues() + return $this->loader->loadChoiceList($this->value)->getValues(); } /** @@ -126,22 +81,7 @@ class LazyChoiceList implements ChoiceListInterface */ public function getStructuredValues() { - if ($this->loaded) { - // Check whether the loader has the same cache - if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) { - @trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED); - } - - return $this->loadedList->getStructuredValues(); - } - - // BC - $this->loadedList = $this->loader->loadChoiceList($this->value); - $this->loaded = true; - - return $this->loadedList->getStructuredValues(); - // In 4.0 keep the following line only: - // return $this->loader->loadChoiceList($this->value)->getStructuredValues(); + return $this->loader->loadChoiceList($this->value)->getStructuredValues(); } /** @@ -149,22 +89,7 @@ class LazyChoiceList implements ChoiceListInterface */ public function getOriginalKeys() { - if ($this->loaded) { - // Check whether the loader has the same cache - if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) { - @trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED); - } - - return $this->loadedList->getOriginalKeys(); - } - - // BC - $this->loadedList = $this->loader->loadChoiceList($this->value); - $this->loaded = true; - - return $this->loadedList->getOriginalKeys(); - // In 4.0 keep the following line only: - // return $this->loader->loadChoiceList($this->value)->getOriginalKeys(); + return $this->loader->loadChoiceList($this->value)->getOriginalKeys(); } /** @@ -172,15 +97,6 @@ class LazyChoiceList implements ChoiceListInterface */ public function getChoicesForValues(array $values) { - if ($this->loaded) { - // Check whether the loader has the same cache - if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) { - @trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED); - } - - return $this->loadedList->getChoicesForValues($values); - } - return $this->loader->loadChoicesForValues($values, $this->value); } @@ -189,15 +105,6 @@ class LazyChoiceList implements ChoiceListInterface */ public function getValuesForChoices(array $choices) { - if ($this->loaded) { - // Check whether the loader has the same cache - if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) { - @trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED); - } - - return $this->loadedList->getValuesForChoices($choices); - } - return $this->loader->loadValuesForChoices($choices, $this->value); } } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 25bb52f290..1836c4a6c0 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -273,22 +273,6 @@ class ChoiceType extends AbstractType return $options['required'] ? null : ''; }; - $choicesAsValuesNormalizer = function (Options $options, $choicesAsValues) { - // Not set by the user - if (null === $choicesAsValues) { - return true; - } - - // Set by the user - if (true !== $choicesAsValues) { - throw new \RuntimeException(sprintf('The "choices_as_values" option of the %s should not be used. Remove it and flip the contents of the "choices" option instead.', get_class($this))); - } - - @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 true; - }; - $placeholderNormalizer = function (Options $options, $placeholder) { if ($options['multiple']) { // never use an empty value for this case @@ -324,7 +308,6 @@ class ChoiceType extends AbstractType 'multiple' => false, 'expanded' => false, 'choices' => array(), - 'choices_as_values' => null, // deprecated since 3.1 'choice_loader' => null, 'choice_label' => null, 'choice_name' => null, @@ -345,7 +328,6 @@ class ChoiceType extends AbstractType $resolver->setNormalizer('placeholder', $placeholderNormalizer); $resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer); - $resolver->setNormalizer('choices_as_values', $choicesAsValuesNormalizer); $resolver->setAllowedTypes('choices', array('null', 'array', '\Traversable')); $resolver->setAllowedTypes('choice_translation_domain', array('null', 'bool', 'string')); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php index 02e8e09cdc..a96a42d3d6 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php @@ -15,7 +15,6 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Intl\Intl; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class CountryType extends AbstractType implements ChoiceLoaderInterface @@ -37,15 +36,7 @@ class CountryType extends AbstractType implements ChoiceLoaderInterface public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'choice_loader' => function (Options $options) { - if ($options['choices']) { - @trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED); - - return null; - } - - return $this; - }, + 'choice_loader' => $this, '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 990235c10a..9970d03ad7 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php @@ -15,7 +15,6 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Intl\Intl; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class CurrencyType extends AbstractType implements ChoiceLoaderInterface @@ -37,15 +36,7 @@ class CurrencyType extends AbstractType implements ChoiceLoaderInterface public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'choice_loader' => function (Options $options) { - if ($options['choices']) { - @trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED); - - return null; - } - - return $this; - }, + 'choice_loader' => $this, 'choice_translation_domain' => false, )); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php index 2137c65a9e..279402a3e2 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php @@ -15,7 +15,6 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Intl\Intl; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class LanguageType extends AbstractType implements ChoiceLoaderInterface @@ -37,15 +36,7 @@ class LanguageType extends AbstractType implements ChoiceLoaderInterface public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'choice_loader' => function (Options $options) { - if ($options['choices']) { - @trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED); - - return null; - } - - return $this; - }, + 'choice_loader' => $this, '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 38e62af060..de795956b7 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php @@ -15,7 +15,6 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Intl\Intl; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class LocaleType extends AbstractType implements ChoiceLoaderInterface @@ -37,15 +36,7 @@ class LocaleType extends AbstractType implements ChoiceLoaderInterface public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'choice_loader' => function (Options $options) { - if ($options['choices']) { - @trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED); - - return null; - } - - return $this; - }, + 'choice_loader' => $this, 'choice_translation_domain' => false, )); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php index ffa86cb9aa..fbfce90ba5 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php @@ -14,7 +14,6 @@ namespace Symfony\Component\Form\Extension\Core\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; -use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; class TimezoneType extends AbstractType implements ChoiceLoaderInterface @@ -34,15 +33,7 @@ class TimezoneType extends AbstractType implements ChoiceLoaderInterface public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'choice_loader' => function (Options $options) { - if ($options['choices']) { - @trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED); - - return null; - } - - return $this; - }, + 'choice_loader' => $this, 'choice_translation_domain' => false, )); } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index d100dcff4a..43c91c363d 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -64,21 +64,6 @@ class PropertyAccessDecoratorTest extends TestCase $this->assertSame(array('value'), $this->factory->createListFromChoices($choices, new PropertyPath('property'))); } - /** - * @group legacy - */ - public function testCreateFromChoicesPropertyPathWithCallableString() - { - $choices = array('foo' => 'bar'); - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromChoices') - ->with($choices, 'end') - ->willReturn('RESULT'); - - $this->assertSame('RESULT', $this->factory->createListFromChoices($choices, 'end')); - } - public function testCreateFromLoaderPropertyPath() { $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); @@ -93,21 +78,6 @@ class PropertyAccessDecoratorTest extends TestCase $this->assertSame('value', $this->factory->createListFromLoader($loader, 'property')); } - /** - * @group legacy - */ - public function testCreateFromLoaderPropertyPathWithCallableString() - { - $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); - - $this->decoratedFactory->expects($this->once()) - ->method('createListFromLoader') - ->with($loader, 'end') - ->willReturn('RESULT'); - - $this->assertSame('RESULT', $this->factory->createListFromLoader($loader, 'end')); - } - // https://github.com/symfony/symfony/issues/5494 public function testCreateFromChoicesAssumeNullIfValuePropertyPathUnreadable() { @@ -169,24 +139,6 @@ class PropertyAccessDecoratorTest extends TestCase )); } - /** - * @group legacy - */ - public function testCreateViewPreferredChoicesAsPropertyPathWithCallableString() - { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, 'end') - ->willReturn('RESULT'); - - $this->assertSame('RESULT', $this->factory->createView( - $list, - 'end' - )); - } - public function testCreateViewPreferredChoicesAsPropertyPathInstance() { $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); @@ -240,25 +192,6 @@ class PropertyAccessDecoratorTest extends TestCase )); } - /** - * @group legacy - */ - public function testCreateViewLabelsAsPropertyPathWithCallableString() - { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, 'end') - ->willReturn('RESULT'); - - $this->assertSame('RESULT', $this->factory->createView( - $list, - null, // preferred choices - 'end' - )); - } - public function testCreateViewLabelsAsPropertyPathInstance() { $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); @@ -296,26 +229,6 @@ class PropertyAccessDecoratorTest extends TestCase )); } - /** - * @group legacy - */ - public function testCreateViewIndicesAsPropertyPathWithCallableString() - { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, 'end') - ->willReturn('RESULT'); - - $this->assertSame('RESULT', $this->factory->createView( - $list, - null, // preferred choices - null, // label - 'end' - )); - } - public function testCreateViewIndicesAsPropertyPathInstance() { $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); @@ -355,27 +268,6 @@ class PropertyAccessDecoratorTest extends TestCase )); } - /** - * @group legacy - */ - public function testCreateViewGroupsAsPropertyPathWithCallableString() - { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, 'end') - ->willReturn('RESULT'); - - $this->assertSame('RESULT', $this->factory->createView( - $list, - null, // preferred choices - null, // label - null, // index - 'end' - )); - } - public function testCreateViewGroupsAsPropertyPathInstance() { $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); @@ -438,28 +330,6 @@ class PropertyAccessDecoratorTest extends TestCase )); } - /** - * @group legacy - */ - public function testCreateViewAttrAsPropertyPathWithCallableString() - { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - - $this->decoratedFactory->expects($this->once()) - ->method('createView') - ->with($list, null, null, null, null, 'end') - ->willReturn('RESULT'); - - $this->assertSame('RESULT', $this->factory->createView( - $list, - null, // preferred choices - null, // label - null, // inde - null, // groups - 'end' - )); - } - public function testCreateViewAttrAsPropertyPathInstance() { $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php index 61c8a5aa0b..57b1259254 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Tests\ChoiceList; use PHPUnit\Framework\TestCase; -use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\LazyChoiceList; /** @@ -61,30 +60,6 @@ class LazyChoiceListTest extends TestCase $this->assertSame('RESULT', $this->list->getChoices()); } - /** - * @group legacy - */ - public function testGetChoicesUsesLoadedListWhenLoaderDoesNotCacheChoiceListOnFirstCall() - { - $this->loader->expects($this->at(0)) - ->method('loadChoiceList') - ->with($this->value) - ->willReturn($this->loadedList); - - $this->loader->expects($this->at(1)) - ->method('loadChoiceList') - ->with($this->value) - ->willReturn(new ArrayChoiceList(array('a', 'b'))); - - // The same list is returned by the lazy choice list - $this->loadedList->expects($this->exactly(2)) - ->method('getChoices') - ->will($this->returnValue('RESULT')); - - $this->assertSame('RESULT', $this->list->getChoices()); - $this->assertSame('RESULT', $this->list->getChoices()); - } - public function testGetValuesLoadsLoadedListOnFirstCall() { $this->loader->expects($this->exactly(2)) @@ -146,18 +121,13 @@ class LazyChoiceListTest extends TestCase public function testGetChoicesForValuesUsesLoadedList() { - $this->loader->expects($this->exactly(3)) + $this->loader->expects($this->exactly(1)) ->method('loadChoiceList') ->with($this->value) - // For BC, the same choice loaded list is returned 3 times - // It should only twice in 4.0 ->will($this->returnValue($this->loadedList)); - $this->loader->expects($this->never()) - ->method('loadChoicesForValues'); - - $this->loadedList->expects($this->exactly(2)) - ->method('getChoicesForValues') + $this->loader->expects($this->exactly(2)) + ->method('loadChoicesForValues') ->with(array('a', 'b')) ->will($this->returnValue('RESULT')); @@ -168,34 +138,15 @@ class LazyChoiceListTest extends TestCase $this->assertSame('RESULT', $this->list->getChoicesForValues(array('a', 'b'))); } - /** - * @group legacy - */ - public function testGetValuesForChoicesForwardsCallIfListNotLoaded() - { - $this->loader->expects($this->exactly(2)) - ->method('loadValuesForChoices') - ->with(array('a', 'b')) - ->will($this->returnValue('RESULT')); - - $this->assertSame('RESULT', $this->list->getValuesForChoices(array('a', 'b'))); - $this->assertSame('RESULT', $this->list->getValuesForChoices(array('a', 'b'))); - } - public function testGetValuesForChoicesUsesLoadedList() { - $this->loader->expects($this->exactly(3)) + $this->loader->expects($this->exactly(1)) ->method('loadChoiceList') ->with($this->value) - // For BC, the same choice loaded list is returned 3 times - // It should only twice in 4.0 ->will($this->returnValue($this->loadedList)); - $this->loader->expects($this->never()) - ->method('loadValuesForChoices'); - - $this->loadedList->expects($this->exactly(2)) - ->method('getValuesForChoices') + $this->loader->expects($this->exactly(2)) + ->method('loadValuesForChoices') ->with(array('a', 'b')) ->will($this->returnValue('RESULT')); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ExtendedChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ExtendedChoiceTypeTest.php index 959ae488a1..0475254d97 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ExtendedChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ExtendedChoiceTypeTest.php @@ -18,26 +18,6 @@ use Symfony\Component\Form\Tests\Fixtures\LazyChoiceTypeExtension; class ExtendedChoiceTypeTest extends TestCase { - /** - * @group legacy - * @dataProvider provideTestedTypes - */ - public function testLegacyChoicesAreOverridden($type) - { - $factory = Forms::createFormFactoryBuilder() - ->addTypeExtension(new ChoiceTypeExtension($type)) - ->getFormFactory() - ; - - $choices = $factory->create($type)->createView()->vars['choices']; - - $this->assertCount(2, $choices); - $this->assertSame('A', $choices[0]->label); - $this->assertSame('a', $choices[0]->value); - $this->assertSame('B', $choices[1]->label); - $this->assertSame('b', $choices[1]->value); - } - /** * @dataProvider provideTestedTypes */