server icon indicating copy to clipboard operation
server copied to clipboard

test: Fix PHPUnit 11 use in Behat

Open danxuliu opened this issue 1 month ago • 0 comments

Follow up to #55870

Starting with PHPUnit 11.3, some complex outputs of certain asserts (like assertStringContainsString) require the output of PHPUnit to be explicitly setup. Otherwise when the assert fails a type error is thrown (although it does not seem to affect asserts with simpler outputs, like assertEquals).

Note that PHPUnit asserts have never been intended to be used as standalone methods, even if it worked and it was recommended by Behat. In the future it might be needed to move to a different library, but for now this adjustment seems to be enough.

How to test

  • Modify any integration test with the "the command output contains the text XXX" so the check fails
  • Run the integration test

Result with this pull request

The output shows the actual and expected texts

Result without this pull request

A type error is thrown: Type error: PHPUnit\TextUI\Configuration\Registry::get(): Return value must be of type PHPUnit\TextUI\Configuration\Configuration, null returned (Behat\Testwork\Call\Exception\FatalThrowableError)

danxuliu avatar Dec 08 '25 15:12 danxuliu