Closed
Description
Symfony version(s) affected: 5.1.4
Description
After the last update a problem appeared in one of my tests.
It's a test case for my custom constraint validator. I'm using extending the ConstraintValidatorTestCase
from Symfony to make things easier.
The validator itself does some logic and delegates the validation to some other constraint like this:
$this->context
->getValidator()
->inContext($this->context)
->atPath($this->context->getPropertyPath())
->validate(...);
So in the test I need mock the ContextualValidator a little bit which worked fine until recently but now triggers this error:
Trying to configure method "atPath" which cannot be configured because it does not exist, has not been specified, is final, or is static
How to reproduce
final class MyValidatorTest extends ConstraintValidatorTestCase
{
public function testValidate(): void
{
/** @var MockObject $contextualValidator */
$contextualValidator = $this->context->getValidator()->inContext($this->context);
$contextualValidator
->method('atPath')
->willReturnSelf();
// ...
}
protected function createValidator(): MyValidator
{
return new MyValidator();
}
}