[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/inc/ -> pageutils_getid.test.php (source)

   1  <?php
   2  
   3  class init_getID_test extends DokuWikiTest {
   4  
   5      /**
   6       * id=0 case
   7       */
   8      function test_zero_id(){
   9          global $conf;
  10          $conf['basedir'] = '/';
  11          $conf['userewrite'] = 0;
  12  
  13          $_SERVER['SCRIPT_FILENAME'] = '/doku.php';
  14          $_SERVER['REQUEST_URI'] = '/doku.php?id=0&do=edit';
  15          $_REQUEST['id'] = '0';
  16  
  17          $this->assertSame('0', getID('id'));
  18      }
  19  
  20      /**
  21       * fetch media files with basedir and urlrewrite=2
  22       *
  23       * data provided by Jan Decaluwe <jan@jandecaluwe.com>
  24       */
  25      function test1(){
  26          global $conf;
  27          $conf['basedir'] = '//';
  28          $conf['userewrite'] = 2;
  29          $conf['deaccent'] = 0; // the default (1) gives me strange exceptions
  30  
  31  
  32          $_SERVER['SCRIPT_FILENAME'] = '/lib/exe/fetch.php';
  33          $_SERVER['REQUEST_URI'] = '/lib/exe/fetch.php/myhdl-0.5dev1.tar.gz?id=snapshots&cache=cache';
  34  
  35          $this->assertEquals(getID('media'), 'myhdl-0.5dev1.tar.gz');
  36      }
  37  
  38  
  39      /**
  40       * getID with internal mediafile, urlrewrite=2, no basedir set, apache, mod_php
  41       */
  42      function test2(){
  43          global $conf;
  44          $conf['basedir'] = '';
  45          $conf['userewrite'] = '2';
  46          $conf['baseurl'] = '';
  47          $conf['useslash'] = '1';
  48          $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
  49          $_SERVER['HTTP_HOST'] = 'xerxes.my.home';
  50          $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/lib/exe/detail.php';
  51          $_SERVER['PHP_SELF'] = '/dokuwiki/lib/exe/detail.php/wiki/discussion/button-dw.png';
  52          $_SERVER['REQUEST_URI'] = '/dokuwiki/lib/exe/detail.php/wiki/discussion/button-dw.png?id=test&debug=1';
  53          $_SERVER['SCRIPT_NAME'] = '/dokuwiki/lib/exe/detail.php';
  54          $_SERVER['PATH_INFO'] = '/wiki/discussion/button-dw.png';
  55          $_SERVER['PATH_TRANSLATED'] = '/var/www/wiki/discussion/button-dw.png';
  56  
  57          $this->assertEquals(getID('media',true), 'wiki:discussion:button-dw.png');
  58          $this->assertEquals(getID('media',false), 'wiki/discussion/button-dw.png');
  59      }
  60  
  61      /**
  62       * getID with given id in url and userewrite=2, no basedir set, dokuwiki not in document root.
  63       */
  64      function test3() {
  65          global $conf;
  66          $conf['basedir'] = '';
  67          $conf['userewrite'] = '2';
  68          $conf['baseurl'] = '';
  69          $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
  70          $_SERVER['SCRIPT_FILENAME'] = '/usr/share/dokuwiki/doku.php';
  71          $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
  72          $_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/wiki:dokuwiki';
  73          $_SERVER['PATH_INFO'] = '/wiki:dokuwiki';
  74          $_SERVER['PATH_TRANSLATED'] = '/var/www/wiki:dokuwiki';
  75          $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/wiki:dokuwiki';
  76  
  77          $this->assertEquals(getID(), 'wiki:dokuwiki');
  78      }
  79  
  80      /**
  81       * getID with given id in url and userewrite=2, no basedir set, Apache and CGI.
  82       */
  83      function test4() {
  84          global $conf;
  85          $conf['basedir'] = '';
  86          $conf['userewrite'] = '2';
  87          $conf['baseurl'] = '';
  88          $conf['useslash'] = '1';
  89  
  90          $_SERVER['DOCUMENT_ROOT'] = '/var/www/vhosts/example.com/htdocs';
  91          $_SERVER['SCRIPT_FILENAME'] = '/var/www/vhosts/example.com/htdocs/doku.php';
  92          $_SERVER['SCRIPT_NAME'] = '/doku.php';
  93          $_SERVER['REQUEST_URI'] = '/doku.php/wiki/dokuwiki';
  94          $_SERVER['PATH_INFO'] = '/wiki/dokuwiki';
  95          $_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php';
  96          $_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki';
  97  
  98          $this->assertEquals(getID(), 'wiki:dokuwiki');
  99      }
 100  
 101      /**
 102       * getID with given id / in url and userewrite=2, no basedir set, Apache and CGI.
 103       */
 104      function test5() {
 105          global $conf;
 106          $conf['basedir'] = '';
 107          $conf['userewrite'] = '2';
 108          $conf['baseurl'] = '';
 109          $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
 110          $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
 111          $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
 112          $_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/?do=debug';
 113          $_SERVER['PATH_INFO'] = '/';
 114          $_SERVER['PATH_TRANSLATED'] = '/var/www/index.html';
 115          $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/';
 116  
 117          $this->assertEquals(getID(), cleanID($conf['start']));
 118      }
 119  
 120  }
 121  //Setup VIM: ex: et ts=4 :