diff options
-rw-r--r-- | _test/cases/inc/common_clientip.test.php (renamed from _test/cases/inc/common_clientIP.test.php) | 0 | ||||
-rw-r--r-- | _test/cases/inc/pageutils_resolve_pageid.test.php | 3 | ||||
-rw-r--r-- | _test/cases/inc/parser/parser.test.php | 1 | ||||
-rw-r--r-- | _test/index.php | 52 | ||||
-rw-r--r-- | _test/lib/testmanager.php | 6 | ||||
-rw-r--r-- | inc/auth.php | 8 | ||||
-rw-r--r-- | inc/events.php | 1 | ||||
-rw-r--r-- | inc/init.php | 12 | ||||
-rw-r--r-- | inc/pageutils.php | 8 | ||||
-rw-r--r-- | inc/parser/handler.php | 2 | ||||
-rw-r--r-- | inc/pluginutils.php | 3 |
11 files changed, 61 insertions, 35 deletions
diff --git a/_test/cases/inc/common_clientIP.test.php b/_test/cases/inc/common_clientip.test.php index 257229811..257229811 100644 --- a/_test/cases/inc/common_clientIP.test.php +++ b/_test/cases/inc/common_clientip.test.php diff --git a/_test/cases/inc/pageutils_resolve_pageid.test.php b/_test/cases/inc/pageutils_resolve_pageid.test.php index 2546bd2af..ab282b57a 100644 --- a/_test/cases/inc/pageutils_resolve_pageid.test.php +++ b/_test/cases/inc/pageutils_resolve_pageid.test.php @@ -2,6 +2,9 @@ require_once DOKU_INC.'inc/utf8.php'; require_once DOKU_INC.'inc/pageutils.php'; +global $conf; +if (!isset($conf['datadir'])) $conf['datadir'] = $conf['savedir'].'/pages'; + class init_resolve_pageid_test extends UnitTestCase { diff --git a/_test/cases/inc/parser/parser.test.php b/_test/cases/inc/parser/parser.test.php index c760c127a..d18a245f7 100644 --- a/_test/cases/inc/parser/parser.test.php +++ b/_test/cases/inc/parser/parser.test.php @@ -10,6 +10,7 @@ */ require_once DOKU_INC . 'inc/parser/parser.php'; require_once DOKU_INC . 'inc/parser/handler.php'; +require_once DOKU_INC . 'inc/events.php'; //require_once DOKU . 'parser/renderer.php'; //Mock::generate('Doku_Renderer'); diff --git a/_test/index.php b/_test/index.php index 7410cf461..99fae4b95 100644 --- a/_test/index.php +++ b/_test/index.php @@ -1,7 +1,13 @@ <?php +define('DOKU_UNITTEST',true); +define('DOKU_TESTSCRIPT',$_SERVER['PHP_SELF']); + if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); -define('DOKU_CONF',realpath(dirname(__FILE__).'/../conf').'/' ); +define('DOKU_CONF',realpath(dirname(__FILE__).'/../conf').'/'); + require_once DOKU_CONF . 'dokuwiki.php'; +if(@file_exists(DOKU_CONF.'local.php')){ require_once(DOKU_CONF.'local.php'); } + $conf['lang'] = 'en'; define('TEST_ROOT', dirname(__FILE__)); define('TMPL_FILESCHEME_PATH', TEST_ROOT . '/filescheme/'); @@ -56,7 +62,7 @@ function DW_TESTS_PaintRunMore() { break; case DW_TESTS_OUTPUT_HTML: default: - echo "<p><a href='" . $_SERVER['PHP_SELF'] . "'>Run more tests</a></p>"; + echo "<p><a href='" . DOKU_TESTSCRIPT . "'>Run more tests</a></p>"; break; } } @@ -94,8 +100,8 @@ function DW_TESTS_PaintSuiteHeader() { case DW_TESTS_OUTPUT_HTML: default: echo "<h1>Dokuwiki: Unit Test Suite</h1>\n"; - echo "<p><a href='index.php?show=groups'>Test groups</a>"; - echo " || <a href='index.php?show=cases'>Test cases</a></p>"; + echo "<p><a href='". DOKU_TESTSCRIPT ."?show=groups'>Test groups</a>"; + echo " || <a href='". DOKU_TESTSCRIPT ."?show=cases'>Test cases</a></p>"; break; } } @@ -140,25 +146,25 @@ EOD; } /** OUTPUT STARTS HERE **/ -
-// If it's a group test
-if (isset($_GET['group'])) {
- if ('all' == $_GET['group']) {
- TestManager::runAllTests(DW_TESTS_GetReporter());
- } else {
- TestManager::runGroupTest(ucfirst($_GET['group']),
- TEST_GROUPS,
- DW_TESTS_GetReporter());
- }
- DW_TESTS_PaintRunMore();
- exit();
-}
-
-// If it's a single test case
-if (isset($_GET['case'])) {
- TestManager::runTestCase($_GET['case'], TEST_CASES, DW_TESTS_GetReporter());
- DW_TESTS_PaintRunMore();
- exit();
+ +// If it's a group test +if (isset($_GET['group'])) { + if ('all' == $_GET['group']) { + TestManager::runAllTests(DW_TESTS_GetReporter()); + } else { + TestManager::runGroupTest(ucfirst($_GET['group']), + TEST_GROUPS, + DW_TESTS_GetReporter()); + } + DW_TESTS_PaintRunMore(); + exit(); +} + +// If it's a single test case +if (isset($_GET['case'])) { + TestManager::runTestCase($_GET['case'], TEST_CASES, DW_TESTS_GetReporter()); + DW_TESTS_PaintRunMore(); + exit(); } // Else it's the main page diff --git a/_test/lib/testmanager.php b/_test/lib/testmanager.php index 51d7f5a99..def86ca27 100644 --- a/_test/lib/testmanager.php +++ b/_test/lib/testmanager.php @@ -47,7 +47,7 @@ class TestManager { require_once SIMPLE_TEST . 'web_tester.php'; require_once SIMPLE_TEST . 'mock_objects.php'; require_once 'web.inc.php'; - require_once 'mock_functions.php'; + require_once 'mock_functions.php'; } function runAllTests(&$reporter) { @@ -286,7 +286,9 @@ class HTMLTestManager extends TestManager { "?case=" . urlencode($testcase) . "'>" . $testcase . "</a></li>\n"; } - return $buffer . "</ul>\n"; + + $buffer .= "</ul>\n"; + return $buffer; } } diff --git a/inc/auth.php b/inc/auth.php index 467f4b0cd..8043feb45 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -17,6 +17,8 @@ require_once(DOKU_INC.'inc/blowfish.php'); require_once(DOKU_INC.'inc/mail.php'); + global $auth; + // load the the backend auth functions and instantiate the auth object if (@file_exists(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php')) { require_once(DOKU_INC.'inc/auth/basic.class.php'); @@ -54,11 +56,15 @@ // do the login either by cookie or provided credentials if($conf['useacl']){ // if no credentials were given try to use HTTP auth (for SSO) - if(!$_REQUEST['u'] && !$_COOKIE[DOKU_COOKIE] && $_SERVER['PHP_AUTH_USER']){ + if(empty($_REQUEST['u']) && !$_COOKIE[DOKU_COOKIE] && $_SERVER['PHP_AUTH_USER']){ $_REQUEST['u'] = $_SERVER['PHP_AUTH_USER']; $_REQUEST['p'] = $_SERVER['PHP_AUTH_PW']; } + if (!isset($_REQUEST['u'])) $_REQUEST['u'] = ''; + if (!isset($_REQUEST['p'])) $_REQUEST['p'] = ''; + if (!isset($_REQUEST['r'])) $_REQUEST['r'] = ''; + // external trust mechanism in place? if(!is_null($auth) && $auth->canDo('external')){ $auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']); diff --git a/inc/events.php b/inc/events.php index cb3f52143..ddb0eb277 100644 --- a/inc/events.php +++ b/inc/events.php @@ -198,4 +198,5 @@ function trigger_event($name, &$data, $action=NULL, $canPreventDefault=true) { } // create the event handler +global $EVENT_HANDLER; $EVENT_HANDLER = new Doku_Event_Handler(); diff --git a/inc/init.php b/inc/init.php index 934b14dd7..783d3d9c4 100644 --- a/inc/init.php +++ b/inc/init.php @@ -25,12 +25,14 @@ //prepare config array() global $conf; - $conf = array(); + if (!defined('DOKU_UNITTEST')) { + $conf = array(); - // load the config file(s) - require_once(DOKU_CONF.'dokuwiki.php'); - if(@file_exists(DOKU_CONF.'local.php')){ - require_once(DOKU_CONF.'local.php'); + // load the config file(s) + require_once(DOKU_CONF.'dokuwiki.php'); + if(@file_exists(DOKU_CONF.'local.php')){ + require_once(DOKU_CONF.'local.php'); + } } //prepare language array diff --git a/inc/pageutils.php b/inc/pageutils.php index a478ecd3a..aacee1b13 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -21,7 +21,7 @@ function getID($param='id',$clean=true){ global $conf; - $id = $_REQUEST[$param]; + $id = isset($_REQUEST[$param]) ? $_REQUEST[$param] : null; //construct page id from request URI if(empty($id) && $conf['userewrite'] == 2){ @@ -301,7 +301,11 @@ function resolve_pageid($ns,&$page,&$exists){ $exists = false; //keep hashlink if exists then clean both parts - list($page,$hash) = split('#',$page,2); + if (strpos($page,'#')) { + list($page,$hash) = split('#',$page,2); + } else { + $hash = ''; + } $hash = cleanID($hash); $page = resolve_id($ns,$page,false); // resolve but don't clean, yet diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 519336caa..602ef1b6d 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -1341,7 +1341,7 @@ class Doku_Handler_Block { function Doku_Handler_Block(){ global $DOKU_PLUGINS; //check if syntax plugins were loaded - if(!is_array($DOKU_PLUGINS['syntax'])) return; + if(empty($DOKU_PLUGINS['syntax'])) return; foreach($DOKU_PLUGINS['syntax'] as $n => $p){ $ptype = $p->getPType(); if($ptype == 'block'){ diff --git a/inc/pluginutils.php b/inc/pluginutils.php index 4d3b5cbd6..a93cca936 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -7,6 +7,7 @@ */ // plugin related constants +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); $plugin_types = array('admin','syntax','action'); /** @@ -67,7 +68,7 @@ function &plugin_load($type,$name){ //plugin already loaded? - if($DOKU_PLUGINS[$type][$name] != null){ + if(!empty($DOKU_PLUGINS[$type][$name])){ return $DOKU_PLUGINS[$type][$name]; } |