Skip to content

Commit dae688d

Browse files
committed
filter out invalid Intl values
1 parent 5cc31ca commit dae688d

File tree

8 files changed

+32
-20
lines changed

8 files changed

+32
-20
lines changed

Extension/Core/Type/CountryType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
8989
return array();
9090
}
9191

92-
// If no callable is set, values are the same as choices
93-
if (null === $value) {
94-
return $values;
95-
}
96-
9792
return $this->loadChoiceList($value)->getChoicesForValues($values);
9893
}
9994

Extension/Core/Type/CurrencyType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
8989
return array();
9090
}
9191

92-
// If no callable is set, values are the same as choices
93-
if (null === $value) {
94-
return $values;
95-
}
96-
9792
return $this->loadChoiceList($value)->getChoicesForValues($values);
9893
}
9994

Extension/Core/Type/LanguageType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
8989
return array();
9090
}
9191

92-
// If no callable is set, values are the same as choices
93-
if (null === $value) {
94-
return $values;
95-
}
96-
9792
return $this->loadChoiceList($value)->getChoicesForValues($values);
9893
}
9994

Extension/Core/Type/LocaleType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
8989
return array();
9090
}
9191

92-
// If no callable is set, values are the same as choices
93-
if (null === $value) {
94-
return $values;
95-
}
96-
9792
return $this->loadChoiceList($value)->getChoicesForValues($values);
9893
}
9994

Tests/Extension/Core/Type/CountryTypeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
15+
use Symfony\Component\Form\Extension\Core\Type\CountryType;
1516
use Symfony\Component\Intl\Util\IntlTestHelper;
1617

1718
class CountryTypeTest extends BaseTypeTest
@@ -61,4 +62,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'FR', $expectedD
6162
{
6263
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
6364
}
65+
66+
public function testInvalidChoiceValuesAreDropped()
67+
{
68+
$type = new CountryType();
69+
70+
$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
71+
}
6472
}

Tests/Extension/Core/Type/CurrencyTypeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
15+
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
1516
use Symfony\Component\Intl\Util\IntlTestHelper;
1617

1718
class CurrencyTypeTest extends BaseTypeTest
@@ -44,4 +45,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'EUR', $expected
4445
{
4546
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
4647
}
48+
49+
public function testInvalidChoiceValuesAreDropped()
50+
{
51+
$type = new CurrencyType();
52+
53+
$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
54+
}
4755
}

Tests/Extension/Core/Type/LanguageTypeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
15+
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
1516
use Symfony\Component\Intl\Util\IntlTestHelper;
1617

1718
class LanguageTypeTest extends BaseTypeTest
@@ -54,4 +55,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'en', $expectedD
5455
{
5556
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
5657
}
58+
59+
public function testInvalidChoiceValuesAreDropped()
60+
{
61+
$type = new LanguageType();
62+
63+
$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
64+
}
5765
}

Tests/Extension/Core/Type/LocaleTypeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
15+
use Symfony\Component\Form\Extension\Core\Type\LocaleType;
1516
use Symfony\Component\Intl\Util\IntlTestHelper;
1617

1718
class LocaleTypeTest extends BaseTypeTest
@@ -44,4 +45,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'en', $expectedD
4445
{
4546
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
4647
}
48+
49+
public function testInvalidChoiceValuesAreDropped()
50+
{
51+
$type = new LocaleType();
52+
53+
$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
54+
}
4755
}

0 commit comments

Comments
 (0)