summaryrefslogtreecommitdiff
path: root/_test/tests/inc/pageutils_getid.test.php
diff options
context:
space:
mode:
authorGuy Brand <gb@unistra.fr>2012-09-10 17:04:45 +0200
committerGuy Brand <gb@unistra.fr>2012-09-10 17:04:45 +0200
commit0f8ac4e8c5872a6b68b350f96a9ecde0291edefa (patch)
treead7938bb4143d5e5a38fd7a8d131e4171aec657d /_test/tests/inc/pageutils_getid.test.php
parent58ec8fa9128e4581749955de87530f432e387588 (diff)
parentb31fcef02fd24b3e746c9618e77152c7b84c2f2a (diff)
downloadrpg-0f8ac4e8c5872a6b68b350f96a9ecde0291edefa.tar.gz
rpg-0f8ac4e8c5872a6b68b350f96a9ecde0291edefa.tar.bz2
Merge branch 'master' into stable
Diffstat (limited to '_test/tests/inc/pageutils_getid.test.php')
-rw-r--r--_test/tests/inc/pageutils_getid.test.php106
1 files changed, 106 insertions, 0 deletions
diff --git a/_test/tests/inc/pageutils_getid.test.php b/_test/tests/inc/pageutils_getid.test.php
new file mode 100644
index 000000000..0fcd58666
--- /dev/null
+++ b/_test/tests/inc/pageutils_getid.test.php
@@ -0,0 +1,106 @@
+<?php
+
+class init_getID_test extends DokuWikiTest {
+
+ /**
+ * fetch media files with basedir and urlrewrite=2
+ *
+ * data provided by Jan Decaluwe <jan@jandecaluwe.com>
+ */
+ function test1(){
+ global $conf;
+ $conf['basedir'] = '//';
+ $conf['userewrite'] = 2;
+ $conf['deaccent'] = 0; // the default (1) gives me strange exceptions
+
+
+ $_SERVER['SCRIPT_FILENAME'] = '/lib/exe/fetch.php';
+ $_SERVER['REQUEST_URI'] = '/lib/exe/fetch.php/myhdl-0.5dev1.tar.gz?id=snapshots&cache=cache';
+
+ $this->assertEquals(getID('media'), 'myhdl-0.5dev1.tar.gz');
+ }
+
+
+ /**
+ * getID with internal mediafile, urlrewrite=2, no basedir set, apache, mod_php
+ */
+ function test2(){
+ global $conf;
+ $conf['basedir'] = '';
+ $conf['userewrite'] = '2';
+ $conf['baseurl'] = '';
+ $conf['useslash'] = '1';
+ $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
+ $_SERVER['HTTP_HOST'] = 'xerxes.my.home';
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/lib/exe/detail.php';
+ $_SERVER['PHP_SELF'] = '/dokuwiki/lib/exe/detail.php/wiki/discussion/button-dw.png';
+ $_SERVER['REQUEST_URI'] = '/dokuwiki/lib/exe/detail.php/wiki/discussion/button-dw.png?id=test&debug=1';
+ $_SERVER['SCRIPT_NAME'] = '/dokuwiki/lib/exe/detail.php';
+ $_SERVER['PATH_INFO'] = '/wiki/discussion/button-dw.png';
+ $_SERVER['PATH_TRANSLATED'] = '/var/www/wiki/discussion/button-dw.png';
+
+ $this->assertEquals(getID('media',true), 'wiki:discussion:button-dw.png');
+ $this->assertEquals(getID('media',false), 'wiki/discussion/button-dw.png');
+ }
+
+ /**
+ * getID with given id in url and userewrite=2, no basedir set, dokuwiki not in document root.
+ */
+ function test3() {
+ global $conf;
+ $conf['basedir'] = '';
+ $conf['userewrite'] = '2';
+ $conf['baseurl'] = '';
+ $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
+ $_SERVER['SCRIPT_FILENAME'] = '/usr/share/dokuwiki/doku.php';
+ $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
+ $_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/wiki:dokuwiki';
+ $_SERVER['PATH_INFO'] = '/wiki:dokuwiki';
+ $_SERVER['PATH_TRANSLATED'] = '/var/www/wiki:dokuwiki';
+ $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/wiki:dokuwiki';
+
+ $this->assertEquals(getID(), 'wiki:dokuwiki');
+ }
+
+ /**
+ * getID with given id in url and userewrite=2, no basedir set, Apache and CGI.
+ */
+ function test4() {
+ global $conf;
+ $conf['basedir'] = '';
+ $conf['userewrite'] = '2';
+ $conf['baseurl'] = '';
+ $conf['useslash'] = '1';
+
+ $_SERVER['DOCUMENT_ROOT'] = '/var/www/vhosts/example.com/htdocs';
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/vhosts/example.com/htdocs/doku.php';
+ $_SERVER['SCRIPT_NAME'] = '/doku.php';
+ $_SERVER['REQUEST_URI'] = '/doku.php/wiki/dokuwiki';
+ $_SERVER['PATH_INFO'] = '/wiki/dokuwiki';
+ $_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php';
+ $_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki';
+
+ $this->assertEquals(getID(), 'wiki:dokuwiki');
+ }
+
+ /**
+ * getID with given id / in url and userewrite=2, no basedir set, Apache and CGI.
+ */
+ function test5() {
+ global $conf;
+ $conf['basedir'] = '';
+ $conf['userewrite'] = '2';
+ $conf['baseurl'] = '';
+ $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
+ $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
+ $_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/?do=debug';
+ $_SERVER['PATH_INFO'] = '/';
+ $_SERVER['PATH_TRANSLATED'] = '/var/www/index.html';
+ $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/';
+
+ $this->assertEquals(getID(), cleanID($conf['start']));
+ }
+
+}
+//Setup VIM: ex: et ts=4 :