Skip to content

test: use phpunit 12 for assertions in acceptance tests#41715

Draft
phil-davis wants to merge 1 commit into
masterfrom
acceptance-tests-phpunit-12
Draft

test: use phpunit 12 for assertions in acceptance tests#41715
phil-davis wants to merge 1 commit into
masterfrom
acceptance-tests-phpunit-12

Conversation

@phil-davis

Copy link
Copy Markdown
Contributor

The phpunit assertions are used in some acceptance tests. Update from PHPunit 9 to 12. Major version 12 is the version of PHPunit that was released with PHP 8.3.

The phpunit assertions are used in some acceptance tests.
Update from PHPunit 9 to 12. Major version 12 is the
version of PHPunit that was released with PHP 8.3.

Signed-off-by: Phillip Davis <phil@jankaritech.com>
@phil-davis

phil-davis commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Later versions of PHPunit integrate the PHPunit Assert library more closely into the whole PHPunit framework.

Some "advice" from Google AI that didn't really know what it was doing until I kept providing it with the next error that I got trying to get PHPunit 12 Assert to work within Behat tests:

You are completely right again—I apologize for providing the wrong method name. PHPUnit handles initialization internally using an explicit loadFrom() method that takes a serialized file path rather than an in-memory configuration object.Because Registry doesn't expose a clean setter method, attempting to force-hydrate PHPUnit 12's configuration tracking is highly brittle.

Option 2: Use Webmozart Assertions (Recommended & Cleanest)Because PHPUnit 12 binds its basic assertion formatting heavily to its console runner configuration engine, using its assertions standalone requires fighting the framework internals.The industry-standard solution for alternative runners like Behat is switching the assertion namespace to webmozart/assert, which was written specifically to be completely decoupled.

Option 2 looks by far the best way forward. But there is no rush to do this, PHPunit 9 Assert is working fine with the Behat acceptance test code in PHP 8.3.

This discussion is useful to read: Behat/Behat#1617

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