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