- install PEAR package manager - see PEAR Manual
- install PHPUnit package - see PHPUnit installation documentation
- edit main config.php - add
$CFG->phpunit_prefix
and$CFG->phpunit_dataroot
- see config-dist.php - execute
admin/tool/phpunit/cli/init.sh
to initialise the test environemnt, repeat it after every upgrade or installation of plugins
- execute
phpunit
from dirroot directory - you can also execute a single test
phpunit lib/tests/phpunit_test.php
- or all tests in one directory
phpunit --configuration phpunit.xml lib/tests/*_test.php
- it is possible to create custom configuration files in xml format and use
phpunit -c myconfig.xml
- create
tests
directory in your plugin if does not already exist - add
*_test.php
files with custom class that extendsbasic_testcase
oradvanced_testcase
- execute your new test, for example
phpunit local/mytest/tests/mytest_test.php
- create new test file in
xxx/tests/yyy_test.php
- copy contents of the old test file
- replace
extends UnitTestCase
withextends basic_testcase
- fix setUp(), tearDown(), asserts, etc.