summaryrefslogtreecommitdiff
path: root/_test/cases/inc/parser
diff options
context:
space:
mode:
authorMichal Rezler <rezlemic@fel.cvut.cz>2011-04-08 22:38:27 +0200
committerMichal Rezler <rezlemic@fel.cvut.cz>2011-04-08 22:38:27 +0200
commit5e8ffd73fd2a48f7a78e085ca7ed0dda73fb8af7 (patch)
tree7d6e598c52037249f707989a962e89481ca4afa2 /_test/cases/inc/parser
parentff482cae0f5a620704d845037d60ae13ab851410 (diff)
parentfda14ffc7c57c4451df9196e8125cd39b1d5c134 (diff)
downloadrpg-5e8ffd73fd2a48f7a78e085ca7ed0dda73fb8af7.tar.gz
rpg-5e8ffd73fd2a48f7a78e085ca7ed0dda73fb8af7.tar.bz2
Merge branch 'master' of git://github.com/splitbrain/dokuwiki
Diffstat (limited to '_test/cases/inc/parser')
-rw-r--r--_test/cases/inc/parser/xhtml_links.test.php195
1 files changed, 195 insertions, 0 deletions
diff --git a/_test/cases/inc/parser/xhtml_links.test.php b/_test/cases/inc/parser/xhtml_links.test.php
index 0ad96c793..74c39353e 100644
--- a/_test/cases/inc/parser/xhtml_links.test.php
+++ b/_test/cases/inc/parser/xhtml_links.test.php
@@ -1,6 +1,7 @@
<?php
if (!defined('DOKU_BASE')) define('DOKU_BASE','./');
require_once DOKU_INC.'inc/parser/xhtml.php';
+require_once DOKU_INC.'inc/pageutils.php';
class xhtml_links_test extends UnitTestCase {
@@ -41,4 +42,198 @@ class xhtml_links_test extends UnitTestCase {
$this->assertEqual($p->doc,$expect);
}
+ /**
+ * Produced by syntax like [[ ]]
+ */
+ function test_empty_internallink(){
+ $page = 'my:space';
+
+ global $ID;
+ $ID = $page;
+
+ global $conf;
+ $conf['start'] = 'start';
+
+ global $conf;
+ $conf['basedir'] = '/';
+ $conf['useheading'] = 0;
+ $conf['userewrite'] = 0;
+ $conf['useslash'] = 0;
+ $conf['canonical'] = 0;
+
+ $p = new Doku_Renderer_xhtml();
+ $p->internallink('');
+
+
+ if (page_exists($page)) {
+ $class = 'wikilink1';
+ $rel = '';
+ }
+ else {
+ $class = 'wikilink2';
+ $rel = ' rel="nofollow"';
+ }
+
+ $parts = split(':', $page);
+ $caption = $parts[count($parts)-1];
+
+ $expect = '<span class="curid"><a href="/./doku.php?id='.$page.'" class="'.$class.'" title="'.$page.'"'.$rel.'>'.$caption.'</a></span>';
+
+ $this->assertEqual($p->doc, $expect);
+ }
+
+ /**
+ * Produced by syntax like [[ |my caption]]
+ */
+ function test_empty_internallink_with_caption(){
+ $page = 'my:space';
+ $caption = 'my caption';
+
+ global $ID;
+ $ID = $page;
+
+ global $conf;
+ $conf['basedir'] = '/';
+ $conf['useheading'] = 0;
+ $conf['userewrite'] = 0;
+ $conf['useslash'] = 0;
+ $conf['canonical'] = 0;
+
+ $p = new Doku_Renderer_xhtml();
+ $p->internallink('', $caption);
+
+ if (page_exists($page)) {
+ $class = 'wikilink1';
+ $rel = '';
+ }
+ else {
+ $class = 'wikilink2';
+ $rel = ' rel="nofollow"';
+ }
+
+ $expect = '<span class="curid"><a href="/./doku.php?id='.$page.'" class="'.$class.'" title="'.$page.'"'.$rel.'>'.$caption.'</a></span>';
+
+ $this->assertEqual($p->doc, $expect);
+ }
+
+ /**
+ * Produced by syntax like [[?do=index]]
+ */
+ function test_empty_internallink_index(){
+ $page = 'my:space';
+
+ global $ID;
+ $ID = $page;
+
+ global $conf;
+ $conf['start'] = 'start';
+
+ global $conf;
+ $conf['basedir'] = '/';
+ $conf['useheading'] = 0;
+ $conf['userewrite'] = 0;
+ $conf['useslash'] = 0;
+ $conf['canonical'] = 0;
+
+ $p = new Doku_Renderer_xhtml();
+ $p->internallink('?do=index');
+
+ if (page_exists($page)) {
+ $class = 'wikilink1';
+ $rel = '';
+ }
+ else {
+ $class = 'wikilink2';
+ $rel = ' rel="nofollow"';
+ }
+
+ $parts = split(':', $page);
+ $caption = $parts[count($parts)-1];
+
+ $expect = '<span class="curid"><a href="/./doku.php?id='.$page.'&amp;do=index" class="'.$class.'" title="'.$page.'"'.$rel.'>'.$caption.'</a></span>';
+
+ $this->assertEqual($p->doc, $expect);
+ }
+
+ /**
+ * Produced by syntax like [[?do=index|my caption]]
+ */
+ function test_empty_internallink_index_with_caption(){
+ $page = 'my:space';
+ $caption = 'my caption';
+
+ global $ID;
+ $ID = $page;
+
+ global $conf;
+ $conf['basedir'] = '/';
+ $conf['useheading'] = 0;
+ $conf['userewrite'] = 0;
+ $conf['useslash'] = 0;
+ $conf['canonical'] = 0;
+
+ $p = new Doku_Renderer_xhtml();
+ $p->internallink('?do=index', $caption);
+
+ if (page_exists($page)) {
+ $class = 'wikilink1';
+ $rel = '';
+ }
+ else {
+ $class = 'wikilink2';
+ $rel = ' rel="nofollow"';
+ }
+
+ $expect = '<span class="curid"><a href="/./doku.php?id='.$page.'&amp;do=index" class="'.$class.'" title="'.$page.'"'.$rel.'>'.$caption.'</a></span>';
+
+ $this->assertEqual($p->doc, $expect);
+ }
+
+ /**
+ * Produced by syntax like [[#test]]
+ */
+ function test_empty_locallink(){
+ $page = 'my:spacex';
+ global $ID;
+ $ID = $page;
+
+ global $conf;
+ $conf['basedir'] = '/';
+ $conf['useheading'] = 0;
+ $conf['userewrite'] = 0;
+ $conf['useslash'] = 0;
+ $conf['canonical'] = 0;
+
+ $p = new Doku_Renderer_xhtml();
+ $p->locallink('test');
+
+ $expect = '<a href="#test" title="'.$page.' &crarr;" class="wikilink1">test</a>';
+
+ $this->assertEqual($p->doc, $expect);
+ }
+
+ /**
+ * Produced by syntax like [[#test|my caption]]
+ */
+ function test_empty_locallink_with_caption(){
+ $page = 'my:spacex';
+ $caption = 'my caption';
+
+ global $ID;
+ $ID = $page;
+
+ global $conf;
+ $conf['basedir'] = '/';
+ $conf['useheading'] = 0;
+ $conf['userewrite'] = 0;
+ $conf['useslash'] = 0;
+ $conf['canonical'] = 0;
+
+ $p = new Doku_Renderer_xhtml();
+ $p->locallink('test', $caption);
+
+ $expect = '<a href="#test" title="'.$caption.' &crarr;" class="wikilink1">'.$caption.'</a>';
+
+ $this->assertEqual($p->doc, $expect);
+ }
}