diff options
author | Andreas Gohr <andi@splitbrain.org> | 2014-09-29 18:29:20 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2014-09-29 18:29:20 +0200 |
commit | 17553fca1944b80c25826f2f71620bbf64e1a49b (patch) | |
tree | 45716d17564d0ea39cda4b0f6961b757e382c068 /_test | |
parent | 2f981761b3f5b7c8dcc53b8026d9fd3c499a7e1e (diff) | |
parent | 80d9f3ddb3a602960d23f1849c1ad6287c4f9d92 (diff) | |
download | rpg-17553fca1944b80c25826f2f71620bbf64e1a49b.tar.gz rpg-17553fca1944b80c25826f2f71620bbf64e1a49b.tar.bz2 |
Merge pull request #624 from lisps/revisions
date_at support
Diffstat (limited to '_test')
-rw-r--r-- | _test/tests/inc/changelog_getlastrevisionat.test.php | 127 | ||||
-rw-r--r-- | _test/tests/inc/common_ml.test.php | 11 | ||||
-rw-r--r-- | _test/tests/inc/common_wl.test.php | 11 |
3 files changed, 149 insertions, 0 deletions
diff --git a/_test/tests/inc/changelog_getlastrevisionat.test.php b/_test/tests/inc/changelog_getlastrevisionat.test.php new file mode 100644 index 000000000..84b185ce8 --- /dev/null +++ b/_test/tests/inc/changelog_getlastrevisionat.test.php @@ -0,0 +1,127 @@ +<?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_getlastrevisionat_test extends DokuWikiTest { + + 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; + $id = 'nonexist'; + $revsexpected = false; + + $pagelog = new PageChangeLog($id, $chunk_size = 8192); + $revs = $pagelog->getLastRevisionAt($rev); + $this->assertEquals($revsexpected, $revs); + } + + /** + * start at exact current revision of mailinglist page + * + */ + function test_startatexactcurrentrev() { + $rev = 1385051947; + $revsexpected = ''; + + //set a known timestamp + touch(wikiFN($this->pageid), $rev); + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getLastRevisionAt($rev); + $this->assertEquals($revsexpected, $revs); + + } + + /** + * test a future revision + * + */ + function test_futurerev() { + $rev = 1385051947; + $revsexpected = ''; + + //set a known timestamp + touch(wikiFN($this->pageid), $rev); + + $rev +=1; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getLastRevisionAt($rev); + $this->assertEquals($revsexpected, $revs); + + } + + /** + * start at exact last revision of mailinglist page + * + */ + function test_exactlastrev() { + $rev = 1360110636; + $revsexpected = 1360110636; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revs = $pagelog->getLastRevisionAt($rev); + $this->assertEquals($revsexpected, $revs); + } + + + /** + * Request not existing revision + * + */ + function test_olderrev() { + $rev = 1; + $revexpected = false; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getLastRevisionAt($rev); + $this->assertEquals($revexpected, $revfound); + } + + /** + * Start at non existing revision somewhere between existing revisions + */ + function test_notexistingrev() { + $rev = 1362525890; + $revexpected = 1362525359; + + $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192); + $revfound = $pagelog->getLastRevisionAt($rev); + $this->assertEquals($revexpected, $revfound); + } + + /** + * request nonexisting page + * + */ + function test_notexistingpage() { + $rev = 1385051947; + $currentexpected = false; + + $pagelog = new PageChangeLog('nonexistingpage', $chunk_size = 8192); + $current = $pagelog->getLastRevisionAt($rev); + $this->assertEquals($currentexpected, $current); + } +}
\ No newline at end of file diff --git a/_test/tests/inc/common_ml.test.php b/_test/tests/inc/common_ml.test.php index 415c0a88d..027dcaef2 100644 --- a/_test/tests/inc/common_ml.test.php +++ b/_test/tests/inc/common_ml.test.php @@ -146,4 +146,15 @@ class common_ml_test extends DokuWikiTest { $this->assertEquals($expect, ml($id, $args)); } + + function test_ml_empty_rev() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $args = array('a' => 'b', 'c' => 'd', 'rev' => ''); + + $expect = DOKU_BASE . $this->script . '?a=b&c=d&media=some:img.jpg'; + $this->assertEquals($expect, ml('some:img.jpg', $args)); + } } diff --git a/_test/tests/inc/common_wl.test.php b/_test/tests/inc/common_wl.test.php index 2e34dcae3..4bfde3f39 100644 --- a/_test/tests/inc/common_wl.test.php +++ b/_test/tests/inc/common_wl.test.php @@ -142,6 +142,17 @@ class common_wl_test extends DokuWikiTest { $expect = DOKU_BASE . DOKU_SCRIPT . '/some/one?a=b&c=d'; $this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&')); } + + function test_wl_empty_rev() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $args = array('a' => 'b', 'c' => 'd', 'rev' => ''); + + $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d'; + $this->assertEquals($expect, wl('some:', $args)); + } |