feature #22860 [Form] remove deprecated features (xabbuh)
This PR was merged into the 4.0-dev branch.
Discussion
----------
[Form] remove deprecated features
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | yes
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Commits
-------
928da1a
[Form] remove deprecated features
This commit is contained in:
commit
089377f28b
@ -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
|
||||
-----
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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'));
|
||||
|
@ -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,
|
||||
));
|
||||
}
|
||||
|
@ -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,
|
||||
));
|
||||
}
|
||||
|
@ -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,
|
||||
));
|
||||
}
|
||||
|
@ -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,
|
||||
));
|
||||
}
|
||||
|
@ -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,
|
||||
));
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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'));
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user