Difference between revisions 1397191 and 2031623 on mediawikiwiki{{Manual:PHP_unit_testing/navigation}} You must have PHPUnit 3.7.0 (or later) installed to run the unit tests. Most developers use the very latest PHPUnit version, so there is no guarantee an older one will actually pass the tests we wrote. {{notice| Depending on your distribution and configuration, you may have to run the following commands as root. }} == Install methods == Several methods are available to you. Note the [[#Known issues|known issue below]], the Debian/Ubuntu package is broken. The [http://phpunit.de/manual/current/en/installation.html recommended way to install PHPUnit] is by downloading a PHP Archive (PHAR file). With the resolution of [[bugzilla:58881|bug 58881]], this should work now. === MediaWiki PHPUnit installer === We provide a shell script for Unix-like operating systems (Ubuntu, Mac OS X, Linux...). The script will attempt to install PHPUnit using various methods and usually manage to get it installed. It will try [http://pear.php.net PEAR], falling back to the [[w:Advanced Packaging Tool|apt]] and [[w:Yellowdog Updater, Modified|yum]] package managers. The script is located in <tt>tests/phpunit</tt> and requires root access. Example installing PHPUnit under an Unix system: <source lang="bash"> $ cd tests/phpunit $ sudo ./install-phpunit.sh </source> This might be the easiest way to install PHPUnit. === Using PEAR === [https://github.com/sebastianbergmann/phpunit/wiki/End-of-Life-for-PEAR-Installation-Method Installing PHPUnit via PEAR is no longer supported .] PEAR is a package manager for PHP, the MediaWiki PHPUnit installer attempt to use it as a first method. You will obviously need to install pear first. <syntaxhighlight lang="bash"> sudo pear channel-discover pear.phpunit.de sudo pear channel-discover components.ez.no sudo pear channel-discover pear.symfony-project.com sudo pear channel-discover pear.symfony.com sudo pear update-channels sudo pear install --alldeps phpunit/phpunit-3.7.35 </syntaxhighlight> If you're upgrading instead of installing, change the last line to: <syntaxhighlight lang="bash"> $ sudo pear upgrade --alldeps phpunit/PHPUnit </syntaxhighlight> == Testing your installation == <source lang="bash"> $ which phpunit /some/path/to/bin/phpunit $ phpunit --version PHPUnit A.B.C by Sebastian Bergmann. $ </source> Where: ; /some/path/to : is the installation prefix which depends upon your distribution and the installation method used. Usually one of <tt>/usr<tt>, <tt>/usr/local/</tt> or <tt>/opt/local/</tt>. ; A.B.C: is the PHPUnit version If you have something similar to <tt>phpunit --version</tt> output above, you should be fine and can start [[Manual:PHP unit testing/Running the unit tests|running the unit tests]]. == Known issues == === Apt package for Ubuntu 11.10, 12.04 is broken === <kbd>sudo apt-get install phpunit</kbd> results in a broken installation missing "PHP/CodeCoverage/Filter.php" ([https://bugs.launchpad.net/ubuntu/+source/phpunit/+bug/770394 Ubuntu launchpad bug 770394]). Installation by hand using the exact commands in the [[#Using PEAR]] section works. You may have to update the installation of PEAR itself on your machine: <source lang="bash"> $ pear upgrade pear </source> When running into an error such as [http://pastebin.com/iP1rgc8Z this one], [http://stackoverflow.com/questions/1528717/phpunit-require-once-error this] should help you out. <ref>https://bugzilla.redhat.com/show_bug.cgi?id=758832</ref> === Class File_Iterator not found === This might happen when trying to run PHPUnit under Ubuntu 11.04. <source lang="bash"> $ phpunit --version PHP Fatal error: Class 'File_Iterator' not found in /usr/share/php/File/Iterator/Factory.php on line 105 </source> You will have to alter the PHPUnit source code shipped by Ubuntu: * Edit <tt>/usr/share/pear/File/Iterator/Factory.php</tt> * on line 44 add <tt>require_once 'File/Iterator.php';</tt>. (Or install using PEAR). If that doesn't work, or you're on '''Windows'''-family operating systems, follow the [http://www.phpunit.de/manual/current/en/installation.html '''installation instructions'''] in the PHPUnit manual. === <code>DiffHistoryBlobTest::testXdiffAdler32</code> test failing === :<tt>DiffHistoryBlobTest::testXdiffAdler32 with data set <nowiki>#0 ('', 'Empty string') String is not zero-terminated ()</nowiki></tt><br/>'''xdiff_string_diff()''' [tests/002.phpt], '''xdiff_string_patch()''' [tests/006.phpt] and '''xdiff_string_merge3()''' [tests/010.phpt] unit tests fail. This is [[:bugzilla:35110|bug 35110]] and [https://bugs.php.net/bug.php?id=61358 PHP#bug 61358]. This might happen when using version of [http://pecl.php.net/package/xdiff pecl-xdiff PHP extension] older than 1.5.2 with PHP 5.3.10+. To fix, please upgrade pecl-xdiff extension to [http://pecl.php.net/package-changelog.php?package=xdiff version 1.5.2 or newer]. The '''xdiff''' tool is not affected by this problem. == Installation troubleshooting == If you get a version error after installation, for example... PHPUnit 3.6.7 or later required, you have 3.5.15. ...this means that you probably have more than one version of PHPUnit installed on your machine. You may need to edit your include_path in your php.ini file to point to the location of the newer installation. You may also need to add this path to the PATH variable in your .profile. If you get the error... This version of PHPUnit requires PHP 5.6. ...you either need to upgrade PHP or downgrade PHPUnit. PHPUnit 4.8 is compatible with PHP 5.5 and earlier.⏎ ⏎ == Notes == <references /> All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://mediawiki.org/w/index.php?diff=prev&oldid=2031623.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|