[Form] Fixed regression in BooleanToStringTransformer from ed83752
This commit is contained in:
parent
610301d5e0
commit
2747bdca76
@ -49,6 +49,10 @@ class BooleanToStringTransformer implements DataTransformerInterface
|
|||||||
*/
|
*/
|
||||||
public function transform($value)
|
public function transform($value)
|
||||||
{
|
{
|
||||||
|
if (null === $value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_bool($value)) {
|
if (!is_bool($value)) {
|
||||||
throw new TransformationFailedException('Expected a Boolean.');
|
throw new TransformationFailedException('Expected a Boolean.');
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,10 @@ class BooleanToStringTransformerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($this->transformer->transform(false));
|
$this->assertNull($this->transformer->transform(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// https://github.com/symfony/symfony/issues/8989
|
||||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
public function testTransformAcceptsNull()
|
||||||
*/
|
|
||||||
public function testTransformFailsIfNull()
|
|
||||||
{
|
{
|
||||||
$this->transformer->transform(null);
|
$this->assertNull($this->transformer->transform(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user