Merge branch 'master' into stable
[dokuwiki.git] / _test / tests / inc / pageutils_getid.test.php
blob0fcd58666a7ce0924534451f057cb046e8816529
1 <?php
3 class init_getID_test extends DokuWikiTest {
5 /**
6 * fetch media files with basedir and urlrewrite=2
8 * data provided by Jan Decaluwe <jan@jandecaluwe.com>
9 */
10 function test1(){
11 global $conf;
12 $conf['basedir'] = '//';
13 $conf['userewrite'] = 2;
14 $conf['deaccent'] = 0; // the default (1) gives me strange exceptions
17 $_SERVER['SCRIPT_FILENAME'] = '/lib/exe/fetch.php';
18 $_SERVER['REQUEST_URI'] = '/lib/exe/fetch.php/myhdl-0.5dev1.tar.gz?id=snapshots&cache=cache';
20 $this->assertEquals(getID('media'), 'myhdl-0.5dev1.tar.gz');
24 /**
25 * getID with internal mediafile, urlrewrite=2, no basedir set, apache, mod_php
27 function test2(){
28 global $conf;
29 $conf['basedir'] = '';
30 $conf['userewrite'] = '2';
31 $conf['baseurl'] = '';
32 $conf['useslash'] = '1';
33 $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
34 $_SERVER['HTTP_HOST'] = 'xerxes.my.home';
35 $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/lib/exe/detail.php';
36 $_SERVER['PHP_SELF'] = '/dokuwiki/lib/exe/detail.php/wiki/discussion/button-dw.png';
37 $_SERVER['REQUEST_URI'] = '/dokuwiki/lib/exe/detail.php/wiki/discussion/button-dw.png?id=test&debug=1';
38 $_SERVER['SCRIPT_NAME'] = '/dokuwiki/lib/exe/detail.php';
39 $_SERVER['PATH_INFO'] = '/wiki/discussion/button-dw.png';
40 $_SERVER['PATH_TRANSLATED'] = '/var/www/wiki/discussion/button-dw.png';
42 $this->assertEquals(getID('media',true), 'wiki:discussion:button-dw.png');
43 $this->assertEquals(getID('media',false), 'wiki/discussion/button-dw.png');
46 /**
47 * getID with given id in url and userewrite=2, no basedir set, dokuwiki not in document root.
49 function test3() {
50 global $conf;
51 $conf['basedir'] = '';
52 $conf['userewrite'] = '2';
53 $conf['baseurl'] = '';
54 $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
55 $_SERVER['SCRIPT_FILENAME'] = '/usr/share/dokuwiki/doku.php';
56 $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
57 $_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/wiki:dokuwiki';
58 $_SERVER['PATH_INFO'] = '/wiki:dokuwiki';
59 $_SERVER['PATH_TRANSLATED'] = '/var/www/wiki:dokuwiki';
60 $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/wiki:dokuwiki';
62 $this->assertEquals(getID(), 'wiki:dokuwiki');
65 /**
66 * getID with given id in url and userewrite=2, no basedir set, Apache and CGI.
68 function test4() {
69 global $conf;
70 $conf['basedir'] = '';
71 $conf['userewrite'] = '2';
72 $conf['baseurl'] = '';
73 $conf['useslash'] = '1';
75 $_SERVER['DOCUMENT_ROOT'] = '/var/www/vhosts/example.com/htdocs';
76 $_SERVER['SCRIPT_FILENAME'] = '/var/www/vhosts/example.com/htdocs/doku.php';
77 $_SERVER['SCRIPT_NAME'] = '/doku.php';
78 $_SERVER['REQUEST_URI'] = '/doku.php/wiki/dokuwiki';
79 $_SERVER['PATH_INFO'] = '/wiki/dokuwiki';
80 $_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php';
81 $_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki';
83 $this->assertEquals(getID(), 'wiki:dokuwiki');
86 /**
87 * getID with given id / in url and userewrite=2, no basedir set, Apache and CGI.
89 function test5() {
90 global $conf;
91 $conf['basedir'] = '';
92 $conf['userewrite'] = '2';
93 $conf['baseurl'] = '';
94 $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
95 $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
96 $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
97 $_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/?do=debug';
98 $_SERVER['PATH_INFO'] = '/';
99 $_SERVER['PATH_TRANSLATED'] = '/var/www/index.html';
100 $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/';
102 $this->assertEquals(getID(), cleanID($conf['start']));
106 //Setup VIM: ex: et ts=4 :