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 ([[https://github.com/sebastianbergmann/phpunit/milestone/34|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 tryingT278010);
-[x] The TestListener interface will be removed in favour of hooks. We have two classes using it; one is easy to migrate ([[https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/566829/|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);[x] Migrate MediaWikiLoggerPHPUnitTestListener ([[https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/566829/|gerrit patch]])
- The methods that were hard-deprecated in PHPUnit 8 (assertInternalType, assertAttribute*, assertArraySubset, ...) will be removed;[x] Migrate MediaWikiPHPUnitTestListener ([[https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/673704/|gerrit patch]])
[] ResultPrinter will become an interface. We subclass the current ResultPrinter to augment logs (the "logs generated by test case" lines); That should extend DefaultResultPrinter (introduced in PHPUnit 9.0.0) instead.
[x] The methods that were hard-deprecated in PHPUnit 8 (assertInternalType, assertAttribute*, assertArraySubset, ...) will be removed; shouldn't be a problem, - It will **not** support PHP 7.2 -- which is (IMHO) the main reason to delay the upgrade itself.related PHPCS sniffs have been in place for many months
[] It will **not** support PHP 7.2. As such, See {we cannot upgrade until T261872} is done.
In general---
Optional things which might (or will) help with future upgrades, we should probably try to clean up our entry points,e.g. and reduce customization to the minimum (re subclassing ResultPrinter, having MediaWikiPHPUnitCommandPHPUnit 10:
- Possibly avoid a custom printer
- Removing MediaWikiPHPUnitCommand and our custom entry point (T90875)
- Removing our PHPUnit extensions: MediaWikiHooksPHPUnitExtension (blocked on T278011), SuiteEventsTrait and other things that mess with suitesMediaWikiLoggerPHPUnitExtension (used in conjunction with the ResultPrinter)