[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

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

   1  <?php
   2  
   3  class init_resolve_pageid_test extends DokuWikiTest {
   4  
   5  
   6      function test1(){
   7          global $conf;
   8  
   9          // we test multiple cases here
  10          // format: $ns, $page, $output
  11          $tests   = array();
  12  
  13          // relative current in root
  14          $tests[] = array('','page','page');
  15          $tests[] = array('','.page','page');
  16          $tests[] = array('','.:page','page');
  17  
  18          // relative current in namespace
  19          $tests[] = array('lev1:lev2','page','lev1:lev2:page');
  20          $tests[] = array('lev1:lev2','.page','lev1:lev2:page');
  21          $tests[] = array('lev1:lev2','.:page','lev1:lev2:page');
  22  
  23          // relative upper in root
  24          $tests[] = array('','..page','page');
  25          $tests[] = array('','..:page','page');
  26  
  27          // relative upper in namespace
  28          $tests[] = array('lev1:lev2','..page','lev1:page');
  29          $tests[] = array('lev1:lev2','..:page','lev1:page');
  30          $tests[] = array('lev1:lev2','..:..:page','page');
  31          $tests[] = array('lev1:lev2','..:..:..:page','page');
  32  
  33          // strange and broken ones
  34          $tests[] = array('lev1:lev2','....:....:page','lev1:lev2:page');
  35          $tests[] = array('lev1:lev2','..:..:lev3:page','lev3:page');
  36          $tests[] = array('lev1:lev2','..:..:lev3:..:page','page');
  37          $tests[] = array('lev1:lev2','..:..:lev3:..:page:....:...','page');
  38  
  39          // now some tests with existing and none existing files
  40          $conf['start'] = 'start';
  41  
  42          $tests[] = array('','.:','start');
  43          $tests[] = array('foo','.:','foo:start');
  44          $tests[] = array('','foo:','foo:start');
  45          $tests[] = array('foo','foo:','foo:start');
  46  
  47          // empty $page
  48          global $ID;
  49          $ID = 'my:space';
  50          $tests[] = array('my', '', 'my:space');
  51  
  52          foreach($tests as $test){
  53              $page = $test[1];
  54              resolve_pageid($test[0],$page,$foo);
  55  
  56              $this->assertEquals($page,$test[2]);
  57          }
  58      }
  59  
  60      /**
  61       * Empty page on homepage should resolve to start page
  62       */
  63      function test_resolve_pageid_empty_homepage() {
  64          global $ID;
  65          $ID = '';
  66          global $conf;
  67          $conf['start'] = 'someverystrangestartname';
  68  
  69          $ns = '';
  70          $page = '';
  71          $exist = true;
  72  
  73          resolve_pageid($ns, $page, $exist);
  74          $this->assertEquals($page, $conf['start']);
  75     }
  76  
  77  }
  78  //Setup VIM: ex: et ts=4 :