UtilsTest: fix the test failure by jrfnl · Pull Request #5997 · wp-cli/wp-cli

@jrfnl

Tests on PHP 8.1 and higher (which are running PHPUnit 10+) are failing with the below message:
```
An error occurred inside PHPUnit.

Message:  Interface "WpOrg\Requests\Transport" not found
Location: /home/runner/work/wp-cli/wp-cli/tests/mock-requests-transport.php:6
```

This may be due to the test classes being loaded (to count the number of tests) before the test bootstrap is being run (which includes the autoloaders).

If that "guess" is correct, this patch should fix this.

@jrfnl

While these tests are not showing errors at this time, it is still best practice to include files in the test `set_up_before_class()` method, not when the file is being read.

This applies this change to all other test files which were using the anti-pattern.

@swissspidy

@swissspidy

swissspidy

@swissspidy

@jrfnl jrfnl deleted the feature/fix-utils-test branch

October 1, 2024 16:33