Page MenuHomePhabricator

Upgrade PHPUnit from 4/6 to 8
Open, LowPublic

Description

Once we drop support for HHVM and < PHP 7.2, we can drop support for PHPUnit 6, and deprecate our forwards/backwards-compat layer for PHPUnit 4.

This is blocked on: T192166: Drop HHVM support from MediaWiki

Progress estimate: https://codesearch.wmflabs.org/search/?q=PHPUnit_%7Cthis-%3EgetMock%5C(%7C%40expectExcep%7C-%3EsetExpectedException%7CPHPUnit4And6&i=nope&files=&repos=

Details

Related Gerrit Patches:
mediawiki/core : masterUpgrade to PHPUnit 8
mediawiki/core : masterManual fix of the remaining assertInternalType & Co.
mediawiki/core : masterDeprecate and stop using assertType(OrValue)
mediawiki/tools/codesniffer : masterphpunit deprecations: Handle assertType() as well
mediawiki/core : masterAutofix 94 PHPUnit 8 compat issues
mediawiki/extensions/Wikibase : masterAutofix some PHPUnit 7 compat issues
mediawiki/extensions/Wikibase : masterPreparation for PHPUnit 8 migration
mediawiki/extensions/CentralNotice : wmf/1.35.0-wmf.10build: Bump mediawiki-codesniffer to 28.0.0 and make pass
mediawiki/extensions/CentralNotice : wmf_deploybuild: Bump mediawiki-codesniffer to 28.0.0 and make pass
mediawiki/extensions/CentralNotice : masterbuild: Bump mediawiki-codesniffer to 28.0.0 and make pass
mediawiki/core : masterFixes for PHPUnit 8 compatibility
mediawiki/core : masterRemove phpunit/php-invoker from require-dev
integration/quibble : masterphpunit: Drop --debug-tests command, killed off in PHPUnit 8
mediawiki/extensions/Wikibase : masterFixes for PHPUnit 7/8 compatibility
mediawiki/extensions/ActiveAbstract : masterFixes for PHPUnit 7 compat
mediawiki/extensions/Echo : masterRemove hack for PHPUnit's Stub interface
mediawiki/extensions/Echo : masterHack: back-compat for PHPUnit's Stub interface
mediawiki/core : masterphpunit: Drop "debug-tests" command, no-op, now unused in Quibble
mediawiki/core : masterUpgrade PHPUnit to version 7
mediawiki/core : masterphpunit: Remove 6And8Compat trait from base classes
mediawiki/extensions/FileImporter : masterSuppress PHPUnit 8 warnings
mediawiki/extensions/WikibaseMediaInfo : masterSuppress PHPUnit 8 warnings
mediawiki/core : masterphpunit: delete MediaWikiTestResult and TestRunner
mediawiki/extensions/CirrusSearch : masterFixes for PHPUnit 8 compatibility
mediawiki/core : masterAdd PHPUnit6And8Compat trait
mediawiki/tools/codesniffer : masterAdd a sniff for methods deprecated in PHPUnit 8
mediawiki/core : masterphpunit: Add typehints for PHPUnit 8
mediawiki/core : masterMore backwards compatible changes for PHPUnit
mediawiki/core : masterRemove PHPUnit4And6Compat from Test classes
mediawiki/core : master[DNM] Drop PHPUnit4And6Compat (in 1.36)
mediawiki/core : masterBackwards-compatible PHPUnit 8 preparations
mediawiki/extensions/Translate : masterFix function signature for PHPUnit 8 compatibility
mediawiki/extensions/CirrusSearch : masterPHPUnit 8 compatibility fixes
mediawiki/extensions/JsonConfig : masterPHPUnit 8 compatible declarations
mediawiki/tools/codesniffer : masterAlso require return type for setUpBeforeClass() and tearDownAfterClass()
mediawiki/core : mastertests: Add explicit return type void to setUp() and tearDown()
mediawiki/extensions/DonationInterface : masterPHPUnit 8 compatibility that doesn't break b/c
mediawiki/extensions/Wikibase : masterKill last usages of PHPUnit4And6Compat with a temporary compat trait
mediawiki/extensions/PasswordlessLogin : masterbuild: Bump mediawiki-codesniffer to 28.0.0
mediawiki/extensions/PagedTiffHandler : mastertests: Add explicit return type void to setUp() and tearDown()
mediawiki/extensions/WikibaseLexemeCirrusSearch : mastertests: Add explicit return type void to setUp() and tearDown()
mediawiki/extensions/TranslateSvg : masterDrop PHPUnit4 compat
mediawiki/extensions/OAuth : mastertests: Fix setUp() signatures
mediawiki/extensions/QuickSearchLookup : mastertests: Fix setUp()/tearDown() signatures
mediawiki/extensions/NumerAlpha : mastertests: Remove empty setUp()/tearDown()
mediawiki/extensions/WhosOnline : mastertests: Remove empty setUp()/tearDown()
mediawiki/extensions/WikibaseCirrusSearch : mastertests: Fix setUp() that crept into a trait
mediawiki/extensions/GlobalCssJs : mastertests: Fix signature of setUp() that have crept into a trait
mediawiki/extensions/SimpleSAMLphp : mastertests: Stop using getMock()
mediawiki/extensions/LDAPGroups : mastertests: Stop using getMock()
mediawiki/extensions/Wikisource : masterStop using getMock()
mediawiki/extensions/LDAPGroups : mastertests: getMock() is deprecated
mediawiki/extensions/Wikisource : mastertests: createMock() is deprecated
mediawiki/core : mastertests: getMock() is deprecated
mediawiki/skins/MinervaNeue : mastertests: Stop using getMock()
mediawiki/extensions/ArticleCreationWorkflow : mastertests: getMock() is deprecated
mediawiki/extensions/WikidataPageBanner : mastertests: getMock() is deprecated
mediawiki/extensions/MobileFrontend : mastertests: getMock() is deprecated
mediawiki/extensions/MassMessage : mastertests: getMock() is deprecated
mediawiki/extensions/EventLogging : mastertests: getMock() is deprecated
mediawiki/extensions/Linter : mastertests: getMock() is deprecated
mediawiki/extensions/ConfirmEdit : mastertests: getMock() is deprecated
mediawiki/extensions/Thanks : mastertests: getMock() is deprecated
mediawiki/extensions/ActiveAbstract : mastertests: getMock() is deprecated
mediawiki/extensions/FileImporter : mastertests: getMock() is deprecated
mediawiki/extensions/SemanticSifter : masterDrop PHPUnit4 compat
mediawiki/extensions/Flow : masterRemove PHPUnit 4 bc stuff
mediawiki/extensions/UserMerge : masterClean up PHPUnit 4 bc stuff
mediawiki/extensions/Thanks : masterClean up some PHPUnit 4 bc stuff
mediawiki/extensions/PropertySuggester : masterClean up PHPUnit 4 bc
mediawiki/extensions/ConfirmEdit : masterRemove PPHUnit 4 bc stuff
mediawiki/extensions/ArticlePlaceholder : masterRemove most PHPUnit4 bc stuff
mediawiki/core : mastertests: Nuke last usages of setExpectedException()
mediawiki/extensions/OAuth : masterUpgrade phpcs, remove PHPUnit 4 b/c
mediawiki/extensions/MobileFrontend : masterRemove PHPUnit 4 bc stuff
mediawiki/extensions/CirrusSearch : masterDon't use PHPUnit 4 class name
mediawiki/extensions/ParserFunctions : master@expectedException is deprecated
mediawiki/extensions/WikimediaBadges : masterFixes for PHPUnit 6 compatibility
mediawiki/extensions/PropertySuggester : mastertests: setExpectedException() is deprecated
mediawiki/extensions/ArticlePlaceholder : mastertests: setExpectedException() is deprecated
mediawiki/tools/codesniffer : masterAdd a sniff to ensure that setUp and tearDown have :void typehints
mediawiki/tools/phan : masterAdd a plugin to ensure that setUp and tearDown have :void typehints
mediawiki/extensions/MassMessage : masterPHPUnit 6 compatibility fixes
mediawiki/extensions/BounceHandler : mastertests: setExpectedException() is deprecated
mediawiki/extensions/EventLogging : mastertests: setExpectedException() is deprecated
mediawiki/extensions/DonationInterface : mastertests: setExpectedException() is deprecated
mediawiki/extensions/ContentTranslation : mastertests: setExpectedException() is deprecated
mediawiki/extensions/AbuseFilter : mastertests: setExpectedException() is deprecated
mediawiki/extensions/ExternalGuidance : mastertests: setExpectedException() is deprecated
mediawiki/extensions/EntitySchema : masterFixes for PHPUnit 6 compatibility
mediawiki/extensions/ArticlePlaceholder : masterUse PHPUnit 6 class name
mediawiki/extensions/Newsletter : masterUse PHPUnit 6 class names
mediawiki/extensions/WikibaseLexemeCirrusSearch : masterDrop PHPUnit 4 support
mediawiki/extensions/WikibaseLexemeCirrusSearch : masterUse PHPUnit 6 class name
mediawiki/extensions/Wikibase : masterUse PHPUnit 6 class names
mediawiki/extensions/WikibaseQualityConstraints : masterDrop support for PHPUnit 4
mediawiki/extensions/WikibaseQualityConstraints : masterUse PHPUnit 6 class name
mediawiki/extensions/WikibaseMediaInfo : masterUse PHPUnit 6 class name
mediawiki/extensions/WikibaseLexeme : masterUse PHPUnit 6 class names
mediawiki/extensions/PropertySuggester : masterUse PHPUnit 6 class names
mediawiki/extensions/WikimediaEvents : masterUse PHPUnit 6 class name
mediawiki/extensions/Echo : masterUse PHPUnit 6 class names
mediawiki/extensions/EventLogging : masterUse PHPUnit 6 class names
mediawiki/extensions/ReadingLists : masterUse PHPUnit 6 class name
mediawiki/extensions/MobileFrontend : masterUse PHPUnit 6 class name
mediawiki/extensions/CentralAuth : masterUse PHPUnit 6 class names
mediawiki/extensions/ActiveAbstract : masterUse PHPUnit class names
mediawiki/extensions/WikibaseLexeme : masterRemove PHPUnit4 compatibility
mediawiki/extensions/WikibaseCirrusSearch : masterDrop PHPUnit 4 support
mediawiki/extensions/WikibaseMediaInfo : masterKill the remaining usages of PHPUnit4And6Compat methods
mediawiki/core : masterKill the remaining usages of PHPUnit4And6Compat methods
mediawiki/core : masterUpdate tests to use PHPUnit 6 class names
mediawiki/extensions/Popups : masterFixes for PHPUnit 6
mediawiki/core : masterReplace getMock with createMock
mediawiki/extensions/PageViewInfo : masterFixes for PHPUnit 6
mediawiki/extensions/CommonsMetadata : masterFixes for PHPUnit 6
mediawiki/extensions/Cognate : masterUpdate tests for PHPUnit 6
mediawiki/extensions/DonationInterface : masterUse PHPUnit 6 class names
mediawiki/extensions/Scribunto : masterUpdate to use PHPUnit 6 class names
mediawiki/core : masterReplace setExpectedException with two args
mediawiki/core : masterReplace setExpectedException with single arg
mediawiki/extensions/Wikibase : masterDrop PHPUnit4And6Compat trait
mediawiki/core : masterCleanup of old PHPUnit usage, part 3
mediawiki/core : masterCleanup of old PHPUnit usage, part 2
mediawiki/core : masterBegin cleaning up PHPUnit 4 code from tests
mediawiki/core : masterPHPUnit4And6Compat: drop forward-compat functions
mediawiki/core : mastertests: Require PHPUnit 6, drop PHPUnit 4 as an option
mediawiki/extensions/CirrusSearch : masterRemove PHPUnit 4 support
mediawiki/extensions/FileImporter : masterRemove PHPUnit 4 compatibility
mediawiki/extensions/GeoData : masterRemove PHPUnit 4 compatibility
mediawiki/extensions/Kartographer : masterDrop PHPUnit 4 compatibility

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Change 546002 merged by jenkins-bot:
[mediawiki/extensions/CentralNotice@master] build: Bump mediawiki-codesniffer to 28.0.0 and make pass

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

