Skip to content

Commit 3411276

Browse files
committed
Fixing missing check in constraing and adding skip-test in tests where SplEnum is not installed.
1 parent 9579aec commit 3411276

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Component/Validator/Constraints/ChoiceValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function validate($value, Constraint $constraint)
3434
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Choice');
3535
}
3636

37-
if (!is_array($constraint->choices) && !$constraint->callback) {
37+
if (!is_array($constraint->choices) && !$constraint->callback && !$constraint->enum) {
3838
throw new ConstraintDefinitionException('Either "choices" or "callback" must be specified on constraint Choice');
3939
}
4040

src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ public function testValidChoiceCallbackContextObjectMethod()
154154

155155
public function testValidChoiceSplEnum()
156156
{
157+
if (!class_exists('\SplEnum')) {
158+
$this->markTestSkipped('SplEnum is not installed on this system.');
159+
}
160+
157161
$constraint = new Choice(array('enum' => new class extends \SplEnum {
158162
const __default = 'foo';
159163
const FOO = 'foo';

0 commit comments

Comments
 (0)