3 * Test Suite bootstrapping for DokuWiki
6 if(!defined('DOKU_UNITTEST')) define('DOKU_UNITTEST',dirname(__FILE__
).'/');
7 require_once DOKU_UNITTEST
.'core/phpQuery-onefile.php';
8 require_once DOKU_UNITTEST
.'core/DokuWikiTest.php';
9 require_once DOKU_UNITTEST
.'core/TestResponse.php';
10 require_once DOKU_UNITTEST
.'core/TestRequest.php';
11 require_once DOKU_UNITTEST
.'core/TestUtils.php';
14 // backward compatibility to old test suite
15 define('SIMPLE_TEST', true);
18 define('DOKU_E_LEVEL',E_ALL ^ E_NOTICE
);
19 error_reporting(DOKU_E_LEVEL
);
21 ini_set('memory_limit','2048M');
23 // prepare temporary directories; str_replace is for WIN
24 define('DOKU_INC', str_replace('\\', '/', dirname(dirname(__FILE__
))) . '/');
25 define('TMP_DIR', str_replace('\\', '/', sys_get_temp_dir()) . '/dwtests-'.microtime(true));
26 define('DOKU_CONF', TMP_DIR
.'/conf/');
27 define('DOKU_TMP_DATA', TMP_DIR
.'/data/');
30 $default_plugins = array(
42 // default server variables
43 $default_server_vars = array(
44 'QUERY_STRING' => '?id=',
45 'REQUEST_METHOD' => 'GET',
47 'CONTENT_LENGTH' => '',
48 'SCRIPT_NAME' => '/doku.php',
49 'REQUEST_URI' => '/doku.php?id=',
50 'DOCUMENT_URI' => '/doku.php',
51 'DOCUMENT_ROOT' => DOKU_INC
,
52 'SERVER_PROTOCOL' => 'HTTP/1.1',
53 'SERVER_SOFTWARE' => 'nginx/0.7.67',
54 'REMOTE_ADDR' => '87.142.120.6',
55 'REMOTE_PORT' => '21418',
56 'SERVER_ADDR' => '46.38.241.24',
57 'SERVER_PORT' => '443',
58 'SERVER_NAME' => 'wiki.example.com',
59 'REDIRECT_STATUS' => '200',
60 'SCRIPT_FILENAME' => DOKU_INC
.'doku.php',
61 'HTTP_HOST' => 'wiki.example.com',
62 'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; OpenBSD amd64; rv:11.0) Gecko/20100101 Firefox/11.0',
63 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
64 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
65 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
66 'HTTP_CONNECTION' => 'keep-alive',
67 'HTTP_CACHE_CONTROL' => 'max-age=0',
68 'PHP_SELF' => '/doku.php',
69 'REQUEST_TIME' => time(),
72 // fixup for $_SERVER when run from CLI,
73 // some values should be mocked for use by inc/init.php which is called here
74 // [ $_SERVER is also mocked in TestRequest::execute() ]
75 if (php_sapi_name() == 'cli') {
76 $_SERVER = array_merge($default_server_vars, $_SERVER);
79 // create temp directories
82 // cleanup dir after exit
83 if (getenv('PRESERVE_TMP') != 'true') {
84 register_shutdown_function(function() {
85 TestUtils
::rdelete(TMP_DIR
);
88 echo ">>>> Preserving temporary directory: ".TMP_DIR
."\n";
91 // populate default dirs for initial setup
92 DokuWikiTest
::setupDataDir();
93 DokuWikiTest
::setupConfDir();
95 // disable all non-default plugins by default
96 $dh = dir(DOKU_INC
.'lib/plugins/');
97 while (false !== ($entry = $dh->read())) {
98 if ($entry == '.' ||
$entry == '..') {
102 if (!is_dir(DOKU_INC
.'lib/plugins/'.$entry)) {
106 if (!in_array($entry, $default_plugins)) {
107 // disable this plugin
108 TestUtils
::fappend(DOKU_CONF
.'plugins.local.php', "\$plugins['$entry'] = 0;\n");
114 require_once(DOKU_INC
.'inc/init.php');
116 // load the parser so $PARSER_MODES is defined before the tests start
117 // otherwise PHPUnit unsets $PARSER_MODES in some cases which breaks p_get_parsermodes()
118 require_once(DOKU_INC
.'inc/parser/parser.php');