Page MenuHomePhabricator

Support PHPUnit 4.x and higher (phpunit.php fails with "Version.php not found")
Closed, ResolvedPublic

Description

Author: physik

Description:
I have set a up a new VM with latest versions of vagrant and virtualbox to reproduce an error originally reported by Etienne.
running vagrant up worked without issues and installed phpunit 4.0.17 from pear. (Which will be unsupported from Dec'14 on)
However, the phpunit.php file within mediawiki does not work. See error messsage below:

vagrant@mediawiki-vagrant:/vagrant/mediawiki/tests/phpunit$ ./phpunit.php --version
PHP Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in /vagrant/mediawiki/tests/phpunit/phpunit.php on line 108
PHP Stack trace:
PHP 1. {main}() /vagrant/mediawiki/tests/phpunit/phpunit.php:0

Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in /vagrant/mediawiki/tests/phpunit/phpunit.php on line 108

Call Stack:

0.0020     680640   1. {main}() /vagrant/mediawiki/tests/phpunit/phpunit.php:0

PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Runner/Version.php' (include_path='.:/usr/share/php:/usr/share/pear') in /vagrant/mediawiki/tests/phpunit/phpunit.php on line 108
PHP Stack trace:
PHP 1. {main}() /vagrant/mediawiki/tests/phpunit/phpunit.php:0

Fatal error: require_once(): Failed opening required 'PHPUnit/Runner/Version.php' (include_path='.:/usr/share/php:/usr/share/pear') in /vagrant/mediawiki/tests/phpunit/phpunit.php on line 108

Call Stack:

0.0020     680640   1. {main}() /vagrant/mediawiki/tests/phpunit/phpunit.php:0

vagrant@mediawiki-vagrant:/vagrant/mediawiki/tests/phpunit$ phpunit --version
PHPUnit 4.0.17 by Sebastian Bergmann.

You have installed PHPUnit via PEAR. This installation method is no longer
supported and http://pear.phpunit.de/ will be shut down no later than
December, 31 2014.

Please read http://phpunit.de/manual/current/en/installation.html and
learn how to use PHPUnit from a PHAR or install it via Composer.


Version: unspecified
Severity: major

Details

Reference
bz64597

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:15 AM
bzimport set Reference to bz64597.
bzimport added a subscriber: Unknown Object (MLST).

physik wrote:

Can anyone reproduce this problem?

Tgr added a comment.May 8 2014, 11:54 PM

Just ran into it. MediaWiki tries to require PHPUnit files directly, but the phpunit/phpunit PEAR channel now falls back to the PHAR method (install a single file, /usr/bin/phpunit, with all classes packed inside it).

After extracting manually, I get "Failed opening required 'PHPUnit/Autoload.php'", which suggests that fixing this will not be as simple as changing the installation method.

On a related note, the testing framework should be vendorized and included with the application, not left to the reuser to figure out which version to install and how. Now that MediaWiki is getting Composer support, this should be easy to do.

Tgr added a comment.May 8 2014, 11:58 PM

Autoloader.php was indeed removed from PHPUnit with 4.0. I assume it relies on Composer now to generate an autoloader on the fly.

Tgr added a comment.May 9 2014, 12:02 AM

As a temporary fix, you can downgrade to the last pre-4.x version:

pear uninstall phpunit/PHPUnit
pear install phpunit/PHPUnit-3.7.35

Change 132377 had a related patch set uploaded by Physikerwelt:
Fix PHPUnit version to 3.7.35

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

Change 132377 merged by jenkins-bot:
Fix PHPUnit version to 3.7.35

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

physik wrote:

It would be nice if someone could assign her/himself to work on this problem... the end of the year seems to be far now... but suddenly it will be very close;-)

Tgr added a comment.Jun 3 2014, 8:25 PM

Given https://gerrit.wikimedia.org/r/#/c/132788/ , can't we just define PHPUnit as a dev dependency and have mw-vagrant run composer install --dev when it checks out mediawiki/core?

Rephrased summary.

The problem is that MediaWiki is trying to include the PHPUnit source files (from a global php import_path) directly. This method is last supported by PHPUnit 3.7.

When using PHPUnit 4.x or later, this no longer works and users are unable to run the MediaWiki phpunit tests.

This is a duplicate of bug 58881 can't use phpunit.phar to invoke MediaWiki tests

There is a bunch of patches in Gerrit attached to that bug which adds support for loading the .phar.

  • This bug has been marked as a duplicate of bug 58881 ***