2010-05-08 16:41:18 -04:00
|
|
|
Running Tests
|
2010-10-22 19:27:41 +02:00
|
|
|
=============
|
2010-05-08 16:41:18 -04:00
|
|
|
|
|
|
|
Prerequisites
|
2010-10-22 19:27:41 +02:00
|
|
|
=============
|
2010-05-08 16:41:18 -04:00
|
|
|
|
|
|
|
PHPUnit
|
2010-10-22 19:27:41 +02:00
|
|
|
-------
|
2010-05-08 16:41:18 -04:00
|
|
|
|
2013-05-09 19:14:31 +02:00
|
|
|
phpBB unit tests use the PHPUnit framework (see http://www.phpunit.de for more
|
|
|
|
information). Version 3.5 or higher is required to run the tests. PHPUnit can
|
|
|
|
be installed via Composer together with other development dependencies as
|
|
|
|
follows.
|
|
|
|
|
|
|
|
$ cd phpBB
|
|
|
|
$ php ../composer.phar install --dev
|
|
|
|
$ cd ..
|
2010-05-08 16:41:18 -04:00
|
|
|
|
|
|
|
PHP extensions
|
2010-10-22 19:27:41 +02:00
|
|
|
--------------
|
2010-05-08 16:41:18 -04:00
|
|
|
|
|
|
|
Unit tests use several PHP extensions that board code does not use. Currently
|
|
|
|
the following PHP extensions must be installed and enabled to run unit tests:
|
|
|
|
|
2012-12-26 10:41:13 -05:00
|
|
|
- ctype (also a PHPUnit dependency)
|
|
|
|
- dom (PHPUnit dependency)
|
2012-12-25 07:15:58 -05:00
|
|
|
|
|
|
|
Some of the functionality in phpBB and/or the test suite uses additional
|
|
|
|
PHP extensions. If these extensions are not loaded, respective tests
|
|
|
|
will be skipped:
|
|
|
|
|
|
|
|
- apc (APC cache driver)
|
|
|
|
- bz2 (compress tests)
|
|
|
|
- interbase, pdo_firebird (Firebird database driver)
|
|
|
|
- mysql, pdo_mysql (MySQL database driver)
|
|
|
|
- mysqli, pdo_mysql (MySQLi database driver)
|
|
|
|
- pdo (any database tests)
|
|
|
|
- pgsql, pdo_pgsql (PostgreSQL database driver)
|
|
|
|
- simplexml (any database tests)
|
|
|
|
- sqlite, pdo_sqlite (SQLite database driver, requires SQLite 2.x support
|
|
|
|
in pdo_sqlite)
|
|
|
|
- zlib (compress tests)
|
2010-05-08 16:41:18 -04:00
|
|
|
|
2010-10-22 19:27:41 +02:00
|
|
|
Database Tests
|
|
|
|
--------------
|
2012-05-11 22:14:12 -04:00
|
|
|
|
2010-10-22 19:27:41 +02:00
|
|
|
By default all tests requiring a database connection will use sqlite. If you
|
|
|
|
do not have sqlite installed the tests will be skipped. If you wish to run the
|
|
|
|
tests on a different database you have to create a test_config.php file within
|
2012-05-11 22:10:19 -04:00
|
|
|
your tests directory following the same format as phpBB's config.php. An
|
|
|
|
example for mysqli can be found below. More information on configuration
|
|
|
|
options can be found on the wiki (see below).
|
2010-10-22 19:27:41 +02:00
|
|
|
|
|
|
|
<?php
|
|
|
|
$dbms = 'mysqli';
|
|
|
|
$dbhost = 'localhost';
|
|
|
|
$dbport = '';
|
|
|
|
$dbname = 'database';
|
|
|
|
$dbuser = 'user';
|
|
|
|
$dbpasswd = 'password';
|
|
|
|
|
2012-05-11 22:24:01 -04:00
|
|
|
It is possible to have multiple test_config.php files, for example if you
|
|
|
|
are testing on multiple databases. You can specify which test_config.php file
|
|
|
|
to use in the environment as follows:
|
|
|
|
|
|
|
|
$ PHPBB_TEST_CONFIG=tests/test_config.php phpunit
|
|
|
|
|
2012-04-12 20:10:20 -05:00
|
|
|
Alternatively you can specify parameters in the environment, so e.g. the
|
2012-12-26 10:41:13 -05:00
|
|
|
following will run PHPUnit with the same parameters as in the shown
|
2012-04-12 20:10:20 -05:00
|
|
|
test_config.php file:
|
2010-10-22 19:50:43 +02:00
|
|
|
|
|
|
|
$ PHPBB_TEST_DBMS='mysqli' PHPBB_TEST_DBHOST='localhost' \
|
|
|
|
PHPBB_TEST_DBNAME='database' PHPBB_TEST_DBUSER='user' \
|
2011-01-03 22:21:54 +01:00
|
|
|
PHPBB_TEST_DBPASSWD='password' phpunit
|
2010-10-22 19:27:41 +02:00
|
|
|
|
2012-02-28 06:18:24 -06:00
|
|
|
Special Database Cases
|
|
|
|
----------------------
|
|
|
|
In order to run tests on some of the databases that we support, it will be
|
2012-04-12 20:10:20 -05:00
|
|
|
necessary to provide a custom DSN string in test_config.php. This is only
|
|
|
|
needed for MSSQL 2000+ (PHP module), MSSQL via ODBC, and Firebird when
|
|
|
|
PDO_Firebird does not work on your system
|
|
|
|
(https://bugs.php.net/bug.php?id=61183). The variable must be named $custom_dsn.
|
2012-02-28 06:18:24 -06:00
|
|
|
|
|
|
|
Examples:
|
|
|
|
Firebird using http://www.firebirdsql.org/en/odbc-driver/
|
|
|
|
$custom_dsn = "Driver={Firebird/InterBase(r) driver};dbname=$dbhost:$dbname";
|
|
|
|
|
|
|
|
MSSQL
|
|
|
|
$custom_dsn = "Driver={SQL Server Native Client 10.0};Server=$dbhost;Database=$dbname";
|
|
|
|
|
2012-04-12 20:10:20 -05:00
|
|
|
The other fields in test_config.php should be filled out as you would normally
|
|
|
|
to connect to that database in phpBB.
|
2012-02-28 06:18:24 -06:00
|
|
|
|
2012-04-12 20:10:20 -05:00
|
|
|
Additionally, you will need to be running the DbUnit fork from
|
|
|
|
https://github.com/phpbb/dbunit/tree/phpbb.
|
2012-02-28 06:18:24 -06:00
|
|
|
|
2010-05-08 16:41:18 -04:00
|
|
|
Running
|
2010-10-22 19:27:41 +02:00
|
|
|
=======
|
2010-05-08 16:41:18 -04:00
|
|
|
|
2012-04-12 20:10:20 -05:00
|
|
|
Once the prerequisites are installed, run the tests from the project root
|
|
|
|
directory (above phpBB):
|
2010-05-08 16:41:18 -04:00
|
|
|
|
2013-05-09 18:58:31 +02:00
|
|
|
$ phpBB/vendor/bin/phpunit
|
2010-05-08 16:41:18 -04:00
|
|
|
|
2011-01-12 02:22:37 +01:00
|
|
|
Slow tests
|
|
|
|
--------------
|
2012-05-11 22:14:12 -04:00
|
|
|
|
2011-01-12 02:22:37 +01:00
|
|
|
Certain tests, such as the UTF-8 normalizer or the DNS tests tend to be slow.
|
|
|
|
Thus these tests are in the `slow` group, which is excluded by default. You can
|
2012-04-12 20:10:20 -05:00
|
|
|
enable slow tests by copying the phpunit.xml.all file to phpunit.xml. If you
|
|
|
|
only want the slow tests, run:
|
2011-01-12 02:22:37 +01:00
|
|
|
|
2013-05-09 18:58:31 +02:00
|
|
|
$ phpBB/vendor/bin/phpunit --group slow
|
2011-01-12 02:22:37 +01:00
|
|
|
|
2010-05-08 16:41:18 -04:00
|
|
|
More Information
|
2010-10-22 19:27:41 +02:00
|
|
|
================
|
2010-05-08 16:41:18 -04:00
|
|
|
|
|
|
|
Further information is available on phpbb wiki:
|
2012-05-11 22:14:40 -04:00
|
|
|
http://wiki.phpbb.com/Unit_Tests
|