Change 545993 merged by jenkins-bot:
[mediawiki/extensions/OAuth@master] tests: Fix setUp() signatures

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

Change 545995 merged by jenkins-bot:
[mediawiki/extensions/WhosOnline@master] tests: Remove empty setUp()/tearDown()

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

Change 545997 merged by jenkins-bot:
[mediawiki/extensions/NumerAlpha@master] tests: Remove empty setUp()/tearDown()

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

Change 545996 merged by jenkins-bot:
[mediawiki/extensions/QuickSearchLookup@master] tests: Fix setUp()/tearDown() signatures

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

Change 544225 merged by jenkins-bot:
[mediawiki/extensions/TranslateSvg@master] Drop PHPUnit4 compat

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

Change 546323 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/PasswordlessLogin@master] build: Bump mediawiki-codesniffer to 28.0.0

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

Change 546362 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/PagedTiffHandler@master] tests: Add explicit return type void to setUp() and tearDown()

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

Change 546363 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/Wikibase@master] tests: Add explicit return type void to setUp() and tearDown()

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

Change 546364 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/WikibaseLexemeCirrusSearch@master] tests: Add explicit return type void to setUp() and tearDown()

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

Change 546364 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexemeCirrusSearch@master] tests: Add explicit return type void to setUp() and tearDown()

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

