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