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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jum 8000 p 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