Change 546362 merged by jenkins-bot:
[mediawiki/extensions/PagedTiffHandler@master] tests: Add explicit return type void to setUp() and tearDown()

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

Change 546323 merged by Jforrester:
[mediawiki/extensions/PasswordlessLogin@master] build: Bump mediawiki-codesniffer to 28.0.0

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

Change 546456 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] Drop the PHPUnit4And6Compat trait

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

Change 542754 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Kill last usages of PHPUnit4And6Compat with a temporary compat trait

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

Change 546749 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/DonationInterface@master] PHPUnit 8 compatibility that doesn't break b/c

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

Change 546749 abandoned by MaxSem:
PHPUnit 8 compatibility that doesn't break b/c

Reason:
As the matter of fact, this patch is not needed as this extension isn't even getting tested on master...

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

Change 544414 merged by jenkins-bot:
[mediawiki/core@master] tests: Add explicit return type void to setUp() and tearDown()

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

Change 547706 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/tools/codesniffer@master] Also require return type for setUpBeforeClass() and tearDownAfterClass()

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

Change 547706 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Also require return type for setUpBeforeClass() and tearDownAfterClass()

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

Change 547843 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[integration/quibble@master] phpunit: Drop --debug-tests command, killed off in PHPUnit 8

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

Change 547848 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/JsonConfig@master] PHPUnit 8 compatible declarations

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

Change 547850 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/CirrusSearch@master] PHPUnit 8 compatibility fixes

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

Change 547851 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/core@master] Backwards-compatible PHPUnit 8 preparations

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

Change 547848 merged by jenkins-bot:
[mediawiki/extensions/JsonConfig@master] PHPUnit 8 compatible declarations

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

Change 547850 merged by jenkins-bot:
[mediawiki/extensions/CirrusSearch@master] PHPUnit 8 compatibility fixes

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

Change 547892 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Translate@master] Fix function signature for PHPUnit 8 compatibility

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

Change 547892 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Fix function signature for PHPUnit 8 compatibility

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

Change 547851 merged by jenkins-bot:
[mediawiki/core@master] Backwards-compatible PHPUnit 8 preparations

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

Change 547958 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/tools/codesniffer@master] Add a sniff for methods deprecated in PHPUnit 8

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

Change 550012 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] Remove PHPUnit4And6Compat from Test classes

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

Change 550012 merged by jenkins-bot:
[mediawiki/core@master] Remove PHPUnit4And6Compat from Test classes

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

Change 550088 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/core@master] More backwards compatible changes for PHPUnit

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

Change 550088 merged by jenkins-bot:
[mediawiki/core@master] More backwards compatible changes for PHPUnit

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

Change 551335 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] phpunit: delete MediaWikiTestResult and TestRunner

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

Change 551336 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] phpunit: Add typehints for PHPUnit 8

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

Change 551535 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/Echo@master] Hack: back-compat for PHPUnit's Stub interface

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

Change 551335 merged by jenkins-bot:
[mediawiki/core@master] phpunit: delete MediaWikiTestResult and TestRunner

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

Change 551336 merged by jenkins-bot:
[mediawiki/core@master] phpunit: Add typehints for PHPUnit 8

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

Change 547958 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Add a sniff for methods deprecated in PHPUnit 8

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

Change 551535 merged by jenkins-bot:
[mediawiki/extensions/Echo@master] Hack: back-compat for PHPUnit's Stub interface

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

Change 551773 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/core@master] Add PHPUnit6And8Compat trait

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

Change 551773 merged by jenkins-bot:
[mediawiki/core@master] Add PHPUnit6And8Compat trait

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

Change 551885 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Wikibase@master] Preparation for PHPUnit 8 migration

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

Change 551887 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/FileImporter@master] Suppress PHPUnit 8 warnings

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

Change 551888 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/WikibaseMediaInfo@master] Suppress PHPUnit 8 warnings

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

Change 551891 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/CirrusSearch@master] Fixes for PHPUnit 8 compatibility

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

Daimona added a subscriber: MaxSem.Tue, Nov 19, 7:18 PM

I was thinking about how to progress the migration. Given the high number of "broken" tests, I'd suggest to:

  • Add forward-compat methods to PHPUnit6And8Compat. For instance:
function assertIsArray( ... ) {
   if( is_callable( [ $this, 'assertIsArray' ] ) {
     $this->assertIsArray( ... )
   } else {
     $this->assertInternalType( ... )
   }
}

Right now, I see that we're going with "suppress the rest", but I believe that the option above could save us some time.


I also see another way forward: upgrade to PHPUnit 7 as a temporary step. It already has assertIs* methods, and assertInternalType is not yet deprecated there. This means that we can start migrating to the new methods in extensions without using the trait. Again, LibUp will do most of the work here.


@MaxSem I've seen your patches around for suppressing stuff, so I wanted to ask you how would you feel about the proposals above.

Change 551887 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Suppress PHPUnit 8 warnings

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

Change 551891 merged by jenkins-bot:
[mediawiki/extensions/CirrusSearch@master] Fixes for PHPUnit 8 compatibility

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

Change 551888 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Suppress PHPUnit 8 warnings

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

I also see another way forward: upgrade to PHPUnit 7 as a temporary step.

Yeah, I searched for problematic methods and we have a ton of them that aren't in the gate pipeline but that we'd better not break. I'll try playing with 7.5 now.

Change 552166 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/core@master] WIP: upgrade PHPUnit to version 7

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

Change 552166 merged by jenkins-bot:
[mediawiki/core@master] Upgrade PHPUnit to version 7

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

Alright, as a next step I'd say we should go with https://gerrit.wikimedia.org/r/#/c/mediawiki/tools/codesniffer/+/551911/ and let LibUp do another batch of autofixes. Then hopefully we'll be ready for PHPUnit 8...

Change 552307 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] phpunit: Remove 6And8Compat trait from base classes

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

Change 552312 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] Upgrade to PHPUnit 8

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

Change 552307 merged by jenkins-bot:
[mediawiki/core@master] phpunit: Remove 6And8Compat trait from base classes

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

