142dcf8b1SAndreas Gohr====== DokuWiki Test Suite ====== 2f8369d7dSTobias Sarnowski 342dcf8b1SAndreas GohrThis is the test suit to automatically test various parts of DokuWiki. 4f8369d7dSTobias Sarnowski 542dcf8b1SAndreas Gohr===== Requirements ===== 642dcf8b1SAndreas Gohr 742dcf8b1SAndreas Gohr * PHPUnit 3.6.10+ http://www.phpunit.de/ 842dcf8b1SAndreas Gohr * PHP 5.3+ http://www.php.net 942dcf8b1SAndreas Gohr 1042dcf8b1SAndreas Gohr===== PHPUnit Installation ====== 1142dcf8b1SAndreas Gohr 1242dcf8b1SAndreas Gohrvia PEAR: 1342dcf8b1SAndreas Gohr 1442dcf8b1SAndreas Gohr pear config-set auto_discover 1 1542dcf8b1SAndreas Gohr pear upgrade 1642dcf8b1SAndreas Gohr pear install pear.phpunit.de/PHPUnit 1742dcf8b1SAndreas Gohr 1842dcf8b1SAndreas Gohron Windows: 1942dcf8b1SAndreas Gohr 2042dcf8b1SAndreas Gohr FIXME 21f8369d7dSTobias Sarnowski 22f8369d7dSTobias Sarnowski 2342dcf8b1SAndreas Gohr===== Running all Tests ===== 24f8369d7dSTobias Sarnowski 2542dcf8b1SAndreas GohrJust change to the ''_test'' directory and run phpunit: 26f8369d7dSTobias Sarnowski 2742dcf8b1SAndreas Gohr cd _testing/ 2842dcf8b1SAndreas Gohr phpunit 29f8369d7dSTobias Sarnowski 3042dcf8b1SAndreas GohrPHPUnit will fail on some systems with a //headers already sent// error. 3142dcf8b1SAndreas GohrThis is a known problem with PHPUnit, the error can be avoided by passing the 3242dcf8b1SAndreas Gohr'--stderr' flag to phpunit: 33f8369d7dSTobias Sarnowski 3442dcf8b1SAndreas Gohr phpunit --stderr 35f8369d7dSTobias Sarnowski 36*f77b4d4fSDominik EckelmannOn windows you may have to enable OpenSSL support for https tests. 37*f77b4d4fSDominik EckelmannSome of them point to httpclient_http.tests.php on the failure. 38*f77b4d4fSDominik EckelmannTo enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' to your ''windows\system32'' folder 39*f77b4d4fSDominik Eckelmannand add the following line to your php.ini in the extension section: 40*f77b4d4fSDominik Eckelmann<code ini> 41*f77b4d4fSDominik Eckelmannextension=php_openssl.dll 42*f77b4d4fSDominik Eckelmann</code> 43*f77b4d4fSDominik Eckelmann 4442dcf8b1SAndreas Gohr===== Running selected Tests ===== 45f8369d7dSTobias Sarnowski 4642dcf8b1SAndreas GohrYou can run a single test file by providing it as an argument to phpunit: 47f8369d7dSTobias Sarnowski 4842dcf8b1SAndreas Gohr phpunit --stderr tests/inc/common_cleanText.test.php 49f8369d7dSTobias Sarnowski 50f7161c34SAndreas GohrYou can also use groups to exclude certain test from running. For example use 51f7161c34SAndreas Gohrthe following command to avoid long running test or tests accessing the 52f7161c34SAndreas GohrInternet. 53f7161c34SAndreas Gohr 54f7161c34SAndreas Gohr phpunit --stderr --exclude-group slow,internet 55f8369d7dSTobias Sarnowski 5642dcf8b1SAndreas Gohr===== Create new Tests ===== 57f8369d7dSTobias Sarnowski 58f8369d7dSTobias SarnowskiTo create a test for DokuWiki, create a *.test.php file within the tests/ 59f8369d7dSTobias Sarnowskifolder. Please respect the folder structure and naming convention. Inside the 60f8369d7dSTobias Sarnowskifile, implement a class, extending 'DokuWikiTest'. Every method, starting 61f8369d7dSTobias Sarnowskiwith 'test' will be called as a test (e.g. 'testIfThisIsValid'); 62f8369d7dSTobias Sarnowski 63f8369d7dSTobias Sarnowski 6442dcf8b1SAndreas Gohr===== TODO for the test framework ===== 65f8369d7dSTobias Sarnowski 66f8369d7dSTobias Sarnowski * test cross platform compatibility: especially test windows 67f8369d7dSTobias Sarnowski * update http://www.dokuwiki.org/devel:unittesting 68f8369d7dSTobias Sarnowski * optional: add helper methods to TestRequest for easy form submission 69f8369d7dSTobias Sarnowski * createForm(), ... 7042dcf8b1SAndreas Gohr * check PHP Unit test_helpers https://github.com/sebastianbergmann/php-test-helpers 71f8369d7dSTobias Sarnowski 72f8369d7dSTobias Sarnowski 7342dcf8b1SAndreas Gohr===== Migration Protocol ===== 74f8369d7dSTobias Sarnowski 75f8369d7dSTobias SarnowskiThe following tests were not migrated: 76f8369d7dSTobias Sarnowski 77f8369d7dSTobias Sarnowski * inc/indexer_idx_indexlengths (fs dependencies) 78f8369d7dSTobias Sarnowski * inc/mail_send (integration test) 79f8369d7dSTobias Sarnowski * inc/parser/parser_formatting 80f8369d7dSTobias Sarnowski * inc/parser/xhtml_htmlphp (runkit) 81f8369d7dSTobias Sarnowski * inc/parser/xhtml_links 82f8369d7dSTobias Sarnowski 83