Skip to content

Commit 276b537

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Validator] Fix AssertingContextualValidator when there is no expectation for atPath()
2 parents 34e6cc8 + 1f517dd commit 276b537

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
@@ -239,7 +239,7 @@ protected function expectValidateAt(int $i, string $propertyPath, mixed $value,
239239
protected function expectValidateValue(int $i, mixed $value, array $constraints = [], string|GroupSequence|array $group = null)
240240
{
241241
$contextualValidator = $this->context->getValidator()->inContext($this->context);
242-
$contextualValidator->expectValidation($i, '', $value, $group, function ($passedConstraints) use ($constraints) {
242+
$contextualValidator->expectValidation($i, null, $value, $group, function ($passedConstraints) use ($constraints) {
243243
if (\is_array($constraints) && !\is_array($passedConstraints)) {
244244
$passedConstraints = [$passedConstraints];
245245
}
@@ -251,7 +251,7 @@ protected function expectValidateValue(int $i, mixed $value, array $constraints
251251
protected function expectFailingValueValidation(int $i, mixed $value, array $constraints, string|GroupSequence|array|null $group, ConstraintViolationInterface $violation)
252252
{
253253
$contextualValidator = $this->context->getValidator()->inContext($this->context);
254-
$contextualValidator->expectValidation($i, '', $value, $group, function ($passedConstraints) use ($constraints) {
254+
$contextualValidator->expectValidation($i, null, $value, $group, function ($passedConstraints) use ($constraints) {
255255
if (\is_array($constraints) && !\is_array($passedConstraints)) {
256256
$passedConstraints = [$passedConstraints];
257257
}
@@ -573,9 +573,12 @@ public function expectNoValidate()
573573
$this->expectNoValidate = true;
574574
}
575575

576-
public function expectValidation(string $call, string $propertyPath, mixed $value, string|GroupSequence|array|null $group, callable $constraints, ConstraintViolationInterface $violation = null)
576+
public function expectValidation(string $call, ?string $propertyPath, mixed $value, string|GroupSequence|array|null $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)