Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form] filter out invalid Intl values #29500

Merged
merged 1 commit into from
Dec 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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')));
}
}
Original file line number Diff line number Diff line change
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')));
}
}
Original file line number Diff line number Diff line change
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')));
}
}
Original file line number Diff line number Diff line change
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')));
}
}