Skip to content

Fix FormTypeClassValidatorTest on PHPUnit 12.2 (Symfony 8.x CI) - #204

Merged
silverbackdan merged 1 commit into
mainfrom
fix/formtype-test-phpunit122-stub
Jul 20, 2026
Merged

Fix FormTypeClassValidatorTest on PHPUnit 12.2 (Symfony 8.x CI)#204
silverbackdan merged 1 commit into
mainfrom
fix/formtype-test-phpunit122-stub

Conversation

@silverbackdan

Copy link
Copy Markdown
Collaborator

Summary

Fixes the 4 PHPUnit errors on the Symfony 8.x / PHP 8.5 CI matrix:

MethodCannotBeConfiguredException: Trying to configure method "setParameter" which cannot be configured because it ... is ... static

captureMessages() stubbed ConstraintViolationBuilderInterface and configured setParameter(), whose return type is static. The PHPUnit version symfony/phpunit-bridge's simple-phpunit pins on that matrix (12.2) cannot configure a static-returning method via createStub(). It passed locally only because we run 12.5. setParameter was the only such method configured — the tests that pass CI (incl. others in this same file, and NewEmailAddressValidatorTest) only ever configure atPath or use the concrete stub.

Fix: reuse the file's existing concrete ConstraintViolationBuilderStub (real fluent methods, zero mocking) for the builder — the exact pattern the file's other violation tests already use and which passes CI. The context stub (returns the interface, not static) is unchanged.

No production changes. Full validator suite green locally.

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.
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 27.34%. Comparing base (27861ac) to head (b2a73f4).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #204   +/-   ##
=========================================
  Coverage     27.34%   27.34%           
  Complexity     2526     2526           
=========================================
  Files           253      253           
  Lines          7364     7364           
=========================================
  Hits           2014     2014           
  Misses         5350     5350           
Flag Coverage Δ
phpunit 27.34% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@silverbackdan
silverbackdan merged commit 66ee9fa into main Jul 20, 2026
12 of 13 checks passed
@silverbackdan
silverbackdan deleted the fix/formtype-test-phpunit122-stub branch July 20, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant