Page MenuHomePhabricator

MediaWiki PHPUnit fails with PHP 7.2
Closed, InvalidPublic

Description

Seen at https://travis-ci.org/JeroenDeDauw/Maps/builds/310575460

Running tests/phpunit/phpunit.php with PHP 7.2 results in a bunch of warnings and a fatal error:

PHP Fatal error: Declaration of PHPUnit_Framework_Comparator_DOMDocument::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false) must be compatible with PHPUnit_Framework_Comparator_Object::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false, array &$processed = Array) in /home/travis/build/JeroenDeDauw/phase3/extensions/Maps/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/DOMDocument.php on line 114

Presumed cause: MediaWiki master uses PHPUnit 4 which has been unsupported since February 2017 and breaks with the latest stable release of PHP.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 3 2017, 1:15 PM
Reedy added a subscriber: Reedy.EditedDec 3 2017, 2:40 PM

So, this is "kinda" blocked on T172165: Require either PHP 7.0+ or HHVM in MW 1.31 (to be able to remove PHPUnit 4.8 completely)

See also T177132: Run MediaWiki tests with PHPUnit 6

That being said... Is there any reason we can't have version options in composer.json? (though, T177132 kinda looks like things might break?)

		"phpunit/phpunit": "4.8.36",

to become

		"phpunit/phpunit": "4.8.36 || 5.7.25 || 6.5.2",

Then for anyone running composer themselves (not using wikimedia's mediawiki-vendor), composer will select an appropriate version of phpunit to run for them?

Change 394851 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@master] Allow PHPUnit 5 and 6 versions optionally in require-dev

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

Then for anyone running composer themselves (not using wikimedia's mediawiki-vendor), composer will select an appropriate version of phpunit to run for them?

What would be the "appropriate" version in this case? (Which can be selected by composer in a generic way)? I think composer will select the most up-to-date version that matches the constraint. As you just wrote version numbers, 4.8.36 || 5.7.25 || 6.5.2 would be the same as 6.5.2.

It would probably be possible, if phpunit would have a bounded php requirement for 4.8.x, but currently it's just "greater than 5.3.3", and I'm not sure, if that would work, in this case :/

Reedy added a comment.EditedDec 24 2017, 2:17 AM

No it wouldn't be treated like that.

It'll use the "newest" version of phpunit available for that version of PHP that it's running under. If you're using oold PHP, it won't use PHPUnit 6.5.2 etc

https://getcomposer.org/doc/articles/versions.md

A double pipe (||) will be treated as a logical OR

Legoktm closed this task as Invalid.Feb 20 2018, 1:12 AM
Legoktm added a subscriber: Legoktm.

I'm not sure exactly how, but I think you somehow got mismatched versions of PHPUnit installed and that's why it failed. This has nothing to do with PHP 7.2 - while there are warnings, PHPUnit 4.8.36 doesn't cause that error (that said there are other errors). We are still going to upgrade to PHPUnit 6.x of course.