Skip to content

Commit 1f517dd

Browse files
committed
[Validator] Fix AssertingContextualValidator when there is no expectation for atPath()
1 parent b8218d2 commit 1f517dd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Test/ConstraintValidatorTestCase.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ protected function expectValidateAt(int $i, string $propertyPath, $value, $group
238238
protected function expectValidateValue(int $i, $value, array $constraints = [], $group = null)
239239
{
240240
$contextualValidator = $this->context->getValidator()->inContext($this->context);
241-
$contextualValidator->expectValidation($i, '', $value, $group, function ($passedConstraints) use ($constraints) {
241+
$contextualValidator->expectValidation($i, null, $value, $group, function ($passedConstraints) use ($constraints) {
242242
if (\is_array($constraints) && !\is_array($passedConstraints)) {
243243
$passedConstraints = [$passedConstraints];
244244
}
@@ -250,7 +250,7 @@ protected function expectValidateValue(int $i, $value, array $constraints = [],
250250
protected function expectFailingValueValidation(int $i, $value, array $constraints, $group, ConstraintViolationInterface $violation)
251251
{
252252
$contextualValidator = $this->context->getValidator()->inContext($this->context);
253-
$contextualValidator->expectValidation($i, '', $value, $group, function ($passedConstraints) use ($constraints) {
253+
$contextualValidator->expectValidation($i, null, $value, $group, function ($passedConstraints) use ($constraints) {
254254
if (\is_array($constraints) && !\is_array($passedConstraints)) {
255255
$passedConstraints = [$passedConstraints];
256256
}
@@ -573,9 +573,12 @@ public function expectNoValidate()
573573
$this->expectNoValidate = true;
574574
}
575575

576-
public function expectValidation(string $call, string $propertyPath, $value, $group, callable $constraints, ConstraintViolationInterface $violation = null)
576+
public function expectValidation(string $call, ?string $propertyPath, $value, $group, callable $constraints, ConstraintViolationInterface $violation = null)
577577
{
578-
$this->expectedAtPath[$call] = $propertyPath;
578+
if (null !== $propertyPath) {
579+
$this->expectedAtPath[$call] = $propertyPath;
580+
}
581+
579582
$this->expectedValidate[$call] = [$value, $group, $constraints, $violation];
580583
}
581584
}

0 commit comments

Comments
 (0)