Skip to content

Commit

Permalink
bug #34458 [Validator] ConstraintValidatorTestCase: add missing retur…
Browse files Browse the repository at this point in the history
…n value to mocked validate method calls (ogizanagi)

This PR was merged into the 3.4 branch.

Discussion
----------

[Validator] ConstraintValidatorTestCase: add missing return value to mocked validate method calls

| Q             | A
| ------------- | ---
| Branch?       | 3.4 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | N/A <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | N/A

Spotted while working on #34456.
Not sure it should really qualify as a bugfix, but the `ContextualValidatorInterface::validate` method is expected to return the instance. If [chaining in a validator](https://github.com/symfony/symfony/pull/34456/files#diff-0e6e3106aa637d750d47e86a14cef8d4R43), trying to use this test methods would throw an error, trying to call a method on `null`.

Commits
-------

8d1f326 [Validator] ConstraintValidatorTestCase: add missing return value to mocked validate method calls
  • Loading branch information
Robin Chalas committed Nov 23, 2019
2 parents b104760 + 8d1f326 commit 814bdeb
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -177,7 +177,8 @@ protected function expectValidateAt($i, $propertyPath, $value, $group)
->willReturn($validator);
$validator->expects($this->at(2 * $i + 1))
->method('validate')
->with($value, $this->logicalOr(null, [], $this->isInstanceOf('\Symfony\Component\Validator\Constraints\Valid')), $group);
->with($value, $this->logicalOr(null, [], $this->isInstanceOf('\Symfony\Component\Validator\Constraints\Valid')), $group)
->willReturn($validator);
}

protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group = null)
Expand All @@ -189,7 +190,8 @@ protected function expectValidateValueAt($i, $propertyPath, $value, $constraints
->willReturn($contextualValidator);
$contextualValidator->expects($this->at(2 * $i + 1))
->method('validate')
->with($value, $constraints, $group);
->with($value, $constraints, $group)
->willReturn($contextualValidator);
}

protected function assertNoViolation()
Expand Down

0 comments on commit 814bdeb

Please sign in to comment.