[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Page MenuHomePhabricator

Migrate MediaWiki core (and thus extensions and skins) to PHPUnit 9
Closed, ResolvedPublic

Description

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 (T278010);
  • Assert::assertRegExp is hard-deprecated in favour of assertMatchesRegularExpression(), which however was also introduced in PHPUnit 9
  • The TestListener interface will be removed in favour of hooks.
  • 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. The change which made ResultPrinter an interface was later reverted, so I don't think we still need to do this (as long as it's still working as expected).
  • The methods that were hard-deprecated in PHPUnit 8 (assertInternalType, assertAttribute*, assertArraySubset, ...) will be removed; shouldn't be a problem, related PHPCS sniffs have been in place for many months
  • It will not support PHP 7.2. As such, we cannot upgrade until T261872 is done.
  • Additional minor fixes:
    • Several traits declare createMock as abstract but the signature will change in PHPUnit 9 (string typehint added); the traits should probably not declare the method at all, and use @method or an if+throw. List: MockTitleTrait, MockAuthorityTrait, MockServiceDependenciesTrait (also fail(), but the signature is the same), HandlerTestTrait
    • MockHttpTrait redeclares getMockBuilder(). Same as above.
    • Our XML schema is outdated (--migrate-configuration to update it)
    • @coversNothing should be added to MediaWikiCoversValidator::testValidCovers
    • ApiTestCase uses $this->contains() which should become $this->containsIdentical

Optional things which might (or will) help with future upgrades, e.g. PHPUnit 10:

  • Possibly avoid a custom printer
  • Removing MediaWikiPHPUnitCommand and our custom entry point (T90875)
  • Removing our PHPUnit extensions: MediaWikiHooksPHPUnitExtension (blocked on T278011), MediaWikiLoggerPHPUnitExtension (used in conjunction with the ResultPrinter)

Details

SubjectRepoBranchLines +/-
mediawiki/coreREL1_39+60 -62
mediawiki/extensions/CookieWarningmaster+2 -2
mediawiki/coremaster+60 -95
mediawiki/extensions/WikibaseMediaInfomaster+17 -13
mediawiki/coremaster+75 -73
mediawiki/extensions/Wikibasemaster+42 -49
mediawiki/extensions/AbuseFiltermaster+2 -2
mediawiki/extensions/ConfirmEditmaster+1 -1
mediawiki/extensions/Flowmaster+1 -1
mediawiki/extensions/GrowthExperimentsmaster+7 -4
mediawiki/extensions/Wikibasemaster+75 -8
mediawiki/extensions/Wikibasemaster+122 -76
mediawiki/extensions/WikibaseCirrusSearchmaster+8 -2
mediawiki/coremaster+18 -0
mediawiki/extensions/ConfirmEditmaster+5 -5
mediawiki/extensions/BetaFeaturesmaster+3 -3
mediawiki/extensions/EventLoggingmaster+3 -3
mediawiki/coremaster+15 -0
mediawiki/extensions/Translatemaster+45 -8
mediawiki/extensions/FileImportermaster+6 -6
mediawiki/coremaster+26 -5
mediawiki/coremaster+248 -269
mediawiki/coremaster+2 -89
mediawiki/coremaster+22 -140
mediawiki/coremaster+0 -60
mediawiki/coremaster+133 -114
mediawiki/coremaster+1 -1
mediawiki/extensions/WikibaseQualityConstraintsmaster+2 -2
Show related patches Customize query in gerrit

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Daimona raised the priority of this task from Low to Medium.Mar 20 2021, 2:54 PM

There are lots of things to do, so I think this shouldn't be low priority, even if the upgrade itself is low priority.

Change 673705 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] Deprecate PHPUnit hooks

https://gerrit.wikimedia.org/r/673705

Change 673704 merged by jenkins-bot:
[mediawiki/core@master] phpunit: Remove MediaWikiPHPUnitTestListener

https://gerrit.wikimedia.org/r/673704

Change 674285 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] phpunit: Don't redefine methods in traits

https://gerrit.wikimedia.org/r/674285

We can allow 8.5|9.5 so that a repo can simultaneously work on PHP 7.2 and PHP 8.0; that's what I've been doing for various libraries as I'm going around. That was this work isn't blocked by dropping 7.2 support.

Change 674285 merged by jenkins-bot:
[mediawiki/core@master] phpunit: Don't redefine methods in traits

