summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2006-06-11 20:44:53 +0200
committerAndreas Gohr <andi@splitbrain.org>2006-06-11 20:44:53 +0200
commita6ef4796e22156364843a3b42bdd8f2dc78c0db5 (patch)
tree6e0677e925e8538b5a903d5456763ecd008e4395 /_test
parent54662a044eb6fd07b3246aed0d598d02bf7a1e4a (diff)
downloadrpg-a6ef4796e22156364843a3b42bdd8f2dc78c0db5.tar.gz
rpg-a6ef4796e22156364843a3b42bdd8f2dc78c0db5.tar.bz2
namespace linking first part
This patch adds namespace linking - formerly known as globalstart patch. It differs somewhat from the original patch. It is not implemented in getID() but in resolve_pageid(). It is now possible to link to a "default" file of a namespace ending the linkid with a colon: [[foo:bar:]] To which page the link links is dependent on the xistance of certain named files. For the above mentioned link [[foo:bar:]] the following pages are checked: foo:bar:start foo:bar:bar foo:bar The pages are checked in the order above whatever page is found first will be linked to. If no page is found foo:bar:start will be chosen. BTW: 'start' is the value configured in $conf['start'] Note: autoplural linking is not done for those links This is just the first patch. Several other locations of the code need to be adjusted to reflect this change and some testing needs to be done (first test cases are supplied within the patch bundle) Things that maybe need adjustment: - tpl_youarehere (hierarchical breadcrumbs) - tpl_button back - maybe others (search?) Patches would be welcome. The best aproach to fix things that don't work is probably making calls to resolve_pageid() instead of simple cleanID() calls. darcs-hash:20060611184453-7ad00-ba70b0fcf2cb64d4d4f0ce6bd6e437595cd947d3.gz
Diffstat (limited to '_test')
-rw-r--r--_test/cases/inc/pageutils_resolve_pageid.test.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/_test/cases/inc/pageutils_resolve_pageid.test.php b/_test/cases/inc/pageutils_resolve_pageid.test.php
new file mode 100644
index 000000000..2546bd2af
--- /dev/null
+++ b/_test/cases/inc/pageutils_resolve_pageid.test.php
@@ -0,0 +1,60 @@
+<?php
+require_once DOKU_INC.'inc/utf8.php';
+require_once DOKU_INC.'inc/pageutils.php';
+
+class init_resolve_pageid_test extends UnitTestCase {
+
+
+ function test1(){
+ global $conf;
+
+ // we test multiple cases here
+ // format: $ns, $page, $output
+ $tests = array();
+
+ // relative current in root
+ $tests[] = array('','page','page');
+ $tests[] = array('','.page','page');
+ $tests[] = array('','.:page','page');
+
+ // relative current in namespace
+ $tests[] = array('lev1:lev2','page','lev1:lev2:page');
+ $tests[] = array('lev1:lev2','.page','lev1:lev2:page');
+ $tests[] = array('lev1:lev2','.:page','lev1:lev2:page');
+
+ // relative upper in root
+ $tests[] = array('','..page','page');
+ $tests[] = array('','..:page','page');
+
+ // relative upper in namespace
+ $tests[] = array('lev1:lev2','..page','lev1:page');
+ $tests[] = array('lev1:lev2','..:page','lev1:page');
+ $tests[] = array('lev1:lev2','..:..:page','page');
+ $tests[] = array('lev1:lev2','..:..:..:page','page');
+
+ // strange and broken ones
+ $tests[] = array('lev1:lev2','....:....:page','lev1:lev2:page');
+ $tests[] = array('lev1:lev2','..:..:lev3:page','lev3:page');
+ $tests[] = array('lev1:lev2','..:..:lev3:..:page','page');
+ $tests[] = array('lev1:lev2','..:..:lev3:..:page:....:...','page');
+
+ // now some tests with existing and none existing files
+ $conf['start'] = 'start';
+
+ $tests[] = array('','.:','start');
+ $tests[] = array('foo','.:','foo:start');
+ $tests[] = array('','foo:','foo:start');
+ $tests[] = array('foo','foo:','foo:start');
+ $tests[] = array('foo','playground:','playground:playground');
+
+
+ foreach($tests as $test){
+ $page = $test[1];
+ resolve_pageid($test[0],$page,$foo);
+
+ $this->assertEqual($page,$test[2]);
+ }
+ }
+
+}
+//Setup VIM: ex: et ts=4 enc=utf-8 :