Skip to content

Commit 408b6a9

Browse files
Merge branch '6.0' into 6.1
* 6.0: [Validator] Fix AssertingContextualValidator when there is no expectation for atPath()
2 parents 8420357 + 276b537 commit 408b6a9

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
@@ -241,7 +241,7 @@ protected function expectValidateAt(int $i, string $propertyPath, mixed $value,
241241
protected function expectValidateValue(int $i, mixed $value, array $constraints = [], string|GroupSequence|array $group = null)
242242
{
243243
$contextualValidator = $this->context->getValidator()->inContext($this->context);
244-
$contextualValidator->expectValidation($i, '', $value, $group, function ($passedConstraints) use ($constraints) {
244+
$contextualValidator->expectValidation($i, null, $value, $group, function ($passedConstraints) use ($constraints) {
245245
if (\is_array($constraints) && !\is_array($passedConstraints)) {
246246
$passedConstraints = [$passedConstraints];
247247
}
@@ -253,7 +253,7 @@ protected function expectValidateValue(int $i, mixed $value, array $constraints
253253
protected function expectFailingValueValidation(int $i, mixed $value, array $constraints, string|GroupSequence|array|null $group, ConstraintViolationInterface $violation)
254254
{
255255
$contextualValidator = $this->context->getValidator()->inContext($this->context);
256-
$contextualValidator->expectValidation($i, '', $value, $group, function ($passedConstraints) use ($constraints) {
256+
$contextualValidator->expectValidation($i, null, $value, $group, function ($passedConstraints) use ($constraints) {
257257
if (\is_array($constraints) && !\is_array($passedConstraints)) {
258258
$passedConstraints = [$passedConstraints];
259259
}
@@ -575,9 +575,12 @@ public function expectNoValidate()
575575
$this->expectNoValidate = true;
576576
}
577577

578-
public function expectValidation(string $call, string $propertyPath, mixed $value, string|GroupSequence|array|null $group, callable $constraints, ConstraintViolationInterface $violation = null)
578+
public function expectValidation(string $call, ?string $propertyPath, mixed $value, string|GroupSequence|array|null $group, callable $constraints, ConstraintViolationInterface $violation = null)
579579
{
580-
$this->expectedAtPath[$call] = $propertyPath;
580+
if (null !== $propertyPath) {
581+
$this->expectedAtPath[$call] = $propertyPath;
582+
}
583+
581584
$this->expectedValidate[$call] = [$value, $group, $constraints, $violation];
582585
}
583586
}

0 commit comments

Comments
 (0)