[Validator] added support for '0' as default constraint option value
This commit is contained in:
parent
8c9f9de086
commit
f2c4f20e70
@ -67,7 +67,7 @@ class Constraint
|
||||
$invalidOptions[] = $option;
|
||||
}
|
||||
}
|
||||
} else if ($options) {
|
||||
} else if ($options !== null && ! (is_array($options) && count($options) === 0)) {
|
||||
$option = $this->defaultOption();
|
||||
|
||||
if (is_null($option)) {
|
||||
|
@ -82,4 +82,15 @@ class ConstraintTest extends \PHPUnit_Framework_TestCase
|
||||
$constraint->addImplicitGroupName('Foo');
|
||||
$this->assertEquals(array('Default', 'Foo'), $constraint->groups);
|
||||
}
|
||||
|
||||
public function testAllowsSettingZeroRequiredPropertyValue()
|
||||
{
|
||||
$constraint = new ConstraintA(0);
|
||||
$this->assertEquals(0, $constraint->property2);
|
||||
}
|
||||
|
||||
public function testCanCreateConstraintWithNoDefaultOptionAndEmptyArray()
|
||||
{
|
||||
new ConstraintB(array());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user