diff options
author | Kate Arzamastseva <pshns@ukr.net> | 2011-04-18 17:00:40 +0300 |
---|---|---|
committer | Kate Arzamastseva <pshns@ukr.net> | 2011-04-18 17:00:40 +0300 |
commit | f493983cbddc6c8c387a76bf3f6631853485162b (patch) | |
tree | 38cc53f0b287fde2a1b4426faa8a6fff1e56d769 /_test | |
parent | 058f1c3e98b1437a691cc77a36002dee1c41f007 (diff) | |
parent | 342e58c8c048bfd5f57f10bd88cee95aa2732e96 (diff) | |
download | rpg-f493983cbddc6c8c387a76bf3f6631853485162b.tar.gz rpg-f493983cbddc6c8c387a76bf3f6631853485162b.tar.bz2 |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to '_test')
-rw-r--r-- | _test/cases/inc/pageutils_getid.test.php | 2 | ||||
-rw-r--r-- | _test/cases/inc/pageutils_resolve_pageid.test.php | 22 | ||||
-rw-r--r-- | _test/cases/inc/parser/parser_links.test.php | 15 | ||||
-rw-r--r-- | _test/cases/inc/parser/xhtml_links.test.php | 195 | ||||
-rw-r--r-- | _test/cases/inc/safefn.test.php | 35 |
5 files changed, 257 insertions, 12 deletions
diff --git a/_test/cases/inc/pageutils_getid.test.php b/_test/cases/inc/pageutils_getid.test.php index 7fccc3a60..6eddeb5ea 100644 --- a/_test/cases/inc/pageutils_getid.test.php +++ b/_test/cases/inc/pageutils_getid.test.php @@ -99,7 +99,7 @@ class init_getID_test extends UnitTestCase { $_SERVER['PATH_TRANSLATED'] = '/var/www/index.html'; $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/'; - $this->assertEqual(getID(), 'start'); + $this->assertEqual(getID(), cleanID($conf['start'])); } } diff --git a/_test/cases/inc/pageutils_resolve_pageid.test.php b/_test/cases/inc/pageutils_resolve_pageid.test.php index d9ea89869..c65ed1866 100644 --- a/_test/cases/inc/pageutils_resolve_pageid.test.php +++ b/_test/cases/inc/pageutils_resolve_pageid.test.php @@ -50,6 +50,10 @@ class init_resolve_pageid_test extends UnitTestCase { $tests[] = array('foo','foo:','foo:start'); $tests[] = array('foo','playground:','playground:playground'); + // empty $page + global $ID; + $ID = 'my:space'; + $tests[] = array('my', '', 'my:space'); foreach($tests as $test){ $page = $test[1]; @@ -59,5 +63,23 @@ class init_resolve_pageid_test extends UnitTestCase { } } + /** + * Empty page on homepage should resolve to start page + */ + function test_resolve_pageid_empty_homepage() { + global $ID; + $ID = ''; + + global $conf; + $conf['start'] = 'someverystrangestartname'; + + $ns = ''; + $page = ''; + $exist = true; + + resolve_pageid($ns, $page, $exist); + $this->assertEqual($page, $conf['start']); + } + } //Setup VIM: ex: et ts=4 : diff --git a/_test/cases/inc/parser/parser_links.test.php b/_test/cases/inc/parser/parser_links.test.php index a4a8c5826..53871e110 100644 --- a/_test/cases/inc/parser/parser_links.test.php +++ b/_test/cases/inc/parser/parser_links.test.php @@ -221,6 +221,21 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser { $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); } + function testInternalLinkNoChar() { + $this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink()); + $this->P->parse("Foo [[]] Bar"); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('internallink',array('',NULL)), + array('cdata',array(' Bar')), + array('p_close',array()), + array('document_end',array()), + ); + $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); + } + function testInternalLinkNamespaceNoTitle() { $this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink()); $this->P->parse("Foo [[foo:bar]] Bar"); diff --git a/_test/cases/inc/parser/xhtml_links.test.php b/_test/cases/inc/parser/xhtml_links.test.php index 0ad96c793..a9a6dfdbc 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.'&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.'&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.' ↵" 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="'.$page.' ↵" class="wikilink1">'.$caption.'</a>'; + + $this->assertEqual($p->doc, $expect); + } } diff --git a/_test/cases/inc/safefn.test.php b/_test/cases/inc/safefn.test.php index c789875ba..1227e5578 100644 --- a/_test/cases/inc/safefn.test.php +++ b/_test/cases/inc/safefn.test.php @@ -10,19 +10,23 @@ class safeFN_test extends UnitTestCase { function test1(){ // we test multiple cases here - format: string, repl, additional, test $tests = array(); - $tests[] = array('äa.txt', '%5g.a.txt'); - $tests[] = array('ä.', '%5g..'); + $tests[] = array('äa.txt', '%5g]a.txt'); + $tests[] = array('ä.', '%5g].'); $tests[] = array('asciistring','asciistring'); $tests[] = array('ascii-_/.string','ascii-_/.string'); - $tests[] = array('AName','%x%1a.ame'); - $tests[] = array('A Name','%x%0%1a.ame'); - $tests[] = array('Another...Name','%x.nother...%1a.ame'); - $tests[] = array('Aß∂ƒName','%x%5b%6oy%aa%1a.ame'); - $tests[] = array('A%ß-∂_.ƒName','%x%%5b.-%6oy._.%aa%1a.ame'); - $tests[] = array('A%%ß-∂_.ƒName','%x%%%5b.-%6oy._.%aa%1a.ame'); - $tests[] = array('데이터도 함께 복원됩니다. 강력한','%zf4%13dg%15ao%zhg%0%164o%yig%0%11at%138w%zk9%zag%zb8..%0%xyt%10cl%164c.'); - $tests[] = array('совместимая','%td%ta%sy%t8%t1%td%te%t4%t8%sw%tr.'); - $tests[] = array('нехватка_файлового_пространства_на_сервере_p0-squid.some.domain.1270211897.txt.gz','%t9%t1%th%sy%sw%te%t6%sw._%tg%sw%t5%t7%ta%sy%ta%sz%ta._%tb%tc%ta%td%te%tc%sw%t9%td%te%sy%sw._%t9%sw._%td%t1%tc%sy%t1%tc%t1._p0-squid.some.domain.1270211897.txt.gz'); + $tests[] = array('AName','%x%1a]ame'); + $tests[] = array('A Name','%x%0%1a]ame'); + $tests[] = array('Another...Name','%x]nother...%1a]ame'); + $tests[] = array('Aß∂ƒName','%x%5b%6oy%aa%1a]ame'); + $tests[] = array('A%ß-∂_.ƒName','%x%%5b]-%6oy]_.%aa%1a]ame'); + $tests[] = array('A%%ß-∂_.ƒName','%x%%%5b]-%6oy]_.%aa%1a]ame'); + $tests[] = array('데이터도 함께 복원됩니다. 강력한','%zf4%13dg%15ao%zhg%0%164o%yig%0%11at%138w%zk9%zag%zb8].%0%xyt%10cl%164c]'); + $tests[] = array('совместимая','%td%ta%sy%t8%t1%td%te%t4%t8%sw%tr]'); + $tests[] = array('нехватка_файлового_пространства_на_сервере_p0-squid.some.domain.1270211897.txt.gz','%t9%t1%th%sy%sw%te%t6%sw]_%tg%sw%t5%t7%ta%sy%ta%sz%ta]_%tb%tc%ta%td%te%tc%sw%t9%td%te%sy%sw]_%t9%sw]_%td%t1%tc%sy%t1%tc%t1]_p0-squid.some.domain.1270211897.txt.gz'); + + $tests[] = array('name[1]','name[1]'); + $tests[] = array('Name[1]','%1a]ame[1]'); + $tests[] = array('Name[A]','%1a]ame[%x]]'); foreach($tests as $test){ list($utf8,$safe) = $test; @@ -30,6 +34,15 @@ class safeFN_test extends UnitTestCase { $this->assertEqual(SafeFN::decode($safe),$utf8); } } + + function test2(){ + $tests[] = array('совместимая','%td%ta%sy%t8%t1%td%te%t4%t8%sw%tr'); + + foreach($tests as $test){ + list($utf8,$safe) = $test; + $this->assertEqual(SafeFN::decode($safe),$utf8); + } + } } //Setup VIM: ex: et ts=4 : |