From fda14ffc7c57c4451df9196e8125cd39b1d5c134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Izidor=20Matu=C5=A1ov?= Date: Thu, 7 Apr 2011 19:44:54 +0200 Subject: Check if link exists and set right caption --- _test/cases/inc/parser/xhtml_links.test.php | 94 ++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 15 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/parser/xhtml_links.test.php b/_test/cases/inc/parser/xhtml_links.test.php index 11883dd9c..74c39353e 100644 --- a/_test/cases/inc/parser/xhtml_links.test.php +++ b/_test/cases/inc/parser/xhtml_links.test.php @@ -1,6 +1,7 @@ internallink(''); - $expect = 'start'; + + if (page_exists($page)) { + $class = 'wikilink1'; + $rel = ''; + } + else { + $class = 'wikilink2'; + $rel = ' rel="nofollow"'; + } + + $parts = split(':', $page); + $caption = $parts[count($parts)-1]; + + $expect = ''.$caption.''; $this->assertEqual($p->doc, $expect); } @@ -67,8 +86,11 @@ class xhtml_links_test extends UnitTestCase { * Produced by syntax like [[ |my caption]] */ function test_empty_internallink_with_caption(){ + $page = 'my:space'; + $caption = 'my caption'; + global $ID; - $ID = 'my:space'; + $ID = $page; global $conf; $conf['basedir'] = '/'; @@ -78,9 +100,18 @@ class xhtml_links_test extends UnitTestCase { $conf['canonical'] = 0; $p = new Doku_Renderer_xhtml(); - $p->internallink('', 'my caption'); + $p->internallink('', $caption); + + if (page_exists($page)) { + $class = 'wikilink1'; + $rel = ''; + } + else { + $class = 'wikilink2'; + $rel = ' rel="nofollow"'; + } - $expect = 'my caption'; + $expect = ''.$caption.''; $this->assertEqual($p->doc, $expect); } @@ -89,8 +120,13 @@ class xhtml_links_test extends UnitTestCase { * Produced by syntax like [[?do=index]] */ function test_empty_internallink_index(){ + $page = 'my:space'; + global $ID; - $ID = 'my:space'; + $ID = $page; + + global $conf; + $conf['start'] = 'start'; global $conf; $conf['basedir'] = '/'; @@ -102,7 +138,19 @@ class xhtml_links_test extends UnitTestCase { $p = new Doku_Renderer_xhtml(); $p->internallink('?do=index'); - $expect = 'start'; + if (page_exists($page)) { + $class = 'wikilink1'; + $rel = ''; + } + else { + $class = 'wikilink2'; + $rel = ' rel="nofollow"'; + } + + $parts = split(':', $page); + $caption = $parts[count($parts)-1]; + + $expect = ''.$caption.''; $this->assertEqual($p->doc, $expect); } @@ -111,8 +159,11 @@ class xhtml_links_test extends UnitTestCase { * Produced by syntax like [[?do=index|my caption]] */ function test_empty_internallink_index_with_caption(){ + $page = 'my:space'; + $caption = 'my caption'; + global $ID; - $ID = 'my:space'; + $ID = $page; global $conf; $conf['basedir'] = '/'; @@ -122,9 +173,18 @@ class xhtml_links_test extends UnitTestCase { $conf['canonical'] = 0; $p = new Doku_Renderer_xhtml(); - $p->internallink('?do=index', 'my caption'); + $p->internallink('?do=index', $caption); - $expect = 'my caption'; + if (page_exists($page)) { + $class = 'wikilink1'; + $rel = ''; + } + else { + $class = 'wikilink2'; + $rel = ' rel="nofollow"'; + } + + $expect = ''.$caption.''; $this->assertEqual($p->doc, $expect); } @@ -133,8 +193,9 @@ class xhtml_links_test extends UnitTestCase { * Produced by syntax like [[#test]] */ function test_empty_locallink(){ + $page = 'my:spacex'; global $ID; - $ID = 'my:space'; + $ID = $page; global $conf; $conf['basedir'] = '/'; @@ -146,7 +207,7 @@ class xhtml_links_test extends UnitTestCase { $p = new Doku_Renderer_xhtml(); $p->locallink('test'); - $expect = 'test'; + $expect = 'test'; $this->assertEqual($p->doc, $expect); } @@ -155,8 +216,11 @@ class xhtml_links_test extends UnitTestCase { * Produced by syntax like [[#test|my caption]] */ function test_empty_locallink_with_caption(){ + $page = 'my:spacex'; + $caption = 'my caption'; + global $ID; - $ID = 'my:space'; + $ID = $page; global $conf; $conf['basedir'] = '/'; @@ -166,9 +230,9 @@ class xhtml_links_test extends UnitTestCase { $conf['canonical'] = 0; $p = new Doku_Renderer_xhtml(); - $p->locallink('test', 'my caption'); + $p->locallink('test', $caption); - $expect = 'my caption'; + $expect = ''.$caption.''; $this->assertEqual($p->doc, $expect); } -- cgit v1.2.3