Skip to content

Commit

Permalink
filter out invalid Intl values
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Dec 8, 2018
1 parent 9e84e0f commit a2d6940
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
Expand Up @@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
return array();
}

// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}

return $this->loadChoiceList($value)->getChoicesForValues($values);
}

Expand Down
Expand Up @@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
return array();
}

// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}

return $this->loadChoiceList($value)->getChoicesForValues($values);
}

Expand Down
Expand Up @@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
return array();
}

// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}

return $this->loadChoiceList($value)->getChoicesForValues($values);
}

Expand Down
5 changes: 0 additions & 5 deletions src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php
Expand Up @@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
return array();
}

// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}

return $this->loadChoiceList($value)->getChoicesForValues($values);
}

Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -61,4 +62,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'FR', $expectedD
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}

public function testInvalidChoiceValuesAreDropped()
{
$type = new CountryType();

$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}
Expand Up @@ -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
Expand Down Expand Up @@ -44,4 +45,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'EUR', $expected
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}

public function testInvalidChoiceValuesAreDropped()
{
$type = new CurrencyType();

$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}
Expand Up @@ -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
Expand Down Expand Up @@ -54,4 +55,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'en', $expectedD
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}

public function testInvalidChoiceValuesAreDropped()
{
$type = new LanguageType();

$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}
Expand Up @@ -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
Expand Down Expand Up @@ -44,4 +45,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'en', $expectedD
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}

public function testInvalidChoiceValuesAreDropped()
{
$type = new LocaleType();

$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}

0 comments on commit a2d6940

Please sign in to comment.