bug #29500 [Form] filter out invalid Intl values (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] filter out invalid Intl values

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23679
| License       | MIT
| Doc PR        |

Commits
-------

a2d694009f filter out invalid Intl values
This commit is contained in:
Nicolas Grekas 2018-12-08 16:20:02 +00:00
commit 7a46c98f00
8 changed files with 32 additions and 20 deletions

View File

@ -89,11 +89,6 @@ class CountryType extends AbstractType implements ChoiceLoaderInterface
return array();
}
// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}
return $this->loadChoiceList($value)->getChoicesForValues($values);
}

View File

@ -89,11 +89,6 @@ class CurrencyType extends AbstractType implements ChoiceLoaderInterface
return array();
}
// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}
return $this->loadChoiceList($value)->getChoicesForValues($values);
}

View File

@ -89,11 +89,6 @@ class LanguageType extends AbstractType implements ChoiceLoaderInterface
return array();
}
// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}
return $this->loadChoiceList($value)->getChoicesForValues($values);
}

View File

@ -89,11 +89,6 @@ class LocaleType extends AbstractType implements ChoiceLoaderInterface
return array();
}
// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}
return $this->loadChoiceList($value)->getChoicesForValues($values);
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Intl\Util\IntlTestHelper;
class CountryTypeTest extends BaseTypeTest
@ -61,4 +62,11 @@ class CountryTypeTest extends BaseTypeTest
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}
public function testInvalidChoiceValuesAreDropped()
{
$type = new CountryType();
$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
use Symfony\Component\Intl\Util\IntlTestHelper;
class CurrencyTypeTest extends BaseTypeTest
@ -44,4 +45,11 @@ class CurrencyTypeTest extends BaseTypeTest
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}
public function testInvalidChoiceValuesAreDropped()
{
$type = new CurrencyType();
$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
use Symfony\Component\Intl\Util\IntlTestHelper;
class LanguageTypeTest extends BaseTypeTest
@ -54,4 +55,11 @@ class LanguageTypeTest extends BaseTypeTest
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}
public function testInvalidChoiceValuesAreDropped()
{
$type = new LanguageType();
$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\LocaleType;
use Symfony\Component\Intl\Util\IntlTestHelper;
class LocaleTypeTest extends BaseTypeTest
@ -44,4 +45,11 @@ class LocaleTypeTest extends BaseTypeTest
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}
public function testInvalidChoiceValuesAreDropped()
{
$type = new LocaleType();
$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}