8000 [OptionsResolver] added test for allowed values and types that default to null by Tobion · Pull Request #13331 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[OptionsResolver] added test for allowed values and types that default to null #13331

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

Merged
merged 1 commit into from
Jan 26, 2015
Merged
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 @@ -504,7 +504,19 @@ public function testFailIfSetAllowedTypesFromLazyOption()
*/
public function testResolveFailsIfInvalidType()
{
$this->resolver->setDefault('foo', 42);
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string');

$this->resolver->resolve(array('foo' => 42));
}

/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
* @expectedExceptionMessage The option "foo" with value null is expected to be of type "string", but is of type "NULL".
*/
public function testResolveFailsIfInvalidTypeIsNull()
{
$this->resolver->setDefault('foo', null);
$this->resolver->setAllowedTypes('foo', 'string');

$this->resolver->resolve();
Expand Down Expand Up @@ -675,7 +687,19 @@ public function testFailIfSetAllowedValuesFromLazyOption()
*/
public function testResolveFailsIfInvalidValue()
{
$this->resolver->setDefault('foo', 42);
$this->resolver->setDefined('foo');
$this->resolver->setAllowedValues('foo', 'bar');

$this->resolver->resolve(array('foo' => 42));
}

/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
* @expectedExceptionMessage The option "foo" with value null is invalid. Accepted values are: "bar".
*/
public function testResolveFailsIfInvalidValueIsNull()
{
$this->resolver->setDefault('foo', null);
$this->resolver->setAllowedValues('foo', 'bar');

$this->resolver->resolve();
Expand Down
0