@MaxSem Another thing I've come across: assertArraySubset will be removed in PHPUnit 9 with no alternative method (https://github.com/sebastianbergmann/phpunit/issues/3494). I see several usages around. I was thinking whether we should:

  1. Just stop using it, although it's not always clear what the replacement should be (usually, a long list of assertArrayHasKey and assertEquals)
  2. Re-implement it in a trait in MW core
  3. Use https://github.com/rdohms/phpunit-arraysubset-asserts as suggested by Sebastian on the issue linked above.

I'd say either 1 or 3. If 3, we should update PHPCS because the new version will forbid usage of assertArraySubset.

Change 555545 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/core@master] phpunit: Drop "debug-tests" command, no-op, now unused in Quibble

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

I was thinking about how to progress the migration. Given the high number of "broken" tests, I'd suggest to:

  • Add forward-compat methods to PHPUnit6And8Compat. For instance:
function assertIsArray( ... ) {
   if( is_callable( [ $this, 'assertIsArray' ] ) {
     $this->assertIsArray( ... )
   } else {
     $this->assertInternalType( ... )
   }
}

Right now, I see that we're going with "suppress the rest", but I believe that the option above could save us some time.

I also see another way forward: upgrade to PHPUnit 7 as a temporary step. It already has assertIs* methods, and assertInternalType is not yet deprecated there. This means that we can start migrating to the new methods in extensions without using the trait. Again, LibUp will do most of the work here.

@MaxSem I've seen your patches around for suppressing stuff, so I wanted to ask you how would you feel about the proposals above.

Either work; I've a slight preference for bumping to 7 rather than add more dreck we need to then rapidly back out, but…

Either work; I've a slight preference for bumping to 7 rather than add more dreck we need to then rapidly back out, but…

Yeah, well, we're already on PHPUnit 7 as of r552166 :)

MW codesniffer 29.0.0 will help us migrate various deprecated methods; the only thing left to decide is what to do with assertArraySubset (T192167#5685401) before releasing that version and beginning the migration.

Change 552166 merged by jenkins-bot:
[mediawiki/core@master] Upgrade PHPUnit to version 7
https://gerrit.wikimedia.org/r/552166

The phpunit/php-invoker dependency added in this commit prevents me from execute composer update on Windows. Where does phpunit/php-invoker apply?

@RazeSoldier, what PHP version? What's the error Composer emits?

I use PHP 7.3, error msg:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phpunit/php-invoker 2.0.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - phpunit/php-invoker 2.0.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - Installation request for phpunit/php-invoker ^2.0 -> satisfiable by phpunit/php-invoker[2.0.0].
Reedy added a comment.Sun, Dec 8, 11:48 PM

There's no ext-pcntl for windows... But phpunit/php-invoker is only in suggests according to https://packagist.org/packages/phpunit/phpunit#7.5.13 so we don't actually have to explicitly list it

Change 555752 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@master] Remove phpunit/php-invoker from require-dev

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

Reedy added a comment.Mon, Dec 9, 12:14 AM

Change 555752 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@master] Remove phpunit/php-invoker from require-dev
https://gerrit.wikimedia.org/r/555752

Basically we should remove it by default. If it's "needed" for CI or similar, we should find some way to make CI install it etc

Change 555752 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@master] Remove phpunit/php-invoker from require-dev
https://gerrit.wikimedia.org/r/555752

Basically we should remove it by default. If it's "needed" for CI or similar, we should find some way to make CI install it etc

Ah, I just realized that I had already noticed this incompatibility. Basically, php-invoker is needed for the "enforceTimeLimit" option, and it's indeed incompatible with windows. Dunno what the proper solution would be.

Change 555912 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/Wikibase@master] Fixes for PHPUnit 7/8 compatibility

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

Change 555910 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/ActiveAbstract@master] Fixes for PHPUnit 7 compat

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

Change 555913 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/Echo@master] Revert "Hack: back-compat for PHPUnit's Stub interface"

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

Change 555910 merged by jenkins-bot:
[mediawiki/extensions/ActiveAbstract@master] Fixes for PHPUnit 7 compat

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

