summaryrefslogtreecommitdiff
path: root/_test/tests/inc/changelog_getrevisions.test.php
diff options
context:
space:
mode:
authorKlap-in <klapinklapin@gmail.com>2013-07-20 02:31:50 +0200
committerKlap-in <klapinklapin@gmail.com>2013-07-20 02:31:50 +0200
commit51bd6f039e782dca456022514893aa80bd7c52b9 (patch)
treee5b365fe2c60ace5b2248c3948d6a1b1a40b32df /_test/tests/inc/changelog_getrevisions.test.php
parent3fc4f82997eb93a407074db4473cade1a76b6971 (diff)
downloadrpg-51bd6f039e782dca456022514893aa80bd7c52b9.tar.gz
rpg-51bd6f039e782dca456022514893aa80bd7c52b9.tar.bz2
Fixed file names of test classes
Diffstat (limited to '_test/tests/inc/changelog_getrevisions.test.php')
-rw-r--r--_test/tests/inc/changelog_getrevisions.test.php200
1 files changed, 200 insertions, 0 deletions
diff --git a/_test/tests/inc/changelog_getrevisions.test.php b/_test/tests/inc/changelog_getrevisions.test.php
new file mode 100644
index 000000000..a9be26dae
--- /dev/null
+++ b/_test/tests/inc/changelog_getrevisions.test.php
@@ -0,0 +1,200 @@
+<?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_getrevisions_test extends DokuWikiTest {
+
+ /**
+ * $first counts inclusive zero, after the current page
+ */
+ private $revsexpected = array(
+ 1374261194, //current page
+ 1371579614, 1368622240, // revisions, corresponds to respectively $first = 0 and 1
+ 1368622195, 1368622152,
+ 1368612599, 1368612506,
+ 1368609772, 1368575634,
+ 1363436892, 1362527164,
+ 1362527046, 1362526861, //10 and 11
+ 1362526767, 1362526167,
+ 1362526119, 1362526039,
+ 1362525926, 1362525899,
+ 1362525359, 1362525145,
+ 1362524799, 1361901536, //20 and 21
+ 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['nonexist']);
+ }
+ }
+
+ /**
+ * no nonexist.changes meta file available
+ */
+ function test_changemetadatanotexists() {
+ $first = 0;
+ $num = 1;
+ $id = 'nonexist';
+
+ $revs = getRevisions($id, $first, $num, $chunk_size = 8192, $media = false);
+ $revsexpected = array();
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * request first recentest revision
+ * (so skips first line which belongs to the current existing page)
+ */
+ function test_requestlastrev() {
+ $first = 0;
+ $num = 1;
+ $revsexpected = array($this->revsexpected[1]);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * request first recentest revision
+ * (so skips first line which belongs to the current existing page)
+ */
+ function test_requestonebutlastrev() {
+ $first = 1;
+ $num = 1;
+ $revsexpected = array($this->revsexpected[2]);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * request first recentest revision
+ * (so skips first line of current existing page)
+ */
+ function test_requestrevswithoffset() {
+ $first = 10;
+ $num = 5;
+ $revsexpected = array_slice($this->revsexpected, $first + 1, $num);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * first = -1 requests recentest logline, without skipping
+ */
+ function test_requestrecentestlogline() {
+ $first = -1;
+ $num = 1;
+ $revsexpected = array($this->revsexpected[0]);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * chunck size = 0 skips chuncked loading
+ */
+ function test_wholefile() {
+ $first = 0;
+ $num = 1000;
+ $revsexpected = array_slice($this->revsexpected, 1);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 0, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * Negative range returns no result
+ */
+ function test_negativenum() {
+ $first = 0;
+ $num = -10;
+ $revsexpected = array();
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * Negative range returns no result
+ */
+ function test_negativennumoffset() {
+ $first = 2;
+ $num = -10;
+ $revsexpected = array();
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * zero range returns no result
+ */
+ function test_zeronum() {
+ $first = 5;
+ $num = 0;
+ $revsexpected = array();
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 512, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * get oldest revisions
+ */
+ function test_requestlargeoffset() {
+ $first = 22;
+ $num = 50;
+ $revsexpected = array_slice($this->revsexpected, $first + 1);
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * request with too large offset and range
+ */
+ function test_requesttoolargenumberrevs() {
+ $first = 50;
+ $num = 50;
+ $revsexpected = array();
+
+ $revs = getRevisions($this->pageid, $first, $num, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+} \ No newline at end of file