diff options
author | Chris Smith <chris.eureka@jalakai.co.uk> | 2008-04-18 12:19:46 +0200 |
---|---|---|
committer | Chris Smith <chris.eureka@jalakai.co.uk> | 2008-04-18 12:19:46 +0200 |
commit | 46c73e019aa4552abbd431f3086e73cea74429ce (patch) | |
tree | 4ae7305da71d2234d422914253fa5ca976002db4 /_test | |
parent | bde4e341723f1f504448e86150fb171d76aef615 (diff) | |
download | rpg-46c73e019aa4552abbd431f3086e73cea74429ce.tar.gz rpg-46c73e019aa4552abbd431f3086e73cea74429ce.tar.bz2 |
Update GetBaseURL() to avoid multiple consecutive slashes in absolute return values (incl. test cases)
darcs-hash:20080418101946-f07c6-615691fab5d4b5714134634b38567ca8422a0aa0.gz
Diffstat (limited to '_test')
-rw-r--r-- | _test/cases/inc/init_getbaseurl.test.php | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/_test/cases/inc/init_getbaseurl.test.php b/_test/cases/inc/init_getbaseurl.test.php index 5dec4a954..edd370d61 100644 --- a/_test/cases/inc/init_getbaseurl.test.php +++ b/_test/cases/inc/init_getbaseurl.test.php @@ -32,7 +32,7 @@ class init_getBaseURL_test extends UnitTestCase { * * data provided by Hilko Bengen <bengen@hilluzination.de> */ - function test2(){ + function test2(){ global $conf; $conf['basedir'] = ''; $conf['baseurl'] = ''; @@ -40,7 +40,7 @@ class init_getBaseURL_test extends UnitTestCase { $_SERVER['DOCUMENT_ROOT'] = '/var/www/localhost'; $_SERVER['HTTP_HOST'] = 'localhost'; - $_SERVER['SCRIPT_FILENAME'] = '/usr/lib/cgi-bin/php4'; + $_SERVER['SCRIPT_FILENAME'] = '/usr/lib/cgi-bin/php4'; $_SERVER['REQUEST_URI'] = '/~bengen/dokuwiki/doku.php?do=debug'; $_SERVER['SCRIPT_NAME'] = '/cgi-bin/php4'; $_SERVER['PATH_INFO'] = '/~bengen/dokuwiki/doku.php'; @@ -210,6 +210,71 @@ class init_getBaseURL_test extends UnitTestCase { $this->assertEqual(getBaseURL(),'/dokuwiki/'); } + + /** + * Possible user settings of $conf['baseurl'] & absolute baseURL required + * + * data provided by Andreas Gohr <andi@splitbrain.org> + */ + function test10(){ + // values for $conf['baseurl'] and expected results + $tests = array( + 'http://www.mysite.com' => 'http://www.mysite.com/dokuwiki/', + 'http://www.mysite.com/' => 'http://www.mysite.com/dokuwiki/', + 'http://www.mysite.com/path/to/wiki' => 'http://www.mysite.com/path/to/wiki/dokuwiki/', + 'http://www.mysite.com/path/to/wiki/' => 'http://www.mysite.com/path/to/wiki/dokuwiki/', + ); + + global $conf; + $conf['basedir'] = ''; + $conf['baseurl'] = ''; + + $_SERVER['DOCUMENT_ROOT'] = '/var/www/'; + $_SERVER['HTTP_HOST'] = 'xerxes.my.home'; + $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php'; + $_SERVER['REQUEST_URI'] = '/dokuwiki/wiki/syntax?do=debug'; + $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php'; + $_SERVER['PATH_INFO'] = null; + $_SERVER['PATH_TRANSLATED'] = '/var/www/dokuwiki/doku.php'; + $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php'; + + foreach ($tests as $test => $correct_result) { + $conf['baseurl'] = $test; + $this->assertEqual(getBaseURL(true),$correct_result); + } + } + /** + * Possible user settings of $conf['baseurl'] & absolute baseURL required + * + * data provided by Andreas Gohr <andi@splitbrain.org> + */ + function test11(){ + // values for $conf['baseurl'] and expected results + $tests = array( + 'http://www.mysite.com' => 'http://www.mysite.com/dokuwiki/', + 'http://www.mysite.com/' => 'http://www.mysite.com/dokuwiki/', + 'http://www.mysite.com/path/to/wiki' => 'http://www.mysite.com/path/to/wiki/dokuwiki/', + 'http://www.mysite.com/path/to/wiki/' => 'http://www.mysite.com/path/to/wiki/dokuwiki/', + ); + + global $conf; + $conf['basedir'] = '/dokuwiki'; + $conf['baseurl'] = ''; + + $_SERVER['DOCUMENT_ROOT'] = '/var/www/'; + $_SERVER['HTTP_HOST'] = 'xerxes.my.home'; + $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php'; + $_SERVER['REQUEST_URI'] = '/dokuwiki/wiki/syntax?do=debug'; + $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php'; + $_SERVER['PATH_INFO'] = null; + $_SERVER['PATH_TRANSLATED'] = '/var/www/dokuwiki/doku.php'; + $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php'; + + foreach ($tests as $test => $correct_result) { + $conf['baseurl'] = $test; + $this->assertEqual(getBaseURL(true),$correct_result); + } + } } //Setup VIM: ex: et ts=2 enc=utf-8 : |