[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

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

   1  <?php
   2  
   3  class common_wl_test extends DokuWikiTest {
   4  
   5      function test_wl_empty() {
   6          global $conf;
   7          $conf['useslash'] = 0;
   8          $conf['userewrite'] = 0;
   9          $conf['start'] = 'start';
  10  
  11          $this->assertEquals(DOKU_BASE . DOKU_SCRIPT . '?id=start' , wl());
  12      }
  13  
  14      function test_wl_empty_rewrite1() {
  15          global $conf;
  16          $conf['useslash'] = 0;
  17          $conf['userewrite'] = 1;
  18          $conf['start'] = 'start';
  19  
  20          $this->assertEquals(DOKU_BASE . 'start' , wl());
  21      }
  22  
  23      function test_wl_empty_rewrite2() {
  24          global $conf;
  25          $conf['useslash'] = 0;
  26          $conf['userewrite'] = 2;
  27          $conf['start'] = 'start';
  28  
  29          $this->assertEquals(DOKU_BASE . DOKU_SCRIPT . '/start' , wl());
  30      }
  31  
  32      function test_wl_id() {
  33          global $conf;
  34          $conf['useslash'] = 0;
  35          $conf['userewrite'] = 0;
  36  
  37          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some';
  38          $this->assertEquals($expect, wl('some'));
  39      }
  40  
  41      function test_wl_id_zero() {
  42          global $conf;
  43          $conf['useslash'] = 0;
  44          $conf['userewrite'] = 0;
  45  
  46          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=0';
  47          $this->assertEquals($expect, wl('0'));
  48      }
  49  
  50      function test_wl_id_ns() {
  51          global $conf;
  52          $conf['useslash'] = 0;
  53          $conf['userewrite'] = 0;
  54  
  55          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:some';
  56          $this->assertEquals($expect, wl('some:some'));
  57      }
  58  
  59      function test_wl_id_ns_start() {
  60          global $conf;
  61          $conf['useslash'] = 0;
  62          $conf['userewrite'] = 0;
  63  
  64          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:';
  65          $this->assertEquals($expect, wl('some:'));
  66      }
  67  
  68      function test_wl_args_array() {
  69          global $conf;
  70          $conf['useslash'] = 0;
  71          $conf['userewrite'] = 0;
  72  
  73          $args = array('a' => 'b', 'c' => 'd', 'q' => '&รค');
  74  
  75          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d&amp;q=%26%C3%A4';
  76          $this->assertEquals($expect, wl('some:', $args));
  77      }
  78  
  79      function test_wl_args_string() {
  80          global $conf;
  81          $conf['useslash'] = 0;
  82          $conf['userewrite'] = 0;
  83  
  84          $args = 'a=b&c=d';
  85  
  86          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&c=d';
  87          $this->assertEquals($expect, wl('some:', $args));
  88      }
  89  
  90      function test_wl_args_comma_string() {
  91          global $conf;
  92          $conf['useslash'] = 0;
  93          $conf['userewrite'] = 0;
  94  
  95          $args = 'a=b,c=d';
  96  
  97          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d';
  98          $this->assertEquals($expect, wl('some:', $args));
  99      }
 100  
 101      function test_wl_abs() {
 102          global $conf;
 103          $conf['useslash'] = 0;
 104          $conf['userewrite'] = 0;
 105  
 106          $expect = DOKU_URL . DOKU_SCRIPT . '?id=some:';
 107          $this->assertEquals($expect, wl('some:', '', true));
 108      }
 109  
 110      function test_wl_sep() {
 111          global $conf;
 112          $conf['useslash'] = 0;
 113          $conf['userewrite'] = 0;
 114  
 115          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d';
 116          $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&'));
 117      }
 118  
 119      function test_wl_useslash() {
 120          global $conf;
 121          $conf['useslash'] = 1;
 122          $conf['userewrite'] = 0;
 123  
 124          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d';
 125          $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&'));
 126      }
 127  
 128      function test_wl_useslash_rewrite1() {
 129          global $conf;
 130          $conf['useslash'] = 1;
 131          $conf['userewrite'] = 1;
 132  
 133          $expect = DOKU_BASE . 'some/?a=b&c=d';
 134          $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&'));
 135      }
 136  
 137      function test_wl_useslash_rewrite1_sub_page() {
 138          global $conf;
 139          $conf['useslash'] = 1;
 140          $conf['userewrite'] = 1;
 141  
 142          $expect = DOKU_BASE . 'some/one?a=b&c=d';
 143          $this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&'));
 144      }
 145  
 146      function test_wl_useslash_rewrite2() {
 147          global $conf;
 148          $conf['useslash'] = 1;
 149          $conf['userewrite'] = 2;
 150  
 151          $expect = DOKU_BASE . DOKU_SCRIPT . '/some/one?a=b&c=d';
 152          $this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&'));
 153      }
 154  
 155      function test_wl_empty_rev() {
 156          global $conf;
 157          $conf['useslash'] = 0;
 158          $conf['userewrite'] = 0;
 159  
 160          $args = array('a' => 'b', 'c' => 'd', 'rev' => '');
 161  
 162          $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d';
 163          $this->assertEquals($expect, wl('some:', $args));
 164      }
 165  
 166  
 167  
 168  }