142dcf8b1SAndreas Gohr====== DokuWiki Test Suite ====== 2f8369d7dSTobias Sarnowski 3b25974c4SGuy BrandThis is the test suite 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 12*7a7b77efSAndreas GohrYou can install phpunit through your distribution's package manager or simply 13*7a7b77efSAndreas Gohrdownload the newest phar file into the _test directory: 1442dcf8b1SAndreas Gohr 15*7a7b77efSAndreas Gohr cd _test/ 16*7a7b77efSAndreas Gohr wget https://phar.phpunit.de/phpunit.phar 17f8369d7dSTobias Sarnowski 18f8369d7dSTobias Sarnowski 19b25974c4SGuy Brand===== Running all tests ===== 20f8369d7dSTobias Sarnowski 21*7a7b77efSAndreas GohrJust change to the ''_test'' directory and run phpunit (depending on your install 22*7a7b77efSAndreas Gohrmethod): 23f8369d7dSTobias Sarnowski 24b25974c4SGuy Brand cd _test/ 2542dcf8b1SAndreas Gohr phpunit 26f8369d7dSTobias Sarnowski 27*7a7b77efSAndreas Gohror 28*7a7b77efSAndreas Gohr 29*7a7b77efSAndreas Gohr cd _test/ 30*7a7b77efSAndreas Gohr php phpunit.phar 31*7a7b77efSAndreas Gohr 32*7a7b77efSAndreas Gohr===== Troubleshooting ===== 33*7a7b77efSAndreas Gohr 3442dcf8b1SAndreas GohrPHPUnit will fail on some systems with a //headers already sent// error. 3542dcf8b1SAndreas GohrThis is a known problem with PHPUnit, the error can be avoided by passing the 3642dcf8b1SAndreas Gohr'--stderr' flag to phpunit: 37f8369d7dSTobias Sarnowski 3842dcf8b1SAndreas Gohr phpunit --stderr 39f8369d7dSTobias Sarnowski 40f77b4d4fSDominik EckelmannOn windows you may have to enable OpenSSL support for https tests. 41f77b4d4fSDominik EckelmannSome of them point to httpclient_http.tests.php on the failure. 42*7a7b77efSAndreas GohrTo enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' 43*7a7b77efSAndreas Gohrto your ''windows\system32'' folder and add the following line to your php.ini 44*7a7b77efSAndreas Gohrin the extension section: 45*7a7b77efSAndreas Gohr 46f77b4d4fSDominik Eckelmann<code ini> 47f77b4d4fSDominik Eckelmannextension=php_openssl.dll 48f77b4d4fSDominik Eckelmann</code> 49f77b4d4fSDominik Eckelmann 5042dcf8b1SAndreas Gohr===== Running selected Tests ===== 51f8369d7dSTobias Sarnowski 5242dcf8b1SAndreas GohrYou can run a single test file by providing it as an argument to phpunit: 53f8369d7dSTobias Sarnowski 54*7a7b77efSAndreas Gohr phpunit tests/inc/common_cleanText.test.php 55f8369d7dSTobias Sarnowski 56f7161c34SAndreas GohrYou can also use groups to exclude certain test from running. For example use 57f7161c34SAndreas Gohrthe following command to avoid long running test or tests accessing the 58f7161c34SAndreas GohrInternet. 59f7161c34SAndreas Gohr 60*7a7b77efSAndreas Gohr phpunit --exclude-group slow,internet 61f8369d7dSTobias Sarnowski 6242dcf8b1SAndreas Gohr===== Create new Tests ===== 63f8369d7dSTobias Sarnowski 64f8369d7dSTobias SarnowskiTo create a test for DokuWiki, create a *.test.php file within the tests/ 65f8369d7dSTobias Sarnowskifolder. Please respect the folder structure and naming convention. Inside the 66f8369d7dSTobias Sarnowskifile, implement a class, extending 'DokuWikiTest'. Every method, starting 67f8369d7dSTobias Sarnowskiwith 'test' will be called as a test (e.g. 'testIfThisIsValid'); 68f8369d7dSTobias Sarnowski 6942dcf8b1SAndreas Gohr===== TODO for the test framework ===== 70f8369d7dSTobias Sarnowski 71f8369d7dSTobias Sarnowski * optional: add helper methods to TestRequest for easy form submission 72f8369d7dSTobias Sarnowski * createForm(), ... 7342dcf8b1SAndreas Gohr * check PHP Unit test_helpers https://github.com/sebastianbergmann/php-test-helpers 74f8369d7dSTobias Sarnowski 75f8369d7dSTobias Sarnowski 76