Page MenuHomePhabricator

Preparation for the PHPUnit 9 upgrade
Open, LowPublic


Yesterday, we've finally upgraded to PHPUnit 8 (T192167). However, PHPUnit 9 is scheduled for release on Feb 7th, which means that we can start thinking about it. IMHO, we shouldn't rush the upgrade (given that various repos are probably still incompatible with PHPUnit 8). However, I find it wise to start preparing now, instead of letting tech debt accumulate.

This is especially true because PHPUnit 9 will have several compat breaks (source). Most notably:

  • MockBuilder::setMethods will be hard-deprecated (it's already soft-deprecated in PHPUnit 8) in favour of more specific methods. As you may expect, setMethods is widely used, and it won't be easy to replace it with phpcs (although it's worth trying);
  • The TestListener interface will be removed in favour of hooks. We have two classes using it; one is easy to migrate (gerrit patch), the other one will be a little harder because it listens to Suite events;
  • ResultPrinter will become an interface. We subclass the current ResultPrinter to augment logs (the "logs generated by test case" lines);
  • The methods that were hard-deprecated in PHPUnit 8 (assertInternalType, assertAttribute*, assertArraySubset, ...) will be removed;
  • It will not support PHP 7.2 -- which is (IMHO) the main reason to delay the upgrade itself. See T261872: Drop PHP 7.2 support from MediaWiki master branch, once Wikimedia production is on 7.3

In general, we should probably try to clean up our entry points, and reduce customization to the minimum (re subclassing ResultPrinter, having MediaWikiPHPUnitCommand, SuiteEventsTrait and other things that mess with suites)

Event Timeline

Daimona created this task.Jan 24 2020, 1:27 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 24 2020, 1:27 PM

Change 566829 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] Use PHPUnit hooks for augmented logs

Daimona triaged this task as Low priority.Jan 25 2020, 10:30 AM

With pleasure! This task should stay at low priority; the most important actionable is creating new sniffs for deprecated methods as soon as we can, so we don't have to rush the LibUp upgrades later.

Change 583591 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Don’t use deprecated assertion function

Change 583591 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Don’t use deprecated assertion function

Change 585438 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/core@master] Replace deprecated PHPUnit method in test

Change 585438 merged by jenkins-bot:
[mediawiki/core@master] Replace deprecated PHPUnit method in test

Change 566829 merged by jenkins-bot:
[mediawiki/core@master] Use PHPUnit hooks for augmented logs