diff options
Diffstat (limited to '_test')
-rw-r--r-- | _test/tests/inc/cache_use.test.php | 36 | ||||
-rw-r--r-- | _test/tests/inc/changelog_getRevisionsAround.test.php | 188 | ||||
-rw-r--r-- | _test/tests/inc/changelog_getrelativerevision.test.php | 418 | ||||
-rw-r--r-- | _test/tests/inc/changelog_getrevisioninfo.test.php | 56 | ||||
-rw-r--r-- | _test/tests/inc/changelog_getrevisions.test.php | 114 | ||||
-rw-r--r-- | _test/tests/inc/common_stripsourcemaps.test.php | 29 | ||||
-rw-r--r-- | _test/tests/inc/io_rmdir.test.php | 2 | ||||
-rw-r--r-- | _test/tests/inc/parser/parser_quotes.test.php | 131 | ||||
-rw-r--r-- | _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 53 | ||||
-rw-r--r-- | _test/tests/inc/parserutils_get_renderer.test.php | 4 | ||||
-rw-r--r-- | _test/tests/lib/exe/css_css_compress.test.php | 39 |
11 files changed, 968 insertions, 102 deletions
diff --git a/_test/tests/inc/cache_use.test.php b/_test/tests/inc/cache_use.test.php new file mode 100644 index 000000000..f5349df13 --- /dev/null +++ b/_test/tests/inc/cache_use.test.php @@ -0,0 +1,36 @@ +<?php + +/** + * Class cache_use_test + * + * Tests if caching can actually be used + */ +class cache_use_test extends DokuWikiTest { + /** @var cache_renderer $cache */ + private $cache; + + function setUp() { + global $ID; + parent::setUp(); + + $ID = 'cached'; + $file = wikiFN($ID); + + saveWikiText($ID, 'Content', 'Created'); + // set the modification time a second in the past in order to ensure that the cache is newer than the page + touch($file, time()-1); + + # Create cache. Note that the metadata cache is used as the xhtml cache triggers metadata rendering + $this->cache = new cache_renderer($ID, $file, 'metadata'); + $this->cache->storeCache('Test'); + } + + function test_use() { + $this->assertTrue($this->cache->useCache()); + } + + + function test_purge() { + $this->assertFalse($this->cache->useCache(array('purge' => true))); + } +}
\ No newline at end of file diff --git a/_test/tests/inc/changelog_getRevisionsAround.test.php b/_test/tests/inc/changelog_getRevisionsAround.test.php new file mode 100644 index 000000000..2a5cb849e --- /dev/null +++ b/_test/tests/inc/changelog_getRevisionsAround.test.php @@ -0,0 +1,188 @@ +<?php +/** + * Tests for requesting revisions of a page with getRevisions() + * + * This class uses the files: + * - data/pages/mailinglist.txt + * - data/meta/mailinglist.changes + */ +class changelog_getrevisionsaround_test extends DokuWikiTest { + + /** + * list of revisions in mailinglist.changes + */ + private $revsexpected = array( + 1374261194, //current page + 1371579614, 1368622240, + 1368622195, 1368622152, + 1368612599, 1368612506, + 1368609772, 1368575634, + 1363436892, 1362527164, + 1362527046, 1362526861, + 1362526767, 1362526167, + 1362526119, 1362526039, + 1362525926, 1362525899, + 1362525359, 1362525145, + 1362524799, 1361901536, + 1360110636 + ); + private $pageid = 'mailinglist'; + + function setup() { + parent::setup(); + global $cache_revinfo; + $cache =& $cache_revinfo; + if(isset($cache['nonexist'])) { + unset($cache['nonexist']); + } + if(isset($cache['mailinglist'])) { + unset($cache['mailinglist']); + } + } + + /** + * no nonexist.changes meta file available + */ + function test_changemetadatanotexists() { + $rev1 = 1362526767; + $rev2 = 1362527164; + $max = 50; + $id = 'nonexist'; + $revsexpected = array(array(), array()); + + $pagelog = new PageChangeLog($id, $chunk_size = 8192); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + } + + /** + * Surrounding revisions of rev1 and rev2 overlaps + */ + function test_request_overlapping() { + $rev1 = 1362526767; + $rev2 = 1362527164; + $max = 10; + $revsexpected = array( + array_slice($this->revsexpected, 8, 11), + array_slice($this->revsexpected, 5, 11) + ); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + } + + /** + * Surrounding revisions of rev1 and rev2 don't overlap. + */ + function test_request_non_overlapping() { + $rev1 = 1362525899; + $rev2 = 1368612599; + $max = 10; + $revsexpected = array( + array_slice($this->revsexpected, 13, 11), + array_slice($this->revsexpected, 0, 11) + ); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + } + + /** + * rev1 and rev2 are at start and end of the changelog. + * Should return still a number of revisions equal to max + */ + function test_request_first_last() { + $rev1 = 1360110636; + $rev2 = 1374261194; + $max = 10; + $revsexpected = array( + array_slice($this->revsexpected, 13, 11), + array_slice($this->revsexpected, 0, 11) + ); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + //todo: number of revisions on the left side is not (yet) completed until max number + $revsexpected = array( + array_slice($this->revsexpected, 18, 6), + array_slice($this->revsexpected, 0, 11) + ); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + } + + + /** + * Number of requested revisions is larger than available revisions, + * so returns whole log + */ + function test_request_wholelog() { + $rev1 = 1362525899; + $rev2 = 1368612599; + $max = 50; + $revsexpected = array($this->revsexpected, $this->revsexpected); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + } + + /** + * When rev1 > rev2, their order is changed + */ + function test_request_wrong_order_revs() { + $rev1 = 1362527164; + $rev2 = 1362526767; + $max = 10; + $revsexpected = array( + array_slice($this->revsexpected, 8, 11), + array_slice($this->revsexpected, 5, 11) + ); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + $revs = $pagelog->getRevisionsAround($rev1, $rev2, $max); + $this->assertEquals($revsexpected, $revs); + } + +}
\ No newline at end of file diff --git a/_test/tests/inc/changelog_getrelativerevision.test.php b/_test/tests/inc/changelog_getrelativerevision.test.php new file mode 100644 index 000000000..f9962066a --- /dev/null +++ b/_test/tests/inc/changelog_getrelativerevision.test.php @@ -0,0 +1,418 @@ +<?php + +/** + * Tests for requesting revisioninfo of a revision of a page with getRevisionInfo() + * + * This class uses the files: + * - data/pages/mailinglist.txt + * - data/meta/mailinglist.changes + */ +class changelog_getrelativerevision_test extends DokuWikiTest { + + private $logline = "1362525899 127.0.0.1 E mailinglist pubcie [Data entry] \n"; + private $pageid = 'mailinglist'; + + function setup() { + parent::setup(); + global $cache_revinfo; + $cache =& $cache_revinfo; + if(isset($cache['nonexist'])) { + unset($cache['nonexist']); + } + if(isset($cache['mailinglist'])) { + unset($cache['mailinglist']); + } + } + + /** + * no nonexist.changes meta file available + */ + function test_changemetadatanotexists() { + $rev = 1362525899; + $dir = 1; + $id = 'nonexist'; + $revsexpected = false; + + $pagelog = new PageChangeLog($id, $chunk_size = 8192); + $revs = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revsexpected, $revs); + } + + /** + * no nonexist.changes meta file available + */ + function test_nodirection() { + $rev = 1362525899; + $dir = 0; + $revsexpected = false; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revsexpected, $revs); + } + + /** + * start at exact current revision of mailinglist page + * + */ + function test_startatexactcurrentrev() { + $rev = 1385051947; + $dir = 1; + $revsexpectedpos = false; + $revsexpectedneg = 1374261194; + + //set a known timestamp + touch(wikiFN($this->pageid), $rev); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revsexpectedpos, $revs); + + $revs = $pagelog->getRelativeRevision($rev, -$dir); + $this->assertEquals($revsexpectedneg, $revs); + } + + /** + * start at exact last revision of mailinglist page + * + */ + function test_startatexactlastrev() { + $rev = 1360110636; + $dir = 1; + $revsexpectedpos = 1361901536; + $revsexpectedneg = false; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revsexpectedpos, $revs); + + $revs = $pagelog->getRelativeRevision($rev, -$dir); + $this->assertEquals($revsexpectedneg, $revs); + } + + /** + * start at exact one before last revision of mailinglist page + * + */ + function test_requestlastrevisions() { + $rev = 1361901536; + $dir = -1; + $revsexpectedlast = 1360110636; + $revsexpectedbeforelast = false; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revsexpectedlast, $revs); + + $revs = $pagelog->getRelativeRevision($rev, 2 * $dir); + $this->assertEquals($revsexpectedbeforelast, $revs); + } + + /** + * request existing rev and check cache + */ + function test_requestrev_checkcache() { + $rev = 1362525359; + $dir = 1; + $revexpected = 1362525899; + $infoexpected = parseChangelogLine($this->logline); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + //checked info returned from cache + $info = $pagelog->getRevisionInfo($revfound); + $this->assertEquals($infoexpected, $info); + } + + /** + * request existing rev + */ + function test_requestnextrev() { + $rev = 1362525899; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + + $dir = 1; + $revexpected = 1362525926; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + $dir = 2; + $revexpected = 1362526039; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + $dir = -1; + $revexpected = 1362525359; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + $dir = -2; + $revexpected = 1362525145; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * request existing rev with chucked reading + */ + function test_requestnextrev_chuncked() { + $rev = 1362525899; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + + $dir = 1; + $revexpected = 1362525926; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + $dir = 2; + $revexpected = 1362526039; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + $dir = -1; + $revexpected = 1362525359; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + $dir = -2; + $revexpected = 1362525145; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + + /** + * request existing rev with chucked reading, chunk size smaller than line length + */ + function test_requestnextrev_chunkshorterthanlines() { + $rev = 1362525899; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + + $dir = 1; + $revexpected = 1362525926; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + $dir = 2; + $revexpected = 1362526039; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + $dir = -1; + $revexpected = 1362525359; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + + $dir = -2; + $revexpected = 1362525145; + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * request existing rev + */ + function test_requestnextfifthrev() { + $rev = 1362525899; + $dir = 5; + $revexpected = 1362526767; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * request existing rev with chucked reading + */ + function test_requestnextfifthrev_chuncked() { + $rev = 1362525899; + $dir = 5; + $revexpected = 1362526767; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * request existing rev + */ + function test_requestprevrev() { + $rev = 1362525899; + $dir1 = -1; + $dir5 = -5; + $revexpected1 = 1362525359; + $revexpected5 = 1360110636; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound1 = $pagelog->getRelativeRevision($rev, $dir1); + $this->assertEquals($revexpected1, $revfound1); + + $revfound5 = $pagelog->getRelativeRevision($rev, $dir5); + $this->assertEquals($revexpected5, $revfound5); + } + + /** + * request existing rev with chucked reading + */ + function test_requestprevrev_chuncked() { + $rev = 1362525899; + $dir1 = -1; + $dir5 = -5; + $revexpected1 = 1362525359; + $revexpected5 = 1360110636; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revfound1 = $pagelog->getRelativeRevision($rev, $dir1); + $this->assertEquals($revexpected1, $revfound1); + + $revfound5 = $pagelog->getRelativeRevision($rev, $dir5); + $this->assertEquals($revexpected5, $revfound5); + } + + /** + * request after recentest version in changelog + */ + function test_requestrecentestlogline_next() { + $rev = 1374261194; + $dir = 1; + $revexpected = false; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * request after recentest version in changelog, with chuncked reading + */ + function test_requestrecentestlogline_next_chuncked() { + $rev = 1374261194; + $dir = 1; + $revexpected = false; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * request before current version + */ + function test_requestrecentestlogline_prev() { + $rev = 1374261194; + $dir = -1; + $revexpected = 1371579614; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * request before current version, with chuncked reading + */ + function test_requestrecentestlogline_prev_chuncked() { + $rev = 1374261194; + $dir = -1; + $revexpected = 1371579614; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * Request negative revision + * looks in positive direction, so it catches the oldest revision + */ + function test_negativerev_posdir() { + $rev = -10; + $dir = 1; + $revexpected = 1360110636; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * Request negative revision + * looks in negative direction, but there is nothing + */ + function test_negativerev_negdir() { + $rev = -10; + $dir = -1; + $revexpected = false; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * Start at non existing revision somewhere between existing revisions + */ + function test_startatnotexistingrev_next() { + $rev = 1362525890; + $dir = 1; + $revexpected = 1362525899; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + /** + * Start at non existing revision somewhere between existing revisions + */ + function test_startatnotexistingrev_prev() { + $rev = 1362525890; + $dir = -1; + $revexpected = 1362525359; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getRelativeRevision($rev, $dir); + $this->assertEquals($revexpected, $revfound); + } + + function test_iscurrentpagerevision() { + $rev = 1385051947; + $currentexpected = true; + + //set a known timestamp + touch(wikiFN($this->pageid), $rev); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $current = $pagelog->isCurrentRevision($rev); + $this->assertEquals($currentexpected, $current); + } + + function test_isnotcurrentpagerevision() { + $rev = 1385051947; + $not_current_rev = $rev - 1; + $currentexpected = false; + + //set a known timestamp + touch(wikiFN($this->pageid), $rev); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $current = $pagelog->isCurrentRevision($not_current_rev); + $this->assertEquals($currentexpected, $current); + } + + function test_notexistingcurrentpage() { + $rev = 1385051947; + $currentexpected = false; + + $pagelog = new PageChangeLog('nonexistingpage', $chunk_size = 8192); + $current = $pagelog->isCurrentRevision($rev); + $this->assertEquals($currentexpected, $current); + } +}
\ No newline at end of file diff --git a/_test/tests/inc/changelog_getrevisioninfo.test.php b/_test/tests/inc/changelog_getrevisioninfo.test.php index 9637d21c8..79b31d68e 100644 --- a/_test/tests/inc/changelog_getrevisioninfo.test.php +++ b/_test/tests/inc/changelog_getrevisioninfo.test.php @@ -21,7 +21,7 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest { unset($cache['nonexist']); } if(isset($cache['mailinglist'])) { - unset($cache['nonexist']); + unset($cache['mailinglist']); } } @@ -29,11 +29,12 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest { * no nonexist.changes meta file available */ function test_changemetadatanotexists() { - $rev = 1362525899; - $id = 'nonexist'; + $rev = 1362525899; + $id = 'nonexist'; $revsexpected = false; - $revs = getRevisionInfo($id, $rev, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($id, $chunk_size = 8192); + $revs = $pagelog->getRevisionInfo($rev); $this->assertEquals($revsexpected, $revs); } @@ -41,13 +42,14 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest { * request existing rev */ function test_requestrev() { - $rev = 1362525899; + $rev = 1362525899; $infoexpected = parseChangelogLine($this->logline); - $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $info = $pagelog->getRevisionInfo($rev); $this->assertEquals($infoexpected, $info); //returns cached value - $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false); + $info = $pagelog->getRevisionInfo($rev); $this->assertEquals($infoexpected, $info); } @@ -55,10 +57,23 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest { * request existing rev with chucked reading */ function test_requestrev_chuncked() { - $rev = 1362525899; + $rev = 1362525899; + $infoexpected = parseChangelogLine($this->logline); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $info = $pagelog->getRevisionInfo($rev); + $this->assertEquals($infoexpected, $info); + } + + /** + * request existing rev with chucked reading + */ + function test_requestrev_chunckedsmallerthanlinelength() { + $rev = 1362525899; $infoexpected = parseChangelogLine($this->logline); - $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 512, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + $info = $pagelog->getRevisionInfo($rev); $this->assertEquals($infoexpected, $info); } @@ -66,13 +81,14 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest { * request current version */ function test_requestrecentestlogline() { - $rev = 1374261194; + $rev = 1374261194; $infoexpected = parseChangelogLine($this->firstlogline); - $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $info = $pagelog->getRevisionInfo($rev); $this->assertEquals($infoexpected, $info); //returns cached value - $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false); + $info = $pagelog->getRevisionInfo($rev); $this->assertEquals($infoexpected, $info); } @@ -80,10 +96,11 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest { * request current version, with chuncked reading */ function test_requestrecentestlogline_chuncked() { - $rev = 1374261194; + $rev = 1374261194; $infoexpected = parseChangelogLine($this->firstlogline); - $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 512, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $info = $pagelog->getRevisionInfo($rev); $this->assertEquals($infoexpected, $info); } @@ -93,7 +110,8 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest { function test_negativerev() { $rev = -10; - $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $info = $pagelog->getRevisionInfo($rev); $this->assertEquals(false, $info); } @@ -103,7 +121,8 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest { function test_notexistingrev() { $rev = 1362525890; - $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $info = $pagelog->getRevisionInfo($rev); $this->assertEquals(false, $info); } @@ -111,10 +130,11 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest { * sometimes chuncksize is set to true */ function test_chuncksizetrue() { - $rev = 1362525899; + $rev = 1362525899; $infoexpected = parseChangelogLine($this->logline); - $info = getRevisionInfo($this->pageid, $rev, true); + $pagelog = new PageChangeLog($this->pageid, true); + $info = $pagelog->getRevisionInfo($rev); $this->assertEquals($infoexpected, $info); } }
\ No newline at end of file diff --git a/_test/tests/inc/changelog_getrevisions.test.php b/_test/tests/inc/changelog_getrevisions.test.php index a9be26dae..b247ce3d6 100644 --- a/_test/tests/inc/changelog_getrevisions.test.php +++ b/_test/tests/inc/changelog_getrevisions.test.php @@ -36,7 +36,7 @@ class changelog_getrevisions_test extends DokuWikiTest { unset($cache['nonexist']); } if(isset($cache['mailinglist'])) { - unset($cache['nonexist']); + unset($cache['mailinglist']); } } @@ -45,11 +45,12 @@ class changelog_getrevisions_test extends DokuWikiTest { */ function test_changemetadatanotexists() { $first = 0; - $num = 1; - $id = 'nonexist'; - - $revs = getRevisions($id, $first, $num, $chunk_size = 8192, $media = false); + $num = 1; + $id = 'nonexist'; $revsexpected = array(); + + $pagelog = new PageChangeLog($id, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -58,14 +59,20 @@ class changelog_getrevisions_test extends DokuWikiTest { * (so skips first line which belongs to the current existing page) */ function test_requestlastrev() { - $first = 0; - $num = 1; + $first = 0; + $num = 1; $revsexpected = array($this->revsexpected[1]); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -74,14 +81,20 @@ class changelog_getrevisions_test extends DokuWikiTest { * (so skips first line which belongs to the current existing page) */ function test_requestonebutlastrev() { - $first = 1; - $num = 1; + $first = 1; + $num = 1; $revsexpected = array($this->revsexpected[2]); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisions($first, $num); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -90,14 +103,20 @@ class changelog_getrevisions_test extends DokuWikiTest { * (so skips first line of current existing page) */ function test_requestrevswithoffset() { - $first = 10; - $num = 5; + $first = 10; + $num = 5; $revsexpected = array_slice($this->revsexpected, $first + 1, $num); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); + $this->assertEquals($revsexpected, $revs); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 20); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -105,14 +124,16 @@ class changelog_getrevisions_test extends DokuWikiTest { * first = -1 requests recentest logline, without skipping */ function test_requestrecentestlogline() { - $first = -1; - $num = 1; + $first = -1; + $num = 1; $revsexpected = array($this->revsexpected[0]); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -120,11 +141,12 @@ class changelog_getrevisions_test extends DokuWikiTest { * chunck size = 0 skips chuncked loading */ function test_wholefile() { - $first = 0; - $num = 1000; + $first = 0; + $num = 1000; $revsexpected = array_slice($this->revsexpected, 1); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 0, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 0); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -132,14 +154,16 @@ class changelog_getrevisions_test extends DokuWikiTest { * Negative range returns no result */ function test_negativenum() { - $first = 0; - $num = -10; + $first = 0; + $num = -10; $revsexpected = array(); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -147,14 +171,16 @@ class changelog_getrevisions_test extends DokuWikiTest { * Negative range returns no result */ function test_negativennumoffset() { - $first = 2; - $num = -10; + $first = 2; + $num = -10; $revsexpected = array(); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -162,14 +188,16 @@ class changelog_getrevisions_test extends DokuWikiTest { * zero range returns no result */ function test_zeronum() { - $first = 5; - $num = 0; + $first = 5; + $num = 0; $revsexpected = array(); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 512); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -177,11 +205,12 @@ class changelog_getrevisions_test extends DokuWikiTest { * get oldest revisions */ function test_requestlargeoffset() { - $first = 22; - $num = 50; + $first = 22; + $num = 50; $revsexpected = array_slice($this->revsexpected, $first + 1); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } @@ -189,11 +218,12 @@ class changelog_getrevisions_test extends DokuWikiTest { * request with too large offset and range */ function test_requesttoolargenumberrevs() { - $first = 50; - $num = 50; + $first = 50; + $num = 50; $revsexpected = array(); - $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false); + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getRevisions($first, $num); $this->assertEquals($revsexpected, $revs); } diff --git a/_test/tests/inc/common_stripsourcemaps.test.php b/_test/tests/inc/common_stripsourcemaps.test.php new file mode 100644 index 000000000..c6a915dcf --- /dev/null +++ b/_test/tests/inc/common_stripsourcemaps.test.php @@ -0,0 +1,29 @@ +<?php + +class common_stripsourcemaps_test extends DokuWikiTest { + + function test_all() { + + $text = <<<EOL +//@ sourceMappingURL=/foo/bar/xxx.map +//# sourceMappingURL=/foo/bar/xxx.map +/*@ sourceMappingURL=/foo/bar/xxx.map */ +/*# sourceMappingURL=/foo/bar/xxx.map */ +bang +EOL; + + $expect = <<<EOL +// +// +/**/ +/**/ +bang +EOL; + + stripsourcemaps($text); + + + $this->assertEquals($expect, $text); + } + +}
\ No newline at end of file diff --git a/_test/tests/inc/io_rmdir.test.php b/_test/tests/inc/io_rmdir.test.php index 3de57fa86..1c0eccb38 100644 --- a/_test/tests/inc/io_rmdir.test.php +++ b/_test/tests/inc/io_rmdir.test.php @@ -4,7 +4,7 @@ class io_rmdir_test extends DokuWikiTest { function test_nopes(){ // set up test dir - $dir = io_mktmpdir(); + $dir = realpath(io_mktmpdir()); $top = dirname($dir); $this->assertTrue($dir !== false); $this->assertTrue(is_dir($dir)); diff --git a/_test/tests/inc/parser/parser_quotes.test.php b/_test/tests/inc/parser/parser_quotes.test.php index b82328212..6f174ddae 100644 --- a/_test/tests/inc/parser/parser_quotes.test.php +++ b/_test/tests/inc/parser/parser_quotes.test.php @@ -10,8 +10,9 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { } function testSingleQuoteOpening() { + $raw = "Foo 'hello Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo 'hello Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -23,12 +24,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuoteOpeningSpecial() { + $raw = "Foo said:'hello Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo said:'hello Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -40,12 +42,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuoteClosing() { + $raw = "Foo hello' Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo hello' Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -57,12 +60,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuoteClosingSpecial() { + $raw = "Foo hello') Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo hello') Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -74,12 +78,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuotes() { + $raw = "Foo 'hello' Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo 'hello' Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -93,12 +98,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testApostrophe() { + $raw = "hey it's fine weather today"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("hey it's fine weather today"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -110,13 +116,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuotesSpecial() { + $raw = "Foo ('hello') Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo ('hello') Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -130,12 +137,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteOpening() { + $raw = 'Foo "hello Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo "hello Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -147,12 +155,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteOpeningSpecial() { + $raw = 'Foo said:"hello Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo said:"hello Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -164,12 +173,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteClosing() { + $raw = 'Foo hello" Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo hello" Bar'); + $this->H->status['doublequote'] = 1; + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -181,12 +192,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteClosingSpecial() { + $raw = 'Foo hello") Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo hello") Bar'); + $this->H->status['doublequote'] = 1; + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -198,12 +211,31 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); + } + function testDoubleQuoteClosingSpecial2() { + $raw = 'Foo hello") Bar'; + $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); + $this->H->status['doublequote'] = 0; + $this->P->parse($raw); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo hello')), + array('doublequoteopening',array()), + array('cdata',array(') Bar')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuotes() { + $raw = 'Foo "hello" Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo "hello" Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -217,12 +249,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuotesSpecial() { + $raw = 'Foo ("hello") Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo ("hello") Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -236,12 +269,54 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); + } + + function testDoubleQuotesEnclosingBrackets() { + $raw = 'Foo "{hello}" Bar'; + $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); + $this->P->parse($raw); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('doublequoteopening',array()), + array('cdata',array('{hello}')), + array('doublequoteclosing',array()), + array('cdata',array(' Bar')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext - '.$raw); + } + + function testDoubleQuotesEnclosingLink() { + $raw = 'Foo "[[www.domain.com]]" Bar'; + $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); + $this->P->parse($raw); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('doublequoteopening',array()), + array('cdata',array('[[www.domain.com]]')), + array('doublequoteclosing',array()), + array('cdata',array(' Bar')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw); } + function testAllQuotes() { + $raw = 'There was written "He thought \'It\'s a man\'s world\'".'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('There was written "He thought \'It\'s a man\'s world\'".'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -262,7 +337,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw); } } diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php new file mode 100644 index 000000000..7b43b6d62 --- /dev/null +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -0,0 +1,53 @@ +<?php + +require_once DOKU_INC . 'inc/parser/renderer.php'; + +/** + * Tests for Doku_Renderer::_resolveInterWiki() + */ +class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { + + function testDefaults() { + $Renderer = new Doku_Renderer(); + $Renderer->interwiki = getInterwiki(); + $Renderer->interwiki['scheme'] = '{SCHEME}://example.com'; + $Renderer->interwiki['withslash'] = '/test'; + $Renderer->interwiki['onlytext'] = ':onlytext{NAME}'; //with {URL} double urlencoded + $Renderer->interwiki['withquery'] = ':anyns:{NAME}?do=edit'; + + $tests = array( + // shortcut, reference and expected + array('wp', 'foo @+%/#txt', 'http://en.wikipedia.org/wiki/foo @+%/#txt'), + array('amazon', 'foo @+%/#txt', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/#txt'), + array('doku', 'foo @+%/#txt', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F#txt'), + array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090/path/naar/?query=foo%20%40%2B%25%2F'), + array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'), + //relative url + array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), + array('skype', 'foo @+%/#txt', 'skype:foo @+%/#txt'), + //dokuwiki id's + array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'), + array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=user:foo#txt'), + array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo&do=edit#txt') + ); + + foreach($tests as $test) { + $url = $Renderer->_resolveInterWiki($test[0], $test[1]); + + $this->assertEquals($test[2], $url); + } + } + + function testNonexisting() { + $Renderer = new Doku_Renderer(); + $Renderer->interwiki = getInterwiki(); + + $shortcut = 'nonexisting'; + $reference = 'foo @+%/'; + $url = $Renderer->_resolveInterWiki($shortcut, $reference); + $expected = 'http://www.google.com/search?q=foo%20%40%2B%25%2F&btnI=lucky'; + + $this->assertEquals($expected, $url); + } + +}
\ No newline at end of file diff --git a/_test/tests/inc/parserutils_get_renderer.test.php b/_test/tests/inc/parserutils_get_renderer.test.php index 69aeb3b19..0f373227d 100644 --- a/_test/tests/inc/parserutils_get_renderer.test.php +++ b/_test/tests/inc/parserutils_get_renderer.test.php @@ -45,10 +45,6 @@ class parserutils_get_renderer_test extends DokuWikiTest { } // test fallback fails - /** - * @expectedException PHPUnit_Framework_Error - * @expectedExceptionCode E_USER_WARNING - */ function test_p_get_renderer_fallback_fail() { global $conf; diff --git a/_test/tests/lib/exe/css_css_compress.test.php b/_test/tests/lib/exe/css_css_compress.test.php index a614ea2fd..f0eb17968 100644 --- a/_test/tests/lib/exe/css_css_compress.test.php +++ b/_test/tests/lib/exe/css_css_compress.test.php @@ -10,33 +10,47 @@ class css_css_compress_test extends DokuWikiTest { * line *test* * check */'; - $this->assertEquals(css_compress($text), ''); + $this->assertEquals('', css_compress($text)); } function test_mlcom2(){ $text = '#comment/* */ { color: lime; }'; - $this->assertEquals(css_compress($text), '#comment/* */{color:lime;}'); + $this->assertEquals('#comment/* */{color:lime;}', css_compress($text)); } function test_slcom1(){ $text = '// this is a comment'; - $this->assertEquals(css_compress($text), ''); + $this->assertEquals('', css_compress($text)); } function test_slcom2(){ $text = '#foo { color: lime; // another comment }'; - $this->assertEquals(css_compress($text), '#foo{color:lime;}'); + $this->assertEquals('#foo{color:lime;}', css_compress($text)); } function test_slcom3(){ $text = '#foo { - background-image: url(http://foo.bar/baz.jpg); + background-image: url(http://foo.bar/baz.jpg); // this is a comment }'; - $this->assertEquals(css_compress($text), '#foo{background-image:url(http://foo.bar/baz.jpg);}'); + $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); + } + + function test_slcom4(){ + $text = '#foo { + background-image: url(http://foo.bar/baz.jpg); background-image: url(http://foo.bar/baz.jpg); // this is a comment + }'; + $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); + } + + function test_slcom5(){ + $text = '#foo { + background-image: url(http://foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is all commented + }'; + $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); } function test_hack(){ @@ -44,7 +58,7 @@ class css_css_compress_test extends DokuWikiTest { /* \\*/ display: inline; /* */'; - $this->assertEquals(css_compress($text), '/* \\*/display:inline;/* */'); + $this->assertEquals('/* \\*/display:inline;/* */', css_compress($text)); } function test_hack2(){ @@ -54,12 +68,12 @@ class css_css_compress_test extends DokuWikiTest { height: 450px; } /**/'; - $this->assertEquals(css_compress($text), '/*\\*/* html .page{height:450px;}/**/'); + $this->assertEquals('/*\\*/* html .page{height:450px;}/**/', css_compress($text)); } function test_nl1(){ $text = "a{left:20px;\ntop:20px}"; - $this->assertEquals(css_compress($text), 'a{left:20px;top:20px}'); + $this->assertEquals('a{left:20px;top:20px}', css_compress($text)); } function test_shortening() { @@ -102,6 +116,13 @@ class css_css_compress_test extends DokuWikiTest { $this->assertEquals($expected, $input); } + function test_data() { + $input = 'list-style-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);'; + $expect = 'list-style-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);'; + + $this->assertEquals($expect, css_compress($input)); + } + } //Setup VIM: ex: et ts=4 : |