phpBB

Development Wiki

Running Unit Tests

From phpBB Development Wiki

Revision as of 10:05, 23 February 2012 by Noxwizard (Talk | contribs)

This is a job for your command-line/shell.

Install PHP extensions

Unit tests use several PHP extensions that phpBB itself does not use. These need to be installed and enabled for unit tests to work.

Unit tests themselves need:

  • ctype
  • simplexml

For database tests you need to have pdo and pdo drivers for each of the databases you want to test with (e.g. pdo_pgsql for postgres).

phpunit needs:

  • ctype
  • dom

Installing phpunit

You need to install PHPUnit to your server: http://www.phpunit.de/ In order to install PHPUnit correctly, you need to run the following commands:

pear channel-update pear.php.net
pear install PEAR-1.9.1
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install --alldeps phpunit/PHPUnit
pear install phpunit/DbUnit

Depending on what versions of phpunit and pear you have installed or had installed earlier, phpunit may silently break itself. If you get errors about missing files when running tests, uninstall phpunit and pear completely and then reinstall the latest versions of pear and phpunit.

Run Tests

You need to switch into the root directory of the git-repo. And then simply run

Linux:
phpunit
Windows:
YOUR_DIRECTORY_WHERE_THE_FILE_IS/phpunit.bat

(Exp. C:/xampp/php/phpunit.bat )

Afterwards you should see something like:

PHPUnit 3.4.11 by Sebastian Bergmann.

............................................................  60 / 688
............................................................ 120 / 688
IIIIIIIIIII................................................. 180 / 688
............................................................ 240 / 688
............................................................ 300 / 688
............................................................ 360 / 688
............................................................ 420 / 688
............................................................ 480 / 688
............................................................ 540 / 688
............................................................ 600 / 688
............................................................ 660 / 688
............................

Time: 5 seconds, Memory: 13.00Mb

OK, but incomplete or skipped tests!
Tests: 688, Assertions: 878, Incomplete: 11.

If there are no errors, your test was successful. Otherwise either a test was wrong, or the functionality itself is wrong. Then you should go and fix it.