Acceptance Criteria
- All of our repositories use PHPUnit 11
Implementation details
Before you can change the composer requirement from 10 to 11, you have to change two other things: Test annotations and coding style
PHPUnit 11 removes annotation support (@covers tags in docblocks). Before you upgrade to PHPUnit 11, you have to convert the PHPUnit annotations to attributes. You can use a pre-built Rector Fix for that:
- Add "rector/rector":"~1.0" as a composer dev dependency
- Add the rector.php config file to the project root (see below)
- run vendor/bin/rector process tests (to run it in docker, run docker compose run --no-deps app php vendor/bin/rector process tests
- Fix the coding style (that includes manually going through all test files and importing the classes in each CoversClass attribute)
- Commit the changes in the tests/ folder, dot not commit rector.php or the rector dev dependency!
// rector.php use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitSetList; return RectorConfig::configure() ->withImportNames( importShortClasses: false ) ->withSets( [ PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES ] );
We have a MediaWiki CodeSniff which ensures that each test must have a @covers annotation, which will lead to errors when we replace them with attributes. The sniff does not recognize attributes. The sniff is also unneccessary, because PHPUnit can check for missing coverage attributes. Before upgrading to PHPUnit 11, make sure that
- The coding style is at least at version 10.1 (The release 10.1 removed the @covers sniff)
- The PHPUnit configuration has the attribute requireCoverageMetadata="true"
Repo list
- https://github.com/wmde/fundraising-application - https://github.com/wmde/fundraising-application/pull/2975
- https://github.com/wmde/fundraising-donations - https://github.com/wmde/fundraising-donations/pull/248
- https://github.com/wmde/fundraising-memberships - https://github.com/wmde/fundraising-memberships/pull/182
- https://github.com/wmde/fundraising-address-change - https://github.com/wmde/fundraising-address-change/pull/54
- https://github.com/wmde/fundraising-subscriptions - https://github.com/wmde/fundraising-subscriptions/pull/71
- https://github.com/wmde/fundraising-payments - https://github.com/wmde/fundraising-payments/pull/164
- https://github.com/wmde/fun-validators - https://github.com/wmde/fun-validators/pull/140
- https://github.com/wmde/fundraising-content-provider/ - https://github.com/wmde/fundraising-content-provider/pull/32
- https://github.com/wmde/fundraising-backend - https://github.com/wmde/fundraising-backend/pull/1010
- https://github.com/wmde/banner-server - https://github.com/wmde/banner-server/pull/579
- https://github.com/wmde/Euro - https://github.com/wmde/Euro/pull/30
- https://github.com/wmde/Clock
- https://github.com/wmde/email-address - https://github.com/wmde/email-address/pull/8
- https://github.com/wmde/PsrLogTestDoubles - https://github.com/wmde/PsrLogTestDoubles/pull/17