1====== DokuWiki Test Suite ====== 2 3This is the test suite to automatically test various parts of DokuWiki. 4 5===== Requirements ===== 6 7 * PHPUnit 3.6.10+ http://www.phpunit.de/ 8 * PHP 5.3+ http://www.php.net 9 10===== PHPUnit Installation ====== 11 12==== via PEAR installer ==== 13 14 pear config-set auto_discover 1 15 pear install pear.phpunit.de/PHPUnit 16 17==== via Composer ==== 18 19Include a composer.json file in your project, which can be as minimal as: 20 21<code> 22{ 23 "require-dev": { 24 "phpunit/phpunit": "3.7.*" 25 } 26} 27</code> 28 29==== via PHP archive (PHAR) ==== 30 31Download http://pear.phpunit.de/get/phpunit.phar and make it executable on your system. 32 33 34===== Running all tests ===== 35 36Just change to the ''_test'' directory and run phpunit: 37 38 cd _test/ 39 phpunit 40 41PHPUnit will fail on some systems with a //headers already sent// error. 42This is a known problem with PHPUnit, the error can be avoided by passing the 43'--stderr' flag to phpunit: 44 45 phpunit --stderr 46 47On windows you may have to enable OpenSSL support for https tests. 48Some of them point to httpclient_http.tests.php on the failure. 49To enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' to your ''windows\system32'' folder 50and add the following line to your php.ini in the extension section: 51<code ini> 52extension=php_openssl.dll 53</code> 54 55===== Running selected Tests ===== 56 57You can run a single test file by providing it as an argument to phpunit: 58 59 phpunit --stderr tests/inc/common_cleanText.test.php 60 61You can also use groups to exclude certain test from running. For example use 62the following command to avoid long running test or tests accessing the 63Internet. 64 65 phpunit --stderr --exclude-group slow,internet 66 67===== Create new Tests ===== 68 69To create a test for DokuWiki, create a *.test.php file within the tests/ 70folder. Please respect the folder structure and naming convention. Inside the 71file, implement a class, extending 'DokuWikiTest'. Every method, starting 72with 'test' will be called as a test (e.g. 'testIfThisIsValid'); 73 74 75===== TODO for the test framework ===== 76 77 * test cross platform compatibility: especially test windows 78 * update http://www.dokuwiki.org/devel:unittesting 79 * optional: add helper methods to TestRequest for easy form submission 80 * createForm(), ... 81 * check PHP Unit test_helpers https://github.com/sebastianbergmann/php-test-helpers 82 83 84===== Migration Protocol ===== 85 86The following tests were not migrated: 87 88 * inc/indexer_idx_indexlengths (fs dependencies) 89 * inc/mail_send (integration test) 90 * inc/parser/parser_formatting 91 * inc/parser/xhtml_htmlphp (runkit) 92 * inc/parser/xhtml_links 93 94