Skip to content

Commit b2a73f4

Browse files
committed
Fix FormTypeClassValidatorTest on PHPUnit 12.2 (Symfony 8.x CI matrix)
The captureMessages() helper stubbed ConstraintViolationBuilderInterface and configured its setParameter() method. That method returns `static`, which the PHPUnit version simple-phpunit pins on the Symfony 8.x matrix (12.2) cannot configure via createStub() - it throws MethodCannotBeConfiguredException. It passed locally only because we run PHPUnit 12.5. Reuse the file's existing concrete ConstraintViolationBuilderStub (real fluent methods, no mocking) - the same stub the other violation tests in this file already use and which passes CI. Only the builder changes; the context stub, which returns the interface (not static), is unaffected.
1 parent 27861ac commit b2a73f4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

tests/Validator/Constraints/FormTypeClassValidatorTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,10 @@ private function captureMessages(mixed $value, Constraint $constraint, iterable
199199
$validator = new FormTypeClassValidator($formTypes);
200200

201201
$messages = [];
202-
$builder = $this->createStub(ConstraintViolationBuilderInterface::class);
203-
$builder->method('setParameter')->willReturn($builder);
204-
$builder->method('atPath')->willReturn($builder);
202+
// Reuse the concrete stub: ConstraintViolationBuilderInterface's fluent methods return
203+
// `static`, which the PHPUnit version pinned by simple-phpunit on the Symfony 8.x matrix
204+
// (12.2) cannot mock via createStub() (works on 12.5 locally, fails on CI).
205+
$builder = new ConstraintViolationBuilderStub();
205206

206207
$context = $this->createStub(ExecutionContextInterface::class);
207208
$context->method('buildViolation')->willReturnCallback(static function (string $message) use (&$messages, $builder): ConstraintViolationBuilderInterface {

0 commit comments

Comments
 (0)