https://gerrit.wikimedia.org/r/674285

We can allow 8.5|9.5 so that a repo can simultaneously work on PHP 7.2 and PHP 8.0; that's what I've been doing for various libraries as I'm going around. That was this work isn't blocked by dropping 7.2 support.

Yes, this is indeed a good idea. The only caveat is that we're going to need a couple of BC hacks for renamed classes, but should be easily doable overall. Tentatively sending a patch now (although T278010 should still be resolved first).

Change 674851 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):
[mediawiki/core@master] [WIP] Allow PHPUnit 9

https://gerrit.wikimedia.org/r/674851

Change 700085 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/tools/cookiecutter-library@master] Update PHPUnit dist file schema

https://gerrit.wikimedia.org/r/700085

Change 673705 merged by jenkins-bot:

[mediawiki/core@master] Remove PHPUnit hooks

https://gerrit.wikimedia.org/r/673705

Daimona updated the task description. (Show Details)

Change 839695 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] phpunit: Avoid deprecated at() matcher

https://gerrit.wikimedia.org/r/839695

Change 839695 merged by jenkins-bot:

[mediawiki/core@master] phpunit: Avoid deprecated at() matcher

https://gerrit.wikimedia.org/r/839695

Next up, from https://integration.wikimedia.org/ci/job/wmf-quibble-core-vendor-mysql-php74-docker/682/consoleFull: we have over 6500 test cases triggering a warning because the test does not have @covers annotations. We also have a phpcs rule for it, MediaWiki.Commenting.MissingCovers.MissingCovers, but obviously it's disabled in a few places... We should really re-enable the sniff everywhere it's disabled, and adjust tests as needed.

If a test doesn't cover anything, then it should be annotated with @coversNothing.

Change 839753 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] Add @coversNothing to all structure tests

https://gerrit.wikimedia.org/r/839753

Change 839759 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/Translate@master] Add @covers tags to all tests

https://gerrit.wikimedia.org/r/839759

Change 839753 merged by jenkins-bot:

[mediawiki/core@master] Add @coversNothing to all structure tests

https://gerrit.wikimedia.org/r/839753

Change 840110 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/Wikibase@master] Add @covers tags to all tests

https://gerrit.wikimedia.org/r/840110

Change 840111 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/FileImporter@master] Use assertStringContainsString instead of assertContains

https://gerrit.wikimedia.org/r/840111

Change 840114 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/BetaFeatures@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840114

Change 840115 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/ConfirmEdit@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840115

Change 840116 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/EventLogging@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840116

Change 840118 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/Wikibase@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840118

Change 840111 merged by jenkins-bot:

[mediawiki/extensions/FileImporter@master] Use assertStringContainsString instead of assertContains

https://gerrit.wikimedia.org/r/840111

Change 840122 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] tests: Add temporary forward-compat method for assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840122

Change 839759 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Add @covers tags to all tests

https://gerrit.wikimedia.org/r/839759

Change 840122 merged by jenkins-bot:

[mediawiki/core@master] tests: Add temporary forward-compat method for assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840122

Change 840116 merged by jenkins-bot:

[mediawiki/extensions/EventLogging@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840116

Change 840114 merged by jenkins-bot:

[mediawiki/extensions/BetaFeatures@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840114

Change 840115 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840115

Change 840146 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] tests: Add forward-compat assertDoesNotMatchRegularExpression too

https://gerrit.wikimedia.org/r/840146

Change 840155 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/WikibaseCirrusSearch@master] tests: Add workaround for PHPUnit 9 migration

https://gerrit.wikimedia.org/r/840155

Change 840156 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/ConfirmEdit@master] Replace assertNotRegExp -> assertDoesNotMatchRegularExpression

https://gerrit.wikimedia.org/r/840156

Change 840146 merged by jenkins-bot:

[mediawiki/core@master] tests: Add forward-compat assertDoesNotMatchRegularExpression too

https://gerrit.wikimedia.org/r/840146

Change 840155 merged by jenkins-bot:

[mediawiki/extensions/WikibaseCirrusSearch@master] tests: Add workaround for PHPUnit 9 migration

https://gerrit.wikimedia.org/r/840155

Change 840118 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840118

Change 840110 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Add @covers tags to all tests

https://gerrit.wikimedia.org/r/840110

Change 840192 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/WikibaseMediaInfo@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840192

Change 840193 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/Wikibase@master] More fixes for PHPUnit 9 compatibility

https://gerrit.wikimedia.org/r/840193

Change 840196 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840196

Change 840197 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/AbuseFilter@master] tests: Replace assertNotRegExp with assertDoesNotMatchRegularExpression

https://gerrit.wikimedia.org/r/840197

Change 840198 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/GrowthExperiments@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840198

Change 840200 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/Flow@master] Fix for PHPUnit 9 compatibility

https://gerrit.wikimedia.org/r/840200

Change 840198 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840198

Change 840200 merged by jenkins-bot:

[mediawiki/extensions/Flow@master] Fix for PHPUnit 9 compatibility

https://gerrit.wikimedia.org/r/840200

Change 840197 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] tests: Replace assertNotRegExp with assertDoesNotMatchRegularExpression

https://gerrit.wikimedia.org/r/840197

Change 840156 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@master] Replace assertNotRegExp -> assertDoesNotMatchRegularExpression

https://gerrit.wikimedia.org/r/840156

Change 840193 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] More fixes for PHPUnit 9 compatibility

https://gerrit.wikimedia.org/r/840193

Change 840196 merged by jenkins-bot:

[mediawiki/core@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840196

Jdforrester-WMF renamed this task from Preparation for the PHPUnit 9 upgrade to Migrate MediaWiki core (and thus extensions and skins) to PHPUnit 9.Oct 7 2022, 7:20 PM

Change 840192 merged by jenkins-bot:

[mediawiki/extensions/WikibaseMediaInfo@master] tests: Replace assertRegExp with assertMatchesRegularExpression

https://gerrit.wikimedia.org/r/840192

Change 674851 merged by jenkins-bot:

[mediawiki/core@master] tests: Upgrade PHPUnit from 8.5+ to 9.5+

https://gerrit.wikimedia.org/r/674851

Daimona claimed this task.

This is done. The migration of other repos is tracked at T320245. Note that PHPUnit could possibly fail on master for many extensions (those whose tests aren't run for MW core patches). However, those failures should usually be easy to resolve, like replacing a deprecated method.

This is done. The migration of other repos is tracked at T320245. Note that PHPUnit could possibly fail on master for many extensions (those whose tests aren't run for MW core patches). However, those failures should usually be easy to resolve, like replacing a deprecated method.

  • assertNotIsReadable => assertIsNotReadable
  • assertNotIsWritable => assertIsNotWritable
  • assertDirectoryNotExists => assertDirectoryDoesNotExist
  • assertDirectoryNotIsReadable => assertDirectoryIsNotReadable
  • assertDirectoryNotIsWritable => assertDirectoryIsNotWritable
  • assertFileNotExists => assertFileDoesNotExist
  • assertFileNotIsReadable => assertFileIsNotReadable
  • assertFileNotIsWritable => assertFileIsNotWritable
  • assertRegExp => assertMatchesRegularExpression
  • assertNotRegExp => assertDoesNotMatchRegularExpression

https://codesearch.wmcloud.org/things/?q=%5Cb(assertNotIsReadable%7CassertNotIsWritable%7CassertDirectoryNotExists%7CassertDirectoryNotIsReadable%7CassertDirectoryNotIsWritable%7CassertFileNotExists%7CassertFileNotIsReadable%7CassertFileNotIsWritable%7CassertRegExp%7CassertNotRegExp)%5Cb&i=nope&files=&excludeFiles=&repos=

Change 841150 had a related patch set uploaded (by Universal Omega; author: Universal Omega):

[mediawiki/extensions/CookieWarning@master] tests: replace deprecated phpunit methods

https://gerrit.wikimedia.org/r/841150

Change 841150 merged by jenkins-bot:

[mediawiki/extensions/CookieWarning@master] tests: replace deprecated phpunit methods

https://gerrit.wikimedia.org/r/841150

Change 921152 had a related patch set uploaded (by Jforrester; author: Daimona Eaytoy):

[mediawiki/core@REL1_39] tests: Upgrade PHPUnit from 8.5+ to 9.5+

https://gerrit.wikimedia.org/r/921152

Change 921152 abandoned by Jforrester:

[mediawiki/core@REL1_39] tests: Upgrade PHPUnit from 8.5+ to 9.5.28

Reason:

https://gerrit.wikimedia.org/r/921152