[Form] Fixed regression in BooleanToStringTransformer from ed83752

This commit is contained in:
Bernhard Schussek 2013-09-12 09:25:54 +02:00
parent 610301d5e0
commit 2747bdca76
2 changed files with 7 additions and 5 deletions

View File

@ -49,6 +49,10 @@ class BooleanToStringTransformer implements DataTransformerInterface
*/
public function transform($value)
{
if (null === $value) {
return null;
}
if (!is_bool($value)) {
throw new TransformationFailedException('Expected a Boolean.');
}

View File

@ -38,12 +38,10 @@ class BooleanToStringTransformerTest extends \PHPUnit_Framework_TestCase
$this->assertNull($this->transformer->transform(false));
}
/**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/
public function testTransformFailsIfNull()
// https://github.com/symfony/symfony/issues/8989
public function testTransformAcceptsNull()
{
$this->transformer->transform(null);
$this->assertNull($this->transformer->transform(null));
}
/**