Change 555912 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Fixes for PHPUnit 7/8 compatibility

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

@MaxSem Another thing I've come across: assertArraySubset will be removed in PHPUnit 9 with no alternative method (https://github.com/sebastianbergmann/phpunit/issues/3494). I see several usages around. I was thinking whether we should:

  1. Just stop using it, although it's not always clear what the replacement should be (usually, a long list of assertArrayHasKey and assertEquals)
  2. Re-implement it in a trait in MW core
  3. Use https://github.com/rdohms/phpunit-arraysubset-asserts as suggested by Sebastian on the issue linked above.

I'd say either 1 or 3. If 3, we should update PHPCS because the new version will forbid usage of assertArraySubset.

For starters, since none of these options are fixable with phpcs, I propose to not block 29.0 on this discussion.

As of the core issue, #2 feels like a waste of time in the presence of #3. The caveat here is that this function was removed because it was too confusing - are we sure we wouldn't make ourselves a disservice by continuing to use it?

Reedy added a comment.Tue, Dec 10, 2:42 PM

Change 555752 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@master] Remove phpunit/php-invoker from require-dev
https://gerrit.wikimedia.org/r/555752

Basically we should remove it by default. If it's "needed" for CI or similar, we should find some way to make CI install it etc

Ah, I just realized that I had already noticed this incompatibility. Basically, php-invoker is needed for the "enforceTimeLimit" option, and it's indeed incompatible with windows. Dunno what the proper solution would be.

Like I say, we can get it injected by CI (like we do for some stuff)... That solves that problem. Unblocks it for Windows.. The question is then what we do for anyone running phans cans locally (who can use php-invoker)

For starters, since none of these options are fixable with phpcs, I propose to not block 29.0 on this discussion.

While that's correct, when I implemented the PHPUnit 8 sniff, I made it throw a warning if assertArraySubset. If we decide for 2 or 3, then it's fine. Otherwise, we have to remove that part. We can also just remove that part and re-add if necessary.

As of the core issue, #2 feels like a waste of time in the presence of #3. The caveat here is that this function was removed because it was too confusing - are we sure we wouldn't make ourselves a disservice by continuing to use it?

Indeed.

Like I say, we can get it injected by CI (like we do for some stuff)... That solves that problem. Unblocks it for Windows.. The question is then what we do for anyone running phans cans locally (who can use php-invoker)

That's certainly an option, although we have to see what happens if someone tries to run PHPUnit without php-invoker + ext-pcntl. Given that our phpunit.xml files both have "enforceTimeLimit=true", we should expect at least a warning.

Change 541082 merged by jenkins-bot:
[mediawiki/core@master] Fixes for PHPUnit 8 compatibility

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

Change 556490 had a related patch set uploaded (by Jforrester; owner: MaxSem):
[mediawiki/extensions/CentralNotice@wmf_deploy] build: Bump mediawiki-codesniffer to 28.0.0 and make pass

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

Change 556490 merged by Jforrester:
[mediawiki/extensions/CentralNotice@wmf_deploy] build: Bump mediawiki-codesniffer to 28.0.0 and make pass

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

Change 556496 had a related patch set uploaded (by Jforrester; owner: MaxSem):
[mediawiki/extensions/CentralNotice@wmf/1.35.0-wmf.10] build: Bump mediawiki-codesniffer to 28.0.0 and make pass

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

Change 556496 merged by Jforrester:
[mediawiki/extensions/CentralNotice@wmf/1.35.0-wmf.10] build: Bump mediawiki-codesniffer to 28.0.0 and make pass

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

Change 556666 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/Wikibase@master] Autofix some PHPUnit 7 compat issues

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

Change 556666 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Autofix some PHPUnit 7 compat issues

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

Change 557026 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] Autofix 94 PHPUnit 8 compat issues

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

Change 557051 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/tools/codesniffer@master] phpunit deprecations: Handle assertType() as well

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

Change 557080 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] Deprecate and stop using assertType(OrValue)

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

Change 557087 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] Manual fix of the remaining assertInternalType & Co.

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