summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorGerry Weißbach <gerry.w@gammaproduction.de>2014-07-16 08:02:34 +0200
committerGerry Weißbach <gerry.w@gammaproduction.de>2014-07-16 08:02:34 +0200
commit0bd5b90b4c1294b3c9abc1977060f971dc2e2744 (patch)
treeac79a7402ffef718685f16dbba6692a0c9b5f458 /_test
parent1858e4d7685782550789fd8c228e55ae319bc37a (diff)
parent80679bafa1a5ed611bafc603afd0ae7b2b5954a7 (diff)
downloadrpg-0bd5b90b4c1294b3c9abc1977060f971dc2e2744.tar.gz
rpg-0bd5b90b4c1294b3c9abc1977060f971dc2e2744.tar.bz2
Merge remote-tracking branch 'splitbrain/master'
Diffstat (limited to '_test')
-rw-r--r--_test/README56
-rw-r--r--_test/core/DokuWikiTest.php3
-rw-r--r--_test/core/TestRequest.php9
-rw-r--r--_test/phpunit.xml5
-rw-r--r--_test/tests/inc/PassHash.test.php2
-rw-r--r--_test/tests/inc/auth_password.test.php2
-rw-r--r--_test/tests/inc/cache_use.test.php83
-rw-r--r--_test/tests/inc/changelog_getRevisionsAround.test.php188
-rw-r--r--_test/tests/inc/changelog_getrelativerevision.test.php418
-rw-r--r--_test/tests/inc/changelog_getrevisioninfo.test.php56
-rw-r--r--_test/tests/inc/changelog_getrevisions.test.php114
-rw-r--r--_test/tests/inc/cli_options.test.php56
-rw-r--r--_test/tests/inc/common_pageinfo.test.php8
-rw-r--r--_test/tests/inc/common_stripsourcemaps.test.php29
-rw-r--r--_test/tests/inc/httpclient_http.test.php153
-rw-r--r--_test/tests/inc/httpclient_http_proxy.test.php5
-rw-r--r--_test/tests/inc/httpclient_https_proxy.test.php15
-rw-r--r--_test/tests/inc/httpclient_mock.php46
-rw-r--r--_test/tests/inc/input.test.php19
-rw-r--r--_test/tests/inc/io_rmdir.test.php2
-rw-r--r--_test/tests/inc/mailer.test.php5
-rw-r--r--_test/tests/inc/parser/parser.inc.php2
-rw-r--r--_test/tests/inc/parser/parser_quotes.test.php131
-rw-r--r--_test/tests/inc/parser/parser_table.test.php299
-rw-r--r--_test/tests/inc/parser/renderer_resolveinterwiki.test.php53
-rw-r--r--_test/tests/inc/parserutils_get_renderer.test.php79
-rw-r--r--_test/tests/inc/tar.test.php50
-rw-r--r--_test/tests/inc/utf8_romanize.test.php2
-rw-r--r--_test/tests/inc/utf8_strtolower.test.php23
-rw-r--r--_test/tests/lib/exe/css_css_compress.test.php54
-rw-r--r--_test/tests/test/basic.test.php16
31 files changed, 1775 insertions, 208 deletions
diff --git a/_test/README b/_test/README
index 5220248b2..f0db2a550 100644
--- a/_test/README
+++ b/_test/README
@@ -9,35 +9,28 @@ This is the test suite to automatically test various parts of DokuWiki.
===== PHPUnit Installation ======
-==== via PEAR installer ====
+You can install phpunit through your distribution's package manager or simply
+download the newest phar file into the _test directory:
- pear config-set auto_discover 1
- pear install pear.phpunit.de/PHPUnit
-
-==== via Composer ====
-
-Include a composer.json file in your project, which can be as minimal as:
-
-<code>
-{
- "require-dev": {
- "phpunit/phpunit": "3.7.*"
- }
-}
-</code>
-
-==== via PHP archive (PHAR) ====
-
-Download http://pear.phpunit.de/get/phpunit.phar and make it executable on your system.
+ cd _test/
+ wget https://phar.phpunit.de/phpunit.phar
===== Running all tests =====
-Just change to the ''_test'' directory and run phpunit:
+Just change to the ''_test'' directory and run phpunit (depending on your install
+method):
cd _test/
phpunit
+or
+
+ cd _test/
+ php phpunit.phar
+
+===== Troubleshooting =====
+
PHPUnit will fail on some systems with a //headers already sent// error.
This is a known problem with PHPUnit, the error can be avoided by passing the
'--stderr' flag to phpunit:
@@ -46,8 +39,10 @@ This is a known problem with PHPUnit, the error can be avoided by passing the
On windows you may have to enable OpenSSL support for https tests.
Some of them point to httpclient_http.tests.php on the failure.
-To enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' to your ''windows\system32'' folder
-and add the following line to your php.ini in the extension section:
+To enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll''
+to your ''windows\system32'' folder and add the following line to your php.ini
+in the extension section:
+
<code ini>
extension=php_openssl.dll
</code>
@@ -56,13 +51,13 @@ extension=php_openssl.dll
You can run a single test file by providing it as an argument to phpunit:
- phpunit --stderr tests/inc/common_cleanText.test.php
+ phpunit tests/inc/common_cleanText.test.php
You can also use groups to exclude certain test from running. For example use
the following command to avoid long running test or tests accessing the
Internet.
- phpunit --stderr --exclude-group slow,internet
+ phpunit --exclude-group slow,internet
===== Create new Tests =====
@@ -71,23 +66,10 @@ folder. Please respect the folder structure and naming convention. Inside the
file, implement a class, extending 'DokuWikiTest'. Every method, starting
with 'test' will be called as a test (e.g. 'testIfThisIsValid');
-
===== TODO for the test framework =====
- * test cross platform compatibility: especially test windows
- * update http://www.dokuwiki.org/devel:unittesting
* optional: add helper methods to TestRequest for easy form submission
* createForm(), ...
* check PHP Unit test_helpers https://github.com/sebastianbergmann/php-test-helpers
-===== Migration Protocol =====
-
-The following tests were not migrated:
-
- * inc/indexer_idx_indexlengths (fs dependencies)
- * inc/mail_send (integration test)
- * inc/parser/parser_formatting
- * inc/parser/xhtml_htmlphp (runkit)
- * inc/parser/xhtml_links
-
diff --git a/_test/core/DokuWikiTest.php b/_test/core/DokuWikiTest.php
index 91eb5293b..f4521256a 100644
--- a/_test/core/DokuWikiTest.php
+++ b/_test/core/DokuWikiTest.php
@@ -115,5 +115,8 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
// reload language
$local = $conf['lang'];
trigger_event('INIT_LANG_LOAD', $local, 'init_lang', true);
+
+ global $INPUT;
+ $INPUT = new Input();
}
}
diff --git a/_test/core/TestRequest.php b/_test/core/TestRequest.php
index 0a54910ed..060e37d28 100644
--- a/_test/core/TestRequest.php
+++ b/_test/core/TestRequest.php
@@ -44,13 +44,18 @@ class TestRequest {
* @return TestResponse the resulting output of the request
*/
public function execute($uri='/doku.php') {
+ global $INPUT;
+ global $ID;
+ global $INFO;
+
// save old environment
$server = $_SERVER;
$session = $_SESSION;
$get = $_GET;
$post = $_POST;
$request = $_REQUEST;
-
+ $input = $INPUT;
+
// prepare the right URI
$this->setUri($uri);
@@ -74,6 +79,7 @@ class TestRequest {
// now execute dokuwiki and grep the output
header_remove();
ob_start('ob_start_callback');
+ $INPUT = new Input();
include(DOKU_INC.$this->script);
ob_end_flush();
@@ -89,6 +95,7 @@ class TestRequest {
$_GET = $get;
$_POST = $post;
$_REQUEST = $request;
+ $INPUT = $input;
return $response;
}
diff --git a/_test/phpunit.xml b/_test/phpunit.xml
index fc7dd8be0..25506b1ae 100644
--- a/_test/phpunit.xml
+++ b/_test/phpunit.xml
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="bootstrap.php"
- convertNoticesToExceptions="false">
+ convertNoticesToExceptions="false"
+ colors="true"
+ stderr="true"
+ >
<testsuites>
<testsuite name="DokuWiki Tests">
diff --git a/_test/tests/inc/PassHash.test.php b/_test/tests/inc/PassHash.test.php
index b6cb07090..1d34aa696 100644
--- a/_test/tests/inc/PassHash.test.php
+++ b/_test/tests/inc/PassHash.test.php
@@ -5,7 +5,7 @@
*
* most tests are in auth_password.test.php
*/
-class PassHash_test extends PHPUnit_Framework_TestCase {
+class PassHash_test extends DokuWikiTest {
function test_hmac(){
// known hashes taken from https://code.google.com/p/yii/issues/detail?id=1942
diff --git a/_test/tests/inc/auth_password.test.php b/_test/tests/inc/auth_password.test.php
index 27e03be60..07b9f5bb2 100644
--- a/_test/tests/inc/auth_password.test.php
+++ b/_test/tests/inc/auth_password.test.php
@@ -1,6 +1,6 @@
<?php
-class auth_password_test extends PHPUnit_Framework_TestCase {
+class auth_password_test extends DokuWikiTest {
// hashes for the password foo$method, using abcdefgh as salt
var $passes = array(
diff --git a/_test/tests/inc/cache_use.test.php b/_test/tests/inc/cache_use.test.php
new file mode 100644
index 000000000..02fe329de
--- /dev/null
+++ b/_test/tests/inc/cache_use.test.php
@@ -0,0 +1,83 @@
+<?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, $conf;
+ parent::setUp();
+
+ $ID = 'cached';
+ $file = wikiFN($ID);
+ $conf['cachetime'] = 0; // ensure the value is not -1, which disables caching
+
+ saveWikiText($ID, 'Content', 'Created');
+
+ $this->cache = new cache_renderer($ID, $file, 'xhtml');
+ $this->cache->storeCache('Test');
+
+ // set the modification times explicitly (overcome Issue #694)
+ $time = time();
+ touch($file, $time-1);
+ touch($this->cache->cache, $time);
+ }
+
+ function test_use() {
+ $this->assertTrue($this->cache->useCache());
+ }
+
+ /**
+ * In all the following tests the cache should not be usable
+ * as such, they are meaningless if test_use didn't pass.
+ *
+ * @depends test_use
+ */
+ function test_purge() {
+ /* @var Input $INPUT */
+ global $INPUT;
+ $INPUT->set('purge',1);
+
+ $this->assertFalse($this->cache->useCache());
+ $this->assertNotEmpty($this->cache->depends['purge']);
+ }
+
+ /**
+ * @depends test_use
+ */
+ function test_filedependency() {
+ // give the dependent src file the same mtime as the cache
+ touch($this->cache->file, filemtime($this->cache->cache));
+ $this->assertFalse($this->cache->useCache());
+ }
+
+ /**
+ * @depends test_use
+ */
+ function test_age() {
+ // need to age both our source file & the cache
+ $age = 10;
+ $time = time() - $age - 1; // older than age
+
+ touch($this->cache->file, $time - 1);
+ touch($this->cache->cache, $time);
+
+ $this->assertFalse($this->cache->useCache(array('age' => $age)));
+ }
+
+ /**
+ * @depends test_use
+ */
+ function test_confnocaching() {
+ global $conf;
+ $conf['cachetime'] = -1; // disables renderer caching
+
+ $this->assertFalse($this->cache->useCache());
+ $this->assertNotEmpty($this->cache->_nocache);
+ }
+} \ 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/cli_options.test.php b/_test/tests/inc/cli_options.test.php
new file mode 100644
index 000000000..ab03ee29b
--- /dev/null
+++ b/_test/tests/inc/cli_options.test.php
@@ -0,0 +1,56 @@
+<?php
+
+class cli_options extends DokuWikiTest {
+
+ function test_simpleshort() {
+ $options = new DokuCLI_Options();
+ $options->registerOption('exclude', 'exclude files', 'x', 'file');
+
+ $options->args = array('-x', 'foo', 'bang');
+ $options->parseOptions();
+
+ $this->assertEquals('foo', $options->getOpt('exclude'));
+ $this->assertEquals(array('bang'), $options->args);
+ $this->assertFalse($options->getOpt('nothing'));
+ }
+
+ function test_simplelong1() {
+ $options = new DokuCLI_Options();
+ $options->registerOption('exclude', 'exclude files', 'x', 'file');
+
+ $options->args = array('--exclude', 'foo', 'bang');
+ $options->parseOptions();
+
+ $this->assertEquals('foo', $options->getOpt('exclude'));
+ $this->assertEquals(array('bang'), $options->args);
+ $this->assertFalse($options->getOpt('nothing'));
+ }
+
+ function test_simplelong2() {
+ $options = new DokuCLI_Options();
+ $options->registerOption('exclude', 'exclude files', 'x', 'file');
+
+ $options->args = array('--exclude=foo', 'bang');
+ $options->parseOptions();
+
+ $this->assertEquals('foo', $options->getOpt('exclude'));
+ $this->assertEquals(array('bang'), $options->args);
+ $this->assertFalse($options->getOpt('nothing'));
+ }
+
+ function test_complex() {
+ $options = new DokuCLI_Options();
+
+ $options->registerOption('plugins', 'run on plugins only', 'p');
+ $options->registerCommand('status', 'display status info');
+ $options->registerOption('long', 'display long lines', 'l', false, 'status');
+
+ $options->args = array('-p', 'status', '--long', 'foo');
+ $options->parseOptions();
+
+ $this->assertEquals('status', $options->getCmd());
+ $this->assertTrue($options->getOpt('plugins'));
+ $this->assertTrue($options->getOpt('long'));
+ $this->assertEquals(array('foo'), $options->args);
+ }
+} \ No newline at end of file
diff --git a/_test/tests/inc/common_pageinfo.test.php b/_test/tests/inc/common_pageinfo.test.php
index 0a1ea0a8f..2b230d9ce 100644
--- a/_test/tests/inc/common_pageinfo.test.php
+++ b/_test/tests/inc/common_pageinfo.test.php
@@ -38,6 +38,7 @@ class common_pageinfo_test extends DokuWikiTest {
$info['writable'] = true;
$info['editable'] = true;
$info['lastmod'] = false;
+ $info['currentrev'] = false;
$info['meta'] = array();
$info['ip'] = null;
$info['user'] = null;
@@ -77,6 +78,7 @@ class common_pageinfo_test extends DokuWikiTest {
$info['filepath'] = $filename;
$info['exists'] = true;
$info['lastmod'] = $rev;
+ $info['currentrev'] = $rev;
$info['meta'] = p_get_metadata($ID);
$this->assertEquals($info, pageinfo());
@@ -101,6 +103,7 @@ class common_pageinfo_test extends DokuWikiTest {
$info['filepath'] = $filename;
$info['exists'] = true;
$info['lastmod'] = $rev;
+ $info['currentrev'] = $rev;
$info['meta'] = p_get_metadata($ID);
$info['rev'] = '';
@@ -131,6 +134,7 @@ class common_pageinfo_test extends DokuWikiTest {
$info['namespace'] = 'wiki';
$info['meta'] = p_get_metadata($ID);
$info['rev'] = $REV;
+ $info['currentrev'] = $rev;
$info['filepath'] = str_replace('pages','attic',substr($filename,0,-3).$REV.'.txt.gz');
$this->assertEquals($info, pageinfo());
@@ -153,6 +157,7 @@ class common_pageinfo_test extends DokuWikiTest {
$info['namespace'] = 'wiki';
$info['exists'] = true;
$info['lastmod'] = $rev;
+ $info['currentrev'] = $rev;
$info['meta'] = p_get_metadata($ID);
$info['filepath'] = $filename;
@@ -197,6 +202,7 @@ class common_pageinfo_test extends DokuWikiTest {
$info['filepath'] = $filename;
$info['exists'] = true;
$info['lastmod'] = $rev;
+ $info['currentrev'] = $rev;
$info['meta'] = p_get_metadata($ID); // need $INFO set correctly for addLogEntry()
global $INFO;
@@ -226,6 +232,7 @@ class common_pageinfo_test extends DokuWikiTest {
touch($filename,$now);
$info['lastmod'] = $now;
+ $info['currentrev'] = $now;
$info['meta']['last_change'] = false;
$info['ip'] = null;
$info['user'] = null;
@@ -251,6 +258,7 @@ class common_pageinfo_test extends DokuWikiTest {
$info['filepath'] = $filename;
$info['exists'] = true;
$info['lastmod'] = $rev;
+ $info['currentrev'] = $rev;
$info['meta'] = p_get_metadata($ID);
// setup a draft, make it more recent than the current page
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/httpclient_http.test.php b/_test/tests/inc/httpclient_http.test.php
index 43dd4478f..3446e1184 100644
--- a/_test/tests/inc/httpclient_http.test.php
+++ b/_test/tests/inc/httpclient_http.test.php
@@ -1,15 +1,22 @@
<?php
+require_once (__DIR__ . '/httpclient_mock.php');
+
class httpclient_http_test extends DokuWikiTest {
protected $server = 'http://httpbin.org';
+
/**
* @group internet
*/
function test_simpleget(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->get($this->server.'/get?foo=bar');
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('args',$resp);
@@ -20,9 +27,13 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_dget(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->dget($this->server.'/get',array('foo'=>'bar'));
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('args',$resp);
@@ -33,9 +44,13 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_gzip(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->get($this->server.'/gzip');
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('gzipped',$resp);
@@ -46,9 +61,13 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_simplepost(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->post($this->server.'/post',array('foo'=>'bar'));
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('form',$resp);
@@ -59,9 +78,13 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_redirect(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->get($this->server.'/redirect/3');
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('url',$resp);
@@ -72,9 +95,13 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_relredirect(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->get($this->server.'/relative-redirect/3');
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('url',$resp);
@@ -85,9 +112,13 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_redirectfail(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->get($this->server.'/redirect/5');
- $this->assertTrue($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertTrue($data === false, 'HTTP response '.$http->error);
$this->assertEquals('Maximum number of redirects exceeded',$http->error);
}
@@ -95,11 +126,19 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_cookies(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$http->get($this->server.'/cookies/set/foo/bar');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
$this->assertEquals(array('foo' => 'bar'), $http->cookies);
$data = $http->get($this->server.'/cookies');
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('cookies',$resp);
@@ -110,9 +149,13 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_teapot(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->get($this->server.'/status/418');
- $this->assertTrue($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertTrue($data === false, 'HTTP response '.$http->error);
$this->assertEquals(418,$http->status);
}
@@ -120,18 +163,26 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_maxbody(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$http->max_bodysize = 250;
// this should abort completely
$data = $http->get($this->server.'/stream/30');
- $this->assertTrue($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertTrue($data === false, 'HTTP response '.$http->error);
// this should read just the needed bytes
$http->max_bodysize_abort = false;
$http->keep_alive = false;
$data = $http->get($this->server.'/stream/30');
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
/* should read no more than max_bodysize+1 */
$this->assertLessThanOrEqual(251,strlen($data));
}
@@ -140,24 +191,36 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_maxbodyok(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$http->max_bodysize = 500*1024;
$data = $http->get($this->server.'/stream/5');
- $this->assertTrue($data !== false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertTrue($data !== false, 'HTTP response '.$http->error);
$http->max_bodysize_abort = false;
$data = $http->get($this->server.'/stream/5');
- $this->assertTrue($data !== false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertTrue($data !== false, 'HTTP response '.$http->error);
}
/**
* @group internet
*/
function test_basicauth(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$http->user = 'user';
$http->pass = 'pass';
$data = $http->get($this->server.'/basic-auth/user/pass');
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertEquals(array('authenticated'=>true,'user'=>'user'), $resp);
@@ -167,11 +230,15 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_basicauthfail(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$http->user = 'user';
$http->pass = 'invalid';
$data = $http->get($this->server.'/basic-auth/user/pass');
- $this->assertTrue($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertTrue($data === false, 'HTTP response '.$http->error);
$this->assertEquals(401,$http->status);
}
@@ -179,10 +246,10 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_timeout(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$http->timeout = 5;
$data = $http->get($this->server.'/delay/10');
- $this->assertTrue($data === false, 'HTTP response');
+ $this->assertTrue($data === false, 'HTTP response '.$http->error);
$this->assertEquals(-100,$http->status);
}
@@ -190,9 +257,13 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_headers(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->get($this->server.'/response-headers?baz=&foo=bar');
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('baz',$http->resp_headers);
@@ -204,9 +275,13 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_chunked(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->get('http://whoopdedo.org/cgi-bin/chunked/2550');
- $this->assertFalse($data === false, 'HTTP response');
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertFalse($data === false, 'HTTP response '.$http->error);
$this->assertEquals(2550,strlen($data));
}
@@ -216,13 +291,17 @@ class httpclient_http_test extends DokuWikiTest {
* @group internet
*/
function test_wikimatrix(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
$data = $http->get('http://www.wikimatrix.org/cfeed/dokuwiki/-/-');
- $this->assertTrue($data !== false, $http->error);
+ if($http->noconnection()) {
+ $this->markTestSkipped('connection timed out');
+ return;
+ }
+ $this->assertTrue($data !== false, 'HTTP response '.$http->error);
}
function test_postencode(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
// check simple data
diff --git a/_test/tests/inc/httpclient_http_proxy.test.php b/_test/tests/inc/httpclient_http_proxy.test.php
index 4aa039fcc..c44dc7ed7 100644
--- a/_test/tests/inc/httpclient_http_proxy.test.php
+++ b/_test/tests/inc/httpclient_http_proxy.test.php
@@ -1,5 +1,7 @@
<?php
+require_once (__DIR__ . '/httpclient_mock.php');
+
class httpclient_http_proxy_test extends DokuWikiTest {
protected $url = 'http://test.dokuwiki.org/README';
@@ -7,7 +9,7 @@ class httpclient_http_proxy_test extends DokuWikiTest {
* @group internet
*/
function test_simpleget(){
- $http = new HTTPClient();
+ $http = new HTTPMockClient();
// proxy provided by Andrwe Lord Weber <dokuwiki@andrwe.org>
$http->proxy_host = 'proxy.andrwe.org';
$http->proxy_port = 8080;
@@ -16,5 +18,4 @@ class httpclient_http_proxy_test extends DokuWikiTest {
$this->assertFalse($data === false, 'HTTP response '.$http->error);
$this->assertTrue(strpos($data,'DokuWiki') !== false, 'response content');
}
-
} \ No newline at end of file
diff --git a/_test/tests/inc/httpclient_https_proxy.test.php b/_test/tests/inc/httpclient_https_proxy.test.php
index aca3b3be2..9402e91af 100644
--- a/_test/tests/inc/httpclient_https_proxy.test.php
+++ b/_test/tests/inc/httpclient_https_proxy.test.php
@@ -12,4 +12,19 @@ class httpclient_https_proxy_test extends httpclient_http_proxy_test {
}
parent::setUp();
}
+
+ /**
+ * @group internet
+ */
+ function test_connectfail(){
+ $http = new HTTPMockClient();
+ // proxy provided by Andrwe Lord Weber <dokuwiki@andrwe.org>
+ $http->proxy_host = 'proxy.andrwe.org';
+ $http->proxy_port = 8080;
+
+ // the proxy accepts connections to dokuwiki.org only - the connect call should fail
+ $data = $http->get('https://www.google.com');
+ $this->assertFalse($data);
+ $this->assertEquals(-150, $http->status);
+ }
} \ No newline at end of file
diff --git a/_test/tests/inc/httpclient_mock.php b/_test/tests/inc/httpclient_mock.php
new file mode 100644
index 000000000..038045c8b
--- /dev/null
+++ b/_test/tests/inc/httpclient_mock.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Class HTTPMockClient
+ *
+ * Does not really mock the client, it still does real connections but will retry failed connections
+ * to work around shaky connectivity.
+ */
+class HTTPMockClient extends HTTPClient {
+ protected $tries;
+
+ /**
+ * Sets shorter timeout
+ */
+ function __construct() {
+ parent::__construct();
+ $this->timeout = 8; // slightly faster timeouts
+ }
+
+ /**
+ * Returns true if the connection timed out
+ *
+ * @return bool
+ */
+ function noconnection() {
+ return ($this->tries === 0);
+ }
+
+ /**
+ * Retries sending the request multiple times
+ *
+ * @param string $url
+ * @param string $data
+ * @param string $method
+ * @return bool
+ */
+ function sendRequest($url, $data = '', $method = 'GET') {
+ $this->tries = 2; // configures the number of retries
+ $return = false;
+ while($this->tries) {
+ $return = parent::sendRequest($url, $data, $method);
+ if($this->status != -100) break;
+ $this->tries--;
+ }
+ return $return;
+ }
+} \ No newline at end of file
diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php
index 59b5ea4b9..cec0b80f6 100644
--- a/_test/tests/inc/input.test.php
+++ b/_test/tests/inc/input.test.php
@@ -214,6 +214,25 @@ class input_test extends DokuWikiTest {
$this->assertEquals('bla',$test);
}
+ public function test_valid(){
+ $_REQUEST = $this->data;
+ $_POST = $this->data;
+ $_GET = $this->data;
+ $INPUT = new Input();
+
+ $valids = array(17, 'foo');
+ $this->assertSame(null, $INPUT->valid('nope', $valids));
+ $this->assertSame('bang', $INPUT->valid('nope', $valids, 'bang'));
+ $this->assertSame(17, $INPUT->valid('int', $valids));
+ $this->assertSame('foo', $INPUT->valid('string', $valids));
+ $this->assertSame(null, $INPUT->valid('array', $valids));
+
+ $valids = array(true);
+ $this->assertSame(true, $INPUT->valid('string', $valids));
+ $this->assertSame(true, $INPUT->valid('one', $valids));
+ $this->assertSame(null, $INPUT->valid('zero', $valids));
+ }
+
public function test_extract(){
$_REQUEST = $this->data;
$_POST = $this->data;
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/mailer.test.php b/_test/tests/inc/mailer.test.php
index 4541d9906..50d282864 100644
--- a/_test/tests/inc/mailer.test.php
+++ b/_test/tests/inc/mailer.test.php
@@ -191,7 +191,10 @@ class mailer_test extends DokuWikiTest {
// ask message lint if it is okay
$html = new HTTPClient();
$results = $html->post('http://tools.ietf.org/tools/msglint/msglint', array('msg'=>$msg));
- $this->assertTrue($results !== false);
+ if($results === false) {
+ $this->markTestSkipped('no response from validator');
+ return;
+ }
// parse the result lines
$lines = explode("\n", $results);
diff --git a/_test/tests/inc/parser/parser.inc.php b/_test/tests/inc/parser/parser.inc.php
index 61f15678b..f1207b119 100644
--- a/_test/tests/inc/parser/parser.inc.php
+++ b/_test/tests/inc/parser/parser.inc.php
@@ -3,7 +3,7 @@
require_once DOKU_INC . 'inc/parser/parser.php';
require_once DOKU_INC . 'inc/parser/handler.php';
-abstract class TestOfDoku_Parser extends PHPUnit_Framework_TestCase {
+abstract class TestOfDoku_Parser extends DokuWikiTest {
var $P;
var $H;
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/parser_table.test.php b/_test/tests/inc/parser/parser_table.test.php
index bc19ebff9..a9b4e284c 100644
--- a/_test/tests/inc/parser/parser_table.test.php
+++ b/_test/tests/inc/parser/parser_table.test.php
@@ -44,7 +44,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testTableWinEOL() {
@@ -84,7 +84,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testEmptyTable() {
@@ -109,7 +109,7 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testTableHeaders() {
@@ -143,7 +143,152 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
+ function testTableHead() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X ^ Y ^ Z ^
+| x | y | z |
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 2, 6)),
+ array('tablethead_open',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Y ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablethead_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' x ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' y ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' z ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(33)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
+ function testTableHeadOneRowTable() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X ^ Y ^ Z ^
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 1, 6)),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Y ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(19)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
+ function testTableHeadMultiline() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X1 ^ Y1 ^ Z1 ^
+^ X2 ^ Y2 ^ Z2 ^
+| A | B | C |
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 3, 6)),
+ array('tablethead_open',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Y1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z1 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X2 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Y2 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z2 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablethead_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' A ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' B ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' C ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(53)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
@@ -178,7 +323,7 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testCellSpan() {
@@ -220,7 +365,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testCellRowSpan() {
@@ -268,7 +413,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testCellRowSpanFirstRow() {
@@ -326,9 +471,134 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
+ function testRowSpanTableHead() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X1 ^ Y1 ^ Z1 ^
+^ X2 ^ ::: ^ Z2 ^
+| A3 | B3 | C3 |
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 3, 6)),
+ array('tablethead_open',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,2)),
+ array('cdata',array(' Y1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z1 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X2 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z2 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablethead_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' A3 ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' B3 ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' C3 ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(57)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
+ function testRowSpanAcrossTableHeadBoundary() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X1 ^ Y1 ^ Z1 ^
+^ X2 ^ ::: ^ Z2 ^
+| A3 | ::: | C3 |
+| A4 | ::: | C4 |
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 4, 6)),
+ array('tablethead_open',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,2)),
+ array('cdata',array(' Y1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z1 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X2 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z2 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablethead_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' A3 ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,2)),
+ array('cdata',array('')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' C3 ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' A4 ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' C4 ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(76)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
function testCellAlignmentFormatting() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
@@ -365,7 +635,7 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
@@ -411,7 +681,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
// This is really a failing test - formatting able to spread across cols
@@ -466,7 +736,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
// This is really a failing test - unformatted able to spread across cols
@@ -517,7 +787,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testTableLinebreak() {
@@ -565,7 +835,7 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
// This is really a failing test - footnote able to spread across cols
@@ -624,7 +894,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testTable_FS1833() {
@@ -646,4 +916,3 @@ def');
}
}
-
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..dd1ed1d3f
--- /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 DokuWikiTest {
+
+ 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&amp;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&amp;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
new file mode 100644
index 000000000..0f373227d
--- /dev/null
+++ b/_test/tests/inc/parserutils_get_renderer.test.php
@@ -0,0 +1,79 @@
+<?php
+
+class parserutils_get_renderer_test extends DokuWikiTest {
+
+ private $plugin_controller;
+
+ // test default behaviour / usual settings
+ function test_p_get_renderer_normal() {
+ global $conf;
+
+ $old_conf = $conf;
+ $conf['renderer_xhtml'] = 'xhtml';
+
+ $this->assertInstanceOf('Doku_Renderer_xhtml', p_get_renderer('xhtml'));
+
+ $conf = $old_conf;
+ }
+
+ // test get a renderer plugin
+ function test_p_get_renderer_plugin() {
+ global $conf;
+ global $plugin_controller;
+
+ $old_conf = $conf;
+ $conf['renderer_xhtml'] = 'get_renderer_test';
+ $this->plugin_controller = $plugin_controller;
+ $plugin_controller = $this;
+
+ $this->assertInstanceOf('renderer_plugin_test', p_get_renderer('xhtml'));
+
+ $conf = $old_conf;
+ $plugin_controller = $this->plugin_controller;
+ }
+
+ // test fallback succeeds
+ function test_p_get_renderer_fallback() {
+ global $conf;
+
+ $old_conf = $conf;
+ $conf['renderer_xhtml'] = 'badvalue';
+
+ $this->assertInstanceOf('Doku_Renderer_xhtml', p_get_renderer('xhtml'));
+
+ $conf = $old_conf;
+ }
+
+ // test fallback fails
+ function test_p_get_renderer_fallback_fail() {
+ global $conf;
+
+ $old_conf = $conf;
+ $conf['renderer_junk'] = 'badvalue';
+
+ $this->assertNull(p_get_renderer('junk'));
+
+ $conf = $old_conf;
+ }
+
+ // wrapper function for the fake plugin controller, return $this for the fake syntax of this test
+ function load($type,$name,$new=false,$disabled=false){
+ if ($name == 'get_renderer_test') {
+ return new renderer_plugin_test();
+ } else {
+ return $this->plugin_controller->load($type, $name, $new, $disabled);
+ }
+ }
+ }
+
+require_once DOKU_INC . 'inc/parser/xhtml.php';
+
+class renderer_plugin_test extends Doku_Renderer_xhtml {
+
+ function canRender($format) {
+ return ($format=='xhtml');
+ }
+
+}
+
+// vim:ts=4:sw=4:et:
diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php
index 417f1a853..15453b16d 100644
--- a/_test/tests/inc/tar.test.php
+++ b/_test/tests/inc/tar.test.php
@@ -1,6 +1,38 @@
<?php
class Tar_TestCase extends DokuWikiTest {
+ /**
+ * file extensions that several tests use
+ */
+ protected $extensions = array('tar');
+
+ public function setUp() {
+ parent::setUp();
+ if (extension_loaded('zlib')) {
+ $this->extensions[] = 'tgz';
+ }
+ if (extension_loaded('bz2')) {
+ $this->extensions[] = 'tbz';
+ }
+ }
+
+ /*
+ * dependency for tests needing zlib extension to pass
+ */
+ public function test_ext_zlib() {
+ if (!extension_loaded('zlib')) {
+ $this->markTestSkipped('skipping all zlib tests. Need zlib extension');
+ }
+ }
+
+ /*
+ * dependency for tests needing zlib extension to pass
+ */
+ public function test_ext_bz2() {
+ if (!extension_loaded('bz2')) {
+ $this->markTestSkipped('skipping all bzip2 tests. Need bz2 extension');
+ }
+ }
/**
* simple test that checks that the given filenames and contents can be grepped from
@@ -58,8 +90,6 @@ class Tar_TestCase extends DokuWikiTest {
$tar->addData('another/testdata3.txt', 'testcontent3');
$tar->close();
-copy ($tmp, '/tmp/test.tar');
-
$this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number
$data = file_get_contents($tmp);
@@ -89,7 +119,7 @@ copy ($tmp, '/tmp/test.tar');
public function test_tarcontent() {
$dir = dirname(__FILE__).'/tar';
- foreach(array('tar', 'tgz', 'tbz') as $ext) {
+ foreach($this->extensions as $ext) {
$tar = new Tar();
$file = "$dir/test.$ext";
@@ -112,7 +142,7 @@ copy ($tmp, '/tmp/test.tar');
$dir = dirname(__FILE__).'/tar';
$out = sys_get_temp_dir().'/dwtartest'.md5(time());
- foreach(array('tar', 'tgz', 'tbz') as $ext) {
+ foreach($this->extensions as $ext) {
$tar = new Tar();
$file = "$dir/test.$ext";
@@ -138,7 +168,7 @@ copy ($tmp, '/tmp/test.tar');
$dir = dirname(__FILE__).'/tar';
$out = sys_get_temp_dir().'/dwtartest'.md5(time());
- foreach(array('tar', 'tgz', 'tbz') as $ext) {
+ foreach($this->extensions as $ext) {
$tar = new Tar();
$file = "$dir/test.$ext";
@@ -164,7 +194,7 @@ copy ($tmp, '/tmp/test.tar');
$dir = dirname(__FILE__).'/tar';
$out = sys_get_temp_dir().'/dwtartest'.md5(time());
- foreach(array('tar', 'tgz', 'tbz') as $ext) {
+ foreach($this->extensions as $ext) {
$tar = new Tar();
$file = "$dir/test.$ext";
@@ -190,7 +220,7 @@ copy ($tmp, '/tmp/test.tar');
$dir = dirname(__FILE__).'/tar';
$out = sys_get_temp_dir().'/dwtartest'.md5(time());
- foreach(array('tar', 'tgz', 'tbz') as $ext) {
+ foreach($this->extensions as $ext) {
$tar = new Tar();
$file = "$dir/test.$ext";
@@ -215,7 +245,7 @@ copy ($tmp, '/tmp/test.tar');
$dir = dirname(__FILE__).'/tar';
$out = sys_get_temp_dir().'/dwtartest'.md5(time());
- foreach(array('tar', 'tgz', 'tbz') as $ext) {
+ foreach($this->extensions as $ext) {
$tar = new Tar();
$file = "$dir/test.$ext";
@@ -249,6 +279,9 @@ copy ($tmp, '/tmp/test.tar');
$this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2'));
}
+ /**
+ * @depends test_ext_zlib
+ */
public function test_longpathextract() {
$dir = dirname(__FILE__).'/tar';
$out = sys_get_temp_dir().'/dwtartest'.md5(time());
@@ -338,6 +371,7 @@ copy ($tmp, '/tmp/test.tar');
/**
* Extract a tarbomomb
+ * @depends test_ext_zlib
*/
public function test_tarbomb() {
$dir = dirname(__FILE__).'/tar';
diff --git a/_test/tests/inc/utf8_romanize.test.php b/_test/tests/inc/utf8_romanize.test.php
index d08346faa..353d48c00 100644
--- a/_test/tests/inc/utf8_romanize.test.php
+++ b/_test/tests/inc/utf8_romanize.test.php
@@ -5,7 +5,7 @@ if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);
/**
* @group slow
*/
-class utf8_romanize_test extends PHPUnit_Framework_TestCase {
+class utf8_romanize_test extends DokuWikiTest {
/**
* Check Japanese romanization
diff --git a/_test/tests/inc/utf8_strtolower.test.php b/_test/tests/inc/utf8_strtolower.test.php
new file mode 100644
index 000000000..85f5b270b
--- /dev/null
+++ b/_test/tests/inc/utf8_strtolower.test.php
@@ -0,0 +1,23 @@
+<?php
+// use no mbstring help here
+if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);
+
+class utf8_strtolower_test extends DokuWikiTest {
+
+ function test_givens(){
+ $data = array(
+ 'Αρχιτεκτονική Μελέτη' => 'αρχιτεκτονική μελέτη', // FS#2173
+ );
+
+ foreach($data as $input => $expected) {
+ $this->assertEquals($expected, utf8_strtolower($input));
+ }
+
+ // just make sure our data was correct
+ if(function_exists('mb_strtolower')) {
+ foreach($data as $input => $expected) {
+ $this->assertEquals($expected, mb_strtolower($input, 'utf-8'));
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/_test/tests/lib/exe/css_css_compress.test.php b/_test/tests/lib/exe/css_css_compress.test.php
index a614ea2fd..807317ca6 100644
--- a/_test/tests/lib/exe/css_css_compress.test.php
+++ b/_test/tests/lib/exe/css_css_compress.test.php
@@ -10,41 +10,70 @@ 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_slcom6(){
+ $text = '#foo {
+ background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is all commented
+ }';
+ $this->assertEquals('#foo{background-image:url(//foo.bar/baz.jpg);}', css_compress($text));
+ }
+
+ function test_slcom7(){
+ $text = '#foo a[href ^="https://"], #foo a[href ^=\'https://\'] {
+ background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is \'all\' "commented"
+ }';
+ $this->assertEquals('#foo a[href ^="https://"],#foo a[href ^=\'https://\']{background-image:url(//foo.bar/baz.jpg);}', css_compress($text));
+ }
+
+
function test_hack(){
$text = '/* Mac IE will not see this and continue with inline-block */
/* \\*/
display: inline;
/* */';
- $this->assertEquals(css_compress($text), '/* \\*/display:inline;/* */');
+ $this->assertEquals('/* \\*/display:inline;/* */', css_compress($text));
}
function test_hack2(){
@@ -54,12 +83,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 +131,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 :
diff --git a/_test/tests/test/basic.test.php b/_test/tests/test/basic.test.php
index 86acef935..0639f0c5a 100644
--- a/_test/tests/test/basic.test.php
+++ b/_test/tests/test/basic.test.php
@@ -33,7 +33,7 @@ class InttestsBasicTest extends DokuWikiTest {
$response = $request->execute();
$this->assertTrue(
- strpos($response->getContent(), 'DokuWiki') >= 0,
+ strpos($response->getContent(), 'DokuWiki') !== false,
'DokuWiki was not a word in the output'
);
}
@@ -60,7 +60,7 @@ class InttestsBasicTest extends DokuWikiTest {
$this->assertEquals('wiki:dokuwiki', $request->getPost('id'));
// output check
- $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
+ $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') !== false);
}
function testPostGet() {
@@ -84,7 +84,7 @@ class InttestsBasicTest extends DokuWikiTest {
$this->assertEquals('wiki:dokuwiki', $request->getGet('id'));
// output check
- $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
+ $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') !== false);
}
function testGet() {
@@ -116,7 +116,7 @@ class InttestsBasicTest extends DokuWikiTest {
$this->assertEquals('bar', $request->getGet('test'));
// output check
- $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
+ $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') !== false);
}
function testScripts() {
@@ -168,5 +168,13 @@ class InttestsBasicTest extends DokuWikiTest {
$response = new TestResponse('',array_slice($this->some_headers,0,-2)); // slice off the last two headers to leave no status header
$this->assertNull($response->getStatusCode());
}
+
+ function testINPUT() {
+ $request = new TestRequest();
+ $response = $request->get(array('id' => 'mailinglist'), '/doku.php');
+
+ // output check
+ $this->assertTrue(strpos($response->getContent(), 'Netiquette') !== false);
+ }
}