xref: /dokuwiki/_test/README (revision b25974c4272787f8c66d36398d9578e630888451)
142dcf8b1SAndreas Gohr====== DokuWiki Test Suite ======
2f8369d7dSTobias Sarnowski
3*b25974c4SGuy 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*b25974c4SGuy Brand==== via PEAR installer ====
1342dcf8b1SAndreas Gohr
1442dcf8b1SAndreas Gohr  pear config-set auto_discover 1
1542dcf8b1SAndreas Gohr  pear install pear.phpunit.de/PHPUnit
1642dcf8b1SAndreas Gohr
17*b25974c4SGuy Brand==== via Composer ====
1842dcf8b1SAndreas Gohr
19*b25974c4SGuy BrandInclude a composer.json file in your project, which can be as minimal as:
20*b25974c4SGuy Brand
21*b25974c4SGuy Brand<code>
22*b25974c4SGuy Brand{
23*b25974c4SGuy Brand    "require-dev": {
24*b25974c4SGuy Brand        "phpunit/phpunit": "3.7.*"
25*b25974c4SGuy Brand    }
26*b25974c4SGuy Brand}
27*b25974c4SGuy Brand</code>
28*b25974c4SGuy Brand
29*b25974c4SGuy Brand==== via PHP archive (PHAR) ====
30*b25974c4SGuy Brand
31*b25974c4SGuy BrandDownload http://pear.phpunit.de/get/phpunit.phar and make it executable on your system.
32f8369d7dSTobias Sarnowski
33f8369d7dSTobias Sarnowski
34*b25974c4SGuy Brand===== Running all tests =====
35f8369d7dSTobias Sarnowski
3642dcf8b1SAndreas GohrJust change to the ''_test'' directory and run phpunit:
37f8369d7dSTobias Sarnowski
38*b25974c4SGuy Brand  cd _test/
3942dcf8b1SAndreas Gohr  phpunit
40f8369d7dSTobias Sarnowski
4142dcf8b1SAndreas GohrPHPUnit will fail on some systems with a //headers already sent// error.
4242dcf8b1SAndreas GohrThis is a known problem with PHPUnit, the error can be avoided by passing the
4342dcf8b1SAndreas Gohr'--stderr' flag to phpunit:
44f8369d7dSTobias Sarnowski
4542dcf8b1SAndreas Gohr  phpunit --stderr
46f8369d7dSTobias Sarnowski
47f77b4d4fSDominik EckelmannOn windows you may have to enable OpenSSL support for https tests.
48f77b4d4fSDominik EckelmannSome of them point to httpclient_http.tests.php on the failure.
49f77b4d4fSDominik EckelmannTo enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' to your ''windows\system32'' folder
50f77b4d4fSDominik Eckelmannand add the following line to your php.ini in the extension section:
51f77b4d4fSDominik Eckelmann<code ini>
52f77b4d4fSDominik Eckelmannextension=php_openssl.dll
53f77b4d4fSDominik Eckelmann</code>
54f77b4d4fSDominik Eckelmann
5542dcf8b1SAndreas Gohr===== Running selected Tests =====
56f8369d7dSTobias Sarnowski
5742dcf8b1SAndreas GohrYou can run a single test file by providing it as an argument to phpunit:
58f8369d7dSTobias Sarnowski
5942dcf8b1SAndreas Gohr  phpunit --stderr tests/inc/common_cleanText.test.php
60f8369d7dSTobias Sarnowski
61f7161c34SAndreas GohrYou can also use groups to exclude certain test from running. For example use
62f7161c34SAndreas Gohrthe following command to avoid long running test or tests accessing the
63f7161c34SAndreas GohrInternet.
64f7161c34SAndreas Gohr
65f7161c34SAndreas Gohr  phpunit --stderr --exclude-group slow,internet
66f8369d7dSTobias Sarnowski
6742dcf8b1SAndreas Gohr===== Create new Tests =====
68f8369d7dSTobias Sarnowski
69f8369d7dSTobias SarnowskiTo create a test for DokuWiki, create a *.test.php file within the tests/
70f8369d7dSTobias Sarnowskifolder. Please respect the folder structure and naming convention. Inside the
71f8369d7dSTobias Sarnowskifile, implement a class, extending 'DokuWikiTest'. Every method, starting
72f8369d7dSTobias Sarnowskiwith 'test' will be called as a test (e.g. 'testIfThisIsValid');
73f8369d7dSTobias Sarnowski
74f8369d7dSTobias Sarnowski
7542dcf8b1SAndreas Gohr===== TODO for the test framework =====
76f8369d7dSTobias Sarnowski
77f8369d7dSTobias Sarnowski  * test cross platform compatibility: especially test windows
78f8369d7dSTobias Sarnowski  * update http://www.dokuwiki.org/devel:unittesting
79f8369d7dSTobias Sarnowski  * optional: add helper methods to TestRequest for easy form submission
80f8369d7dSTobias Sarnowski    * createForm(), ...
8142dcf8b1SAndreas Gohr  * check PHP Unit test_helpers https://github.com/sebastianbergmann/php-test-helpers
82f8369d7dSTobias Sarnowski
83f8369d7dSTobias Sarnowski
8442dcf8b1SAndreas Gohr===== Migration Protocol =====
85f8369d7dSTobias Sarnowski
86f8369d7dSTobias SarnowskiThe following tests were not migrated:
87f8369d7dSTobias Sarnowski
88f8369d7dSTobias Sarnowski  * inc/indexer_idx_indexlengths (fs dependencies)
89f8369d7dSTobias Sarnowski  * inc/mail_send (integration test)
90f8369d7dSTobias Sarnowski  * inc/parser/parser_formatting
91f8369d7dSTobias Sarnowski  * inc/parser/xhtml_htmlphp (runkit)
92f8369d7dSTobias Sarnowski  * inc/parser/xhtml_links
93f8369d7dSTobias Sarnowski
94