summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorKlap-in <klapinklapin@gmail.com>2013-07-20 01:28:07 +0200
committerKlap-in <klapinklapin@gmail.com>2013-07-20 01:31:32 +0200
commit3fc4f82997eb93a407074db4473cade1a76b6971 (patch)
tree35d57a415e02026ca2e3cdd55c60b78142f31ae3 /_test
parentfbd8067eeeb9f424981aad8b283e17f734c738c3 (diff)
downloadrpg-3fc4f82997eb93a407074db4473cade1a76b6971.tar.gz
rpg-3fc4f82997eb93a407074db4473cade1a76b6971.tar.bz2
Added tests for getRevisions and getRevisionInfo from page changelog
Diffstat (limited to '_test')
-rw-r--r--_test/data/meta/mailinglist.changes24
-rw-r--r--_test/data/pages/mailinglist.txt11
-rw-r--r--_test/tests/inc/changelog_getRevisionInfo.class.php120
-rw-r--r--_test/tests/inc/changelog_getRevisions.class.php200
4 files changed, 355 insertions, 0 deletions
diff --git a/_test/data/meta/mailinglist.changes b/_test/data/meta/mailinglist.changes
new file mode 100644
index 000000000..348f8258f
--- /dev/null
+++ b/_test/data/meta/mailinglist.changes
@@ -0,0 +1,24 @@
+1360110636 127.0.0.1 C mailinglist pubcie aangemaakt
+1361901536 127.0.0.1 E mailinglist pubcie
+1362524799 127.0.0.1 E mailinglist pubcie
+1362525145 127.0.0.1 E mailinglist pubcie
+1362525359 127.0.0.1 E mailinglist pubcie [Data entry]
+1362525899 127.0.0.1 E mailinglist pubcie [Data entry]
+1362525926 127.0.0.1 E mailinglist pubcie
+1362526039 127.0.0.1 E mailinglist pubcie [Data entry]
+1362526119 127.0.0.1 E mailinglist pubcie
+1362526167 127.0.0.1 E mailinglist pubcie [Data entry]
+1362526767 127.0.0.1 E mailinglist pubcie [Data entry]
+1362526861 127.0.0.1 E mailinglist pubcie [Data entry]
+1362527046 127.0.0.1 E mailinglist pubcie [Data entry]
+1362527164 127.0.0.1 E mailinglist pubcie [Data entry]
+1363436892 127.0.0.1 E mailinglist pubcie
+1368575634 127.0.0.1 E mailinglist pubcie
+1368609772 127.0.0.1 E mailinglist pubcie
+1368612506 127.0.0.1 E mailinglist pubcie [Data entry]
+1368612599 127.0.0.1 E mailinglist pubcie [Data entry]
+1368622152 127.0.0.1 E mailinglist pubcie [Data entry]
+1368622195 127.0.0.1 E mailinglist pubcie
+1368622240 127.0.0.1 E mailinglist pubcie [Data entry]
+1371579614 127.0.0.1 E mailinglist pubcie
+1374261194 127.0.0.1 E mailinglist pubcie
diff --git a/_test/data/pages/mailinglist.txt b/_test/data/pages/mailinglist.txt
new file mode 100644
index 000000000..3fbe91b67
--- /dev/null
+++ b/_test/data/pages/mailinglist.txt
@@ -0,0 +1,11 @@
+====== Mailing Lists ======
+
+[[DokuWiki]]'s development is coordinated through multiple Mailinglists hosted by [[http://www.freelists.org|freelists.org]].
+
+===== Using the lists =====
+
+First you should subscribe to one or several of the mailing lists presented below. After subscribing you can send emails to the list(s) by using the mailing list address stated in its description. If you rather want to use the mailing list through a news group interface, please read the section [[#News group interface]].
+
+If you are new to mailing lists in general, please read [[rfc>1855|RFC 1855 - Netiquette Guidelines]], especially the sections 3.1.1 and 3.1.2. Before you ask any questions you should also have a look at [[http://www.catb.org/~esr/faqs/smart-questions.html|How To Ask Questions The Smart Way]].
+
+:!: Please note that these documents are linked here solely for the purpose of information. Their respective authors have nothing do to with [[DokuWiki]] and in **no case** should you send email to them, asking for help related to [[DokuWiki]]!
diff --git a/_test/tests/inc/changelog_getRevisionInfo.class.php b/_test/tests/inc/changelog_getRevisionInfo.class.php
new file mode 100644
index 000000000..9637d21c8
--- /dev/null
+++ b/_test/tests/inc/changelog_getRevisionInfo.class.php
@@ -0,0 +1,120 @@
+<?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_getrevisionsinfo_test extends DokuWikiTest {
+
+ private $logline = "1362525899 127.0.0.1 E mailinglist pubcie [Data entry] \n";
+ private $firstlogline = "1374261194 127.0.0.1 E mailinglist pubcie \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['nonexist']);
+ }
+ }
+
+ /**
+ * no nonexist.changes meta file available
+ */
+ function test_changemetadatanotexists() {
+ $rev = 1362525899;
+ $id = 'nonexist';
+ $revsexpected = false;
+
+ $revs = getRevisionInfo($id, $rev, $chunk_size = 8192, $media = false);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * request existing rev
+ */
+ function test_requestrev() {
+ $rev = 1362525899;
+ $infoexpected = parseChangelogLine($this->logline);
+
+ $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false);
+ $this->assertEquals($infoexpected, $info);
+ //returns cached value
+ $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false);
+ $this->assertEquals($infoexpected, $info);
+ }
+
+ /**
+ * request existing rev with chucked reading
+ */
+ function test_requestrev_chuncked() {
+ $rev = 1362525899;
+ $infoexpected = parseChangelogLine($this->logline);
+
+ $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 512, $media = false);
+ $this->assertEquals($infoexpected, $info);
+ }
+
+ /**
+ * request current version
+ */
+ function test_requestrecentestlogline() {
+ $rev = 1374261194;
+ $infoexpected = parseChangelogLine($this->firstlogline);
+
+ $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false);
+ $this->assertEquals($infoexpected, $info);
+ //returns cached value
+ $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false);
+ $this->assertEquals($infoexpected, $info);
+ }
+
+ /**
+ * request current version, with chuncked reading
+ */
+ function test_requestrecentestlogline_chuncked() {
+ $rev = 1374261194;
+ $infoexpected = parseChangelogLine($this->firstlogline);
+
+ $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 512, $media = false);
+ $this->assertEquals($infoexpected, $info);
+ }
+
+ /**
+ * request negative revision
+ */
+ function test_negativerev() {
+ $rev = -10;
+
+ $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false);
+ $this->assertEquals(false, $info);
+ }
+
+ /**
+ * request non existing revision somewhere between existing revisions
+ */
+ function test_notexistingrev() {
+ $rev = 1362525890;
+
+ $info = getRevisionInfo($this->pageid, $rev, $chunk_size = 8192, $media = false);
+ $this->assertEquals(false, $info);
+ }
+
+ /**
+ * sometimes chuncksize is set to true
+ */
+ function test_chuncksizetrue() {
+ $rev = 1362525899;
+ $infoexpected = parseChangelogLine($this->logline);
+
+ $info = getRevisionInfo($this->pageid, $rev, true);
+ $this->assertEquals($infoexpected, $info);
+ }
+} \ No newline at end of file
diff --git a/_test/tests/inc/changelog_getRevisions.class.php b/_test/tests/inc/changelog_getRevisions.class.php
new file mode 100644
index 000000000..a9be26dae
--- /dev/null
+++ b/_test/tests/inc/changelog_getRevisions.class.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