1<?php 2/** 3 * Test Suite bootstrapping for DokuWiki 4 */ 5 6if(!defined('DOKU_UNITTEST')) define('DOKU_UNITTEST',dirname(__FILE__).'/'); 7require_once DOKU_UNITTEST.'core/phpQuery-onefile.php'; 8require_once DOKU_UNITTEST.'core/DokuWikiTest.php'; 9require_once DOKU_UNITTEST.'core/TestResponse.php'; 10require_once DOKU_UNITTEST.'core/TestRequest.php'; 11require_once DOKU_UNITTEST.'core/TestUtils.php'; 12 13 14// backward compatibility to old test suite 15define('SIMPLE_TEST', true); 16 17// basic behaviours 18error_reporting(E_ALL); 19set_time_limit(0); 20ini_set('memory_limit','2048M'); 21 22// prepare temporary directories 23define('DOKU_INC', dirname(dirname(__FILE__)).'/'); 24define('TMP_DIR', sys_get_temp_dir().'/dwtests-'.microtime(true)); 25define('DOKU_CONF', TMP_DIR.'/conf/'); 26define('DOKU_TMP_DATA', TMP_DIR.'/data/'); 27 28// default plugins 29$default_plugins = array( 30 'acl', 31 'config', 32 'info', 33 'plugin', 34 'popularity', 35 'revert', 36 'safefnrecode', 37 'usermanager' 38); 39 40// default server variables 41$default_server_vars = array( 42 'QUERY_STRING' => '?id=', 43 'REQUEST_METHOD' => 'GET', 44 'CONTENT_TYPE' => '', 45 'CONTENT_LENGTH' => '', 46 'SCRIPT_NAME' => '/doku.php', 47 'REQUEST_URI' => '/doku.php?id=', 48 'DOCUMENT_URI' => '/doku.php', 49 'DOCUMENT_ROOT' => DOKU_INC, 50 'SERVER_PROTOCOL' => 'HTTP/1.1', 51 'SERVER_SOFTWARE' => 'nginx/0.7.67', 52 'REMOTE_ADDR' => '87.142.120.6', 53 'REMOTE_PORT' => '21418', 54 'SERVER_ADDR' => '46.38.241.24', 55 'SERVER_PORT' => '443', 56 'SERVER_NAME' => 'wiki.example.com', 57 'REDIRECT_STATUS' => '200', 58 'SCRIPT_FILENAME' => DOKU_INC.'doku.php', 59 'HTTP_HOST' => 'wiki.example.com', 60 'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; OpenBSD amd64; rv:11.0) Gecko/20100101 Firefox/11.0', 61 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 62 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', 63 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 64 'HTTP_CONNECTION' => 'keep-alive', 65 'HTTP_CACHE_CONTROL' => 'max-age=0', 66 'PHP_SELF' => '/doku.php', 67 'REQUEST_TIME' => time(), 68); 69 70// create temp directories 71mkdir(TMP_DIR); 72 73// cleanup dir after exit 74if (getenv('PRESERVE_TMP') != 'true') { 75 register_shutdown_function(function() { 76 TestUtils::rdelete(TMP_DIR); 77 }); 78} else { 79 echo ">>>> Preserving temporary directory: ".TMP_DIR."\n"; 80} 81 82// populate default dirs 83TestUtils::rcopy(TMP_DIR, DOKU_INC.'/conf'); 84TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/conf'); 85mkdir(DOKU_TMP_DATA); 86foreach(array( 87 'attic', 'cache', 'index', 'locks', 'media', 88 'media_attic', 'media_meta', 'meta', 'pages', 'tmp') as $dir){ 89 mkdir(DOKU_TMP_DATA.'/'.$dir); 90} 91 92// disable all non-default plugins by default 93$dh = dir(DOKU_INC.'lib/plugins/'); 94while (false !== ($entry = $dh->read())) { 95 if ($entry == '.' || $entry == '..') { 96 continue; 97 } 98 99 if (!is_dir(DOKU_INC.'lib/plugins/'.$entry)) { 100 continue; 101 } 102 103 if (!in_array($entry, $default_plugins)) { 104 // disable this plugin 105 TestUtils::fappend(DOKU_CONF.'plugins.local.php', "\$plugins['$entry'] = 0;\n"); 106 } 107} 108$dh->close(); 109 110// load dw 111require_once(DOKU_INC.'inc/init.php'); 112 113// load the parser so $PARSER_MODES is defined before the tests start 114// otherwise PHPUnit unsets $PARSER_MODES in some cases which breaks p_get_parsermodes() 115require_once(DOKU_INC.'inc/parser/parser.php'); 116 117