summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2010-08-29 14:22:01 +0200
committerAndreas Gohr <andi@splitbrain.org>2010-08-29 14:22:01 +0200
commit2c053ed58376c6709596ab48fc40dceb90d4e89d (patch)
treec8d0f78c2f47f373473419396d3c0855ec671eca /_test
parentcb4a07568e84d853fbcd9d5eca37f572fa10786f (diff)
parent5479a8c3341247ca228026819f20f3ab5c34a80f (diff)
downloadrpg-2c053ed58376c6709596ab48fc40dceb90d4e89d.tar.gz
rpg-2c053ed58376c6709596ab48fc40dceb90d4e89d.tar.bz2
Merge branch 'master' into stable
Conflicts: conf/msg lib/plugins/acl/ajax.php
Diffstat (limited to '_test')
-rw-r--r--_test/cases/inc/IXR_Library_IXR_Message.test.php139
-rw-r--r--_test/cases/inc/IXR_Library_date.test.php34
-rw-r--r--_test/cases/inc/auth_admincheck.test.php12
-rw-r--r--_test/cases/inc/html_hilight.test.php4
-rw-r--r--_test/cases/inc/indexer_idx_indexlengths.test.php121
-rw-r--r--_test/cases/inc/pageutils_getid.test.php38
-rw-r--r--_test/cases/inc/parser/parser_footnote.test.php4
-rw-r--r--_test/cases/inc/parser/parser_formatting.test.php42
-rw-r--r--_test/cases/inc/parser/parser_headers.test.php21
-rw-r--r--_test/cases/inc/parser/parser_i18n.test.php7
-rw-r--r--_test/cases/inc/parser/parser_table.test.php58
-rw-r--r--_test/cases/inc/parser/xhtml_htmlphp.test.php4
-rw-r--r--_test/cases/inc/safefn.test.php33
-rw-r--r--_test/cases/lib/exe/js_js_compress.test.php4
-rw-r--r--_test/index.php46
-rw-r--r--_test/lib/testmanager.php94
-rw-r--r--_test/lib/unittest.php5
-rwxr-xr-x_test/runtests.php57
18 files changed, 641 insertions, 82 deletions
diff --git a/_test/cases/inc/IXR_Library_IXR_Message.test.php b/_test/cases/inc/IXR_Library_IXR_Message.test.php
new file mode 100644
index 000000000..2a8133230
--- /dev/null
+++ b/_test/cases/inc/IXR_Library_IXR_Message.test.php
@@ -0,0 +1,139 @@
+<?php
+require_once DOKU_INC.'inc/IXR_Library.php';
+
+class ixr_library_ixr_message_test extends UnitTestCase {
+
+
+
+
+
+ function test_untypedvalue1(){
+ $xml = '<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>wiki.getBackLinks</methodName><params><param><value> change </value></param></params></methodCall>';
+
+ $ixrmsg = new IXR_Message($xml);
+ $ixrmsg->parse();
+
+ $this->assertEqual($ixrmsg->messageType,'methodCall');
+ $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
+ $this->assertEqual($ixrmsg->params,array(' change '));
+ }
+
+ function test_untypedvalue2(){
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>
+ <methodCall>
+ <methodName>wiki.getBackLinks</methodName>
+ <params>
+ <param>
+ <value> change </value>
+ </param>
+ </params>
+ </methodCall>';
+
+ $ixrmsg = new IXR_Message($xml);
+ $ixrmsg->parse();
+
+ $this->assertEqual($ixrmsg->messageType,'methodCall');
+ $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
+ $this->assertEqual($ixrmsg->params,array(' change '));
+ }
+
+ function test_stringvalue1(){
+ $xml = '<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>wiki.getBackLinks</methodName><params><param><value><string> change </string></value></param></params></methodCall>';
+
+ $ixrmsg = new IXR_Message($xml);
+ $ixrmsg->parse();
+
+ $this->assertEqual($ixrmsg->messageType,'methodCall');
+ $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
+ $this->assertEqual($ixrmsg->params,array(' change '));
+ }
+
+ function test_stringvalue2(){
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>
+ <methodCall>
+ <methodName>wiki.getBackLinks</methodName>
+ <params>
+ <param>
+ <value>
+ <string> change </string>
+ </value>
+ </param>
+ </params>
+ </methodCall>';
+
+ $ixrmsg = new IXR_Message($xml);
+ $ixrmsg->parse();
+
+ $this->assertEqual($ixrmsg->messageType,'methodCall');
+ $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
+ $this->assertEqual($ixrmsg->params,array(' change '));
+ }
+
+ function test_emptyvalue1(){
+ $xml = '<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>wiki.getBackLinks</methodName><params><param><value><string></string></value></param></params></methodCall>';
+
+ $ixrmsg = new IXR_Message($xml);
+ $ixrmsg->parse();
+
+ $this->assertEqual($ixrmsg->messageType,'methodCall');
+ $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
+ $this->assertEqual($ixrmsg->params,array(''));
+ }
+
+ function test_emptyvalue2(){
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>
+ <methodCall>
+ <methodName>wiki.getBackLinks</methodName>
+ <params>
+ <param>
+ <value>
+ <string></string>
+ </value>
+ </param>
+ </params>
+ </methodCall>';
+
+ $ixrmsg = new IXR_Message($xml);
+ $ixrmsg->parse();
+
+ $this->assertEqual($ixrmsg->messageType,'methodCall');
+ $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
+ $this->assertEqual($ixrmsg->params,array(''));
+ }
+
+ function test_struct(){
+ $xml = '<?xml version=\'1.0\'?>
+ <methodCall>
+ <methodName>wiki.putPage</methodName>
+ <params>
+ <param>
+ <value><string>start</string></value>
+ </param>
+ <param>
+ <value><string>test text</string></value>
+ </param>
+ <param>
+ <value><struct>
+ <member>
+ <name>sum</name>
+ <value><string>xmlrpc edit</string></value>
+ </member>
+ <member>
+ <name>minor</name>
+ <value><string>1</string></value>
+ </member>
+ </struct></value>
+ </param>
+ </params>
+ </methodCall>';
+
+ $ixrmsg = new IXR_Message($xml);
+ $ixrmsg->parse();
+
+ $this->assertEqual($ixrmsg->messageType,'methodCall');
+ $this->assertEqual($ixrmsg->methodName,'wiki.putPage');
+ $this->assertEqual($ixrmsg->params,array('start','test text',array('sum'=>'xmlrpc edit','minor'=>'1')));
+ }
+
+}
+//Setup VIM: ex: et ts=4 enc=utf-8 :
diff --git a/_test/cases/inc/IXR_Library_date.test.php b/_test/cases/inc/IXR_Library_date.test.php
new file mode 100644
index 000000000..a2b6154d8
--- /dev/null
+++ b/_test/cases/inc/IXR_Library_date.test.php
@@ -0,0 +1,34 @@
+<?php
+require_once DOKU_INC.'inc/IXR_Library.php';
+
+class ixr_library_date_test extends UnitTestCase {
+
+
+ function test_parseIso(){
+ // multiple tests
+ $tests = array(
+ // full datetime, different formats
+ array('2010-08-17T09:23:14', 1282036994),
+ array('20100817T09:23:14', 1282036994),
+ array('2010-08-17 09:23:14', 1282036994),
+ array('20100817 09:23:14', 1282036994),
+ array('2010-08-17T09:23:14Z', 1282036994),
+ array('20100817T09:23:14Z', 1282036994),
+
+ // no seconds
+ array('2010-08-17T09:23', 1282036980),
+ array('20100817T09:23', 1282036980),
+
+ // no time
+ array('2010-08-17', 1282003200),
+ //array('20100817', 1282003200), #this will NOT be parsed, but is assumed to be timestamp
+ );
+
+ foreach($tests as $test){
+ $dt = new IXR_Date($test[0]);
+ $this->assertEqual($dt->getTimeStamp(),$test[1]);
+ }
+ }
+
+}
+//Setup VIM: ex: et ts=4 enc=utf-8 :
diff --git a/_test/cases/inc/auth_admincheck.test.php b/_test/cases/inc/auth_admincheck.test.php
index c00271a26..f14d6369e 100644
--- a/_test/cases/inc/auth_admincheck.test.php
+++ b/_test/cases/inc/auth_admincheck.test.php
@@ -19,11 +19,11 @@ class auth_admin_test extends UnitTestCase {
$conf['manager'] = 'john,@managers,doe';
// anonymous user
- $this->assertEqual(auth_ismanager('jill', '',false), false);
+ $this->assertEqual(auth_ismanager('jill', null,false), false);
// admin or manager users
- $this->assertEqual(auth_ismanager('john', '',false), true);
- $this->assertEqual(auth_ismanager('doe', '',false), true);
+ $this->assertEqual(auth_ismanager('john', null,false), true);
+ $this->assertEqual(auth_ismanager('doe', null,false), true);
// admin or manager groups
$this->assertEqual(auth_ismanager('jill', array('admin'),false), true);
@@ -35,11 +35,11 @@ class auth_admin_test extends UnitTestCase {
$conf['superuser'] = 'john,@admin,doe,@roots';
// anonymous user
- $this->assertEqual(auth_ismanager('jill', '',true), false);
+ $this->assertEqual(auth_ismanager('jill', null,true), false);
// admin user
- $this->assertEqual(auth_ismanager('john', '',true), true);
- $this->assertEqual(auth_ismanager('doe', '',true), true);
+ $this->assertEqual(auth_ismanager('john', null,true), true);
+ $this->assertEqual(auth_ismanager('doe', null,true), true);
// admin groups
$this->assertEqual(auth_ismanager('jill', array('admin'),true), true);
diff --git a/_test/cases/inc/html_hilight.test.php b/_test/cases/inc/html_hilight.test.php
index 85f224b6e..cc5579c71 100644
--- a/_test/cases/inc/html_hilight.test.php
+++ b/_test/cases/inc/html_hilight.test.php
@@ -2,9 +2,7 @@
require_once DOKU_INC.'inc/html.php';
-if ( !extension_loaded('runkit') &&
- !@dl('runkit.dll') &&
- !@dl('runkit.so' ) ){
+if (!extension_loaded('runkit')) {
SimpleTestOptions::ignore('html_hilight_test');
trigger_error('Skipping html_hilight_test - http://www.php.net/runkit required');
}
diff --git a/_test/cases/inc/indexer_idx_indexlengths.test.php b/_test/cases/inc/indexer_idx_indexlengths.test.php
new file mode 100644
index 000000000..d1339a111
--- /dev/null
+++ b/_test/cases/inc/indexer_idx_indexlengths.test.php
@@ -0,0 +1,121 @@
+<?php
+
+require_once DOKU_INC.'inc/indexer.php';
+
+class indexer_idx_indexlengths_test extends UnitTestCase {
+
+ /**
+ * Test the function with an array of one value
+ */
+ function test_oneWord(){
+ global $conf;
+ $filter[8] = array('dokuwiki');
+ // one word should return the index
+ $ref[] = 8;
+ sort($ref);
+ $result = idx_indexLengths(&$filter);
+ sort($result);
+ $this->assertIdentical($result, $ref);
+ }
+
+ /**
+ * Test the function with an array of values
+ */
+ function test_moreWords() {
+ global $conf;
+ $filter = array( 4 => array('test'), 8 => array('dokuwiki'), 7 => array('powered'));
+ // more words should return the indexes
+ $ref = array(4, 7, 8);
+ sort($ref);
+ $result = idx_indexLengths(&$filter);
+ sort($result);
+ $this->assertIdentical($result, $ref);
+ }
+
+ /**
+ * Test a minimal value in case of wildcard search
+ */
+ function test_minValue() {
+ global $conf;
+ $filter = 5;
+ // construction of the list of the index to compare
+ $dir = @opendir($conf['indexdir']);
+ $ref = array();
+ while (($f = readdir($dir)) !== false) {
+ if (substr($f,0,1) == 'i' && substr($f,-4) == '.idx'){
+ $i = substr($f,1,-4);
+ if (is_numeric($i) && $i >= $filter)
+ $ref[] = (int)$i;
+ }
+ }
+ closedir($dir);
+ sort($ref);
+ $result = idx_indexLengths(&$filter);
+ sort($result);
+ $this->assertIdentical($result, $ref);
+ }
+}
+
+class indexer_idx_indexlengths_time extends UnitTestCase {
+
+ /**
+ * Test the time improvments of the new function
+ * Time reference for 10000 call oneWords: 4,6s
+ * It's 90% faster
+ */
+ function test_oneWord(){
+ global $conf;
+ $filter[8] = array('dokuwiki');
+ $start = microtime(true);
+ for ($i = 0; $i < 10000; $i++) {
+ $result = idx_indexLengths(&$filter);
+ }
+ $end = microtime(true);
+ $time = $end - $start;
+ $timeref = 4.6*0.10; // actual execution time of 4,6s for 10000 calls
+ echo "1) 10% ref : $timeref -> $time \n";
+ $this->assertTrue($time < $timeref);
+ }
+
+ /**
+ * Test the time improvments of the new function
+ * Time reference for 10000 call moreWords: 4,6s
+ * It's 90% faster
+ */
+ function test_moreWords() {
+ global $conf;
+ $filter = array( 4 => array('test'), 8 => array('dokuwiki'), 7 => array('powered'));
+ // more words should return the indexes
+ $start = microtime(true);
+ for ($i = 0; $i < 10000; $i++) {
+ $result = idx_indexLengths(&$filter);
+ }
+ $end = microtime(true);
+ $time = $end - $start;
+ $timeref = 4.6*0.10; // actual execution time of 4,6s for 10000 calls
+ echo "2) 10% ref : $timeref -> $time \n";
+ $this->assertTrue($time < $timeref);
+ }
+
+ /**
+ * Test the time improvments of the new function
+ * Time reference for 10000 call on minValue: 4,9s
+ * Sould be at least 65% faster
+ * Test fail with no cache
+ */
+ function test_minValue() {
+ global $conf;
+ $filter = 5;
+ $start = microtime(true);
+ for ($i = 0; $i < 10000; $i++) {
+ $result = idx_indexLengths(&$filter);
+ }
+ $end = microtime(true);
+ $time = $end - $start;
+ $timeref = 4.9 * 0.35; // actual execution time of 4,9s for 10000 calls
+ echo "3) 35% ref : $timeref -> $time \n";
+ $this->assertTrue($time < $timeref);
+ }
+}
+
+//Setup VIM: ex: et ts=4 enc=utf-8 :
diff --git a/_test/cases/inc/pageutils_getid.test.php b/_test/cases/inc/pageutils_getid.test.php
index 8233ffb42..e3932a579 100644
--- a/_test/cases/inc/pageutils_getid.test.php
+++ b/_test/cases/inc/pageutils_getid.test.php
@@ -64,5 +64,43 @@ class init_getID_test extends UnitTestCase {
$this->assertEqual(getID(), 'wiki:dokuwiki');
}
+ /**
+ * getID with given id in url and userewrite=2, no basedir set, Apache and CGI.
+ */
+ function test4() {
+ global $conf;
+ $conf['basedir'] = '';
+ $conf['userewrite'] = '2';
+ $conf['baseurl'] = '';
+ $_SERVER['DOCUMENT_ROOT'] = '/var/www/vhosts/example.com/htdocs';
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/vhosts/example.com/htdocs/doku.php';
+ $_SERVER['SCRIPT_NAME'] = '/doku.php';
+ $_SERVER['REQUEST_URI'] = '/doku.php/wiki/dokuwiki';
+ $_SERVER['PATH_INFO'] = '/wiki/dokuwiki';
+ $_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php';
+ $_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki';
+
+ $this->assertEqual(getID(), 'wiki:dokuwiki');
+ }
+
+ /**
+ * getID with given id / in url and userewrite=2, no basedir set, Apache and CGI.
+ */
+ function test5() {
+ global $conf;
+ $conf['basedir'] = '';
+ $conf['userewrite'] = '2';
+ $conf['baseurl'] = '';
+ $_SERVER['DOCUMENT_ROOT'] = '/var/www/';
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
+ $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
+ $_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/?do=debug';
+ $_SERVER['PATH_INFO'] = '/';
+ $_SERVER['PATH_TRANSLATED'] = '/var/www/index.html';
+ $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/';
+
+ $this->assertEqual(getID(), 'start');
+ }
+
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
diff --git a/_test/cases/inc/parser/parser_footnote.test.php b/_test/cases/inc/parser/parser_footnote.test.php
index 2b00a0b2e..a1da2ab06 100644
--- a/_test/cases/inc/parser/parser_footnote.test.php
+++ b/_test/cases/inc/parser/parser_footnote.test.php
@@ -259,7 +259,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
- array('table_open',array(3,2)),
+ array('table_open',array(3, 2, 8)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
@@ -282,7 +282,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(123)),
array('cdata',array(' ')),
array('footnote_close',array()),
))),
diff --git a/_test/cases/inc/parser/parser_formatting.test.php b/_test/cases/inc/parser/parser_formatting.test.php
index 35bb41a6a..79509f40b 100644
--- a/_test/cases/inc/parser/parser_formatting.test.php
+++ b/_test/cases/inc/parser/parser_formatting.test.php
@@ -168,6 +168,48 @@ class TestOfDoku_Parser_Formatting extends TestOfDoku_Parser {
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
+ function testEmWithMultiOccurence() {
+ // Case from #763
+ $this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
+ $this->P->parse('//text:// Blablabla Blablabla
+
+//text:// another Blablabla Blablabla');
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n")),
+ array('emphasis_open',array()),
+ array('cdata',array('text:')),
+ array('emphasis_close',array()),
+ array('cdata',array(" Blablabla Blablabla\n\n")),
+ array('emphasis_open',array()),
+ array('cdata',array('text:')),
+ array('emphasis_close',array()),
+ array('cdata',array(" another Blablabla Blablabla\n")),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+ $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testEmWithUnicode() {
+ // Case from #1468
+ $this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
+ $this->P->parse('//Тест://');
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n")),
+ array('emphasis_open',array()),
+ array('cdata',array('Тест:')),
+ array('emphasis_close',array()),
+ array('cdata',array("\n")),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+ $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
function testUnderline() {
$this->P->addMode('underline',new Doku_Parser_Mode_Formatting('underline'));
$this->P->parse('abc __bar__ def');
diff --git a/_test/cases/inc/parser/parser_headers.test.php b/_test/cases/inc/parser/parser_headers.test.php
index 8e6517123..e1c6783f5 100644
--- a/_test/cases/inc/parser/parser_headers.test.php
+++ b/_test/cases/inc/parser/parser_headers.test.php
@@ -15,14 +15,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
- array('section_edit',array(-1,5,1,'')),
array('header',array('Header',1,6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array (6,0,1,'Header')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
@@ -36,14 +34,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
- array('section_edit',array(-1,5,1,'')),
array('header',array('Header',2,6)),
array('section_open',array(2)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(6,0,2,'Header')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
@@ -57,14 +53,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
- array('section_edit',array(-1,5,1,'')),
array('header',array('Header',3,6)),
array('section_open',array(3)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(6,0,3,'Header')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
@@ -116,14 +110,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
- array('section_edit',array(-1,5,1,'')),
array('header',array('Header',2,6)),
array('section_open',array(2)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(6,0,2,'Header')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
@@ -137,14 +129,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
- array('section_edit',array(-1,5,1,'')),
array('header',array('Header',2,6)),
array('section_open',array(2)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(6,0,2,'Header')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
@@ -158,14 +148,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
- array('section_edit',array(-1,5,1,'')),
array('header',array('Header',1,6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(6,0,1,'Header')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
@@ -193,14 +181,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
- array('section_edit',array(-1,5,1,'')),
array('header',array('== Header ==',1,6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(6,0,1,'== Header ==')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
@@ -233,14 +219,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nabc \n== ====== Header\n")),
array('p_close',array()),
- array('section_edit',array(-1,22,1,'')),
array('header',array('',1,23)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(23,0,1,'')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
@@ -261,14 +245,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array('abc '.DOKU_PARSER_EOL)),
array('p_close',array()),
- array('section_edit',array(-1,5,1,'')),
array('header',array('Header',1, 6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array(' def'.DOKU_PARSER_EOL)),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(6,0,1,'Header')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
@@ -283,21 +265,18 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
- array('section_edit',array(-1,5,1,'')),
array('header',array('Header',1,6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def abc \n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(6,38,1,'Header')),
array('header',array('Header2',2,39)),
array('section_open',array(2)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(39,0,2,'Header2')),
array('document_end',array())
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
diff --git a/_test/cases/inc/parser/parser_i18n.test.php b/_test/cases/inc/parser/parser_i18n.test.php
index 8d587fe0e..f0cceb69e 100644
--- a/_test/cases/inc/parser/parser_i18n.test.php
+++ b/_test/cases/inc/parser/parser_i18n.test.php
@@ -62,14 +62,12 @@ class TestOfDoku_Parser_i18n extends TestOfDoku_Parser {
array('p_open',array()),
array('cdata',array("\nFoo\n")),
array('p_close',array()),
- array('section_edit',array(-1,4,1,'')),
array('header',array('Iñtërnâtiônàlizætiøn',3,5)),
array('section_open',array(3)),
array('p_open',array()),
array('cdata',array("\n Bar\n")),
array('p_close',array()),
array('section_close',array()),
- array('section_edit',array(5,0,3,'Iñtërnâtiônàlizætiøn')),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
@@ -87,7 +85,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,2)),
+ array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
@@ -110,13 +108,12 @@ def');
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(153)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
-
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
diff --git a/_test/cases/inc/parser/parser_table.test.php b/_test/cases/inc/parser/parser_table.test.php
index f84923dfd..099909495 100644
--- a/_test/cases/inc/parser/parser_table.test.php
+++ b/_test/cases/inc/parser/parser_table.test.php
@@ -19,7 +19,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,2)),
+ array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
@@ -42,7 +42,7 @@ def');
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(121)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
@@ -59,7 +59,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,2)),
+ array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
@@ -82,7 +82,7 @@ def');
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(121)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
@@ -103,16 +103,16 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(0,1)),
+ array('table_open',array(0, 1, 6)),
array('tablerow_open',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(7)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
-
+
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
@@ -128,7 +128,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,1)),
+ array('table_open',array(3, 1, 6)),
array('tablerow_open',array()),
array('tableheader_open',array(1,NULL,1)),
array('cdata',array(' X ')),
@@ -140,13 +140,13 @@ def');
array('cdata',array(' Z ')),
array('tableheader_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(19)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
-
+
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
@@ -163,7 +163,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,1)),
+ array('table_open',array(3, 1, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'right',1)),
array('cdata',array(' X ')),
@@ -175,13 +175,13 @@ def');
array('cdata',array(' Z ')),
array('tableheader_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(23)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
-
+
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
@@ -199,7 +199,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,3)),
+ array('table_open',array(3, 3, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(2,'right',1)),
array('cdata',array(' d ')),
@@ -218,7 +218,7 @@ def');
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(31)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
@@ -241,7 +241,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,3)),
+ array('table_open',array(3, 3, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,NULL,2)),
array('cdata',array(' a ')),
@@ -266,7 +266,7 @@ def');
array('cdata',array(':::f')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(51)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
@@ -288,7 +288,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,1)),
+ array('table_open',array(3, 1, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'right',1)),
array('cdata',array(' ')),
@@ -304,7 +304,7 @@ def');
array('cdata',array(' Z ')),
array('tableheader_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(27)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
@@ -328,7 +328,7 @@ def');
array('p_open',array()),
array('cdata',array(DOKU_PARSER_EOL."abc")),
array('p_close',array()),
- array('table_open',array(3,2)),
+ array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
@@ -351,7 +351,7 @@ def');
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(121)),
array('p_open',array()),
array('cdata',array('def'.DOKU_PARSER_EOL)),
array('p_close',array()),
@@ -375,7 +375,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,2)),
+ array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' ')),
@@ -403,7 +403,7 @@ def');
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(129)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
@@ -427,7 +427,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,2)),
+ array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' ')),
@@ -451,7 +451,7 @@ def');
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(155)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
@@ -473,7 +473,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,2)),
+ array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0')),
@@ -498,7 +498,7 @@ def');
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(123)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
@@ -523,7 +523,7 @@ def');
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
- array('table_open',array(3,2)),
+ array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' ')),
@@ -555,7 +555,7 @@ def');
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
- array('table_close',array()),
+ array('table_close',array(129)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
diff --git a/_test/cases/inc/parser/xhtml_htmlphp.test.php b/_test/cases/inc/parser/xhtml_htmlphp.test.php
index 3493bab4d..65d64e579 100644
--- a/_test/cases/inc/parser/xhtml_htmlphp.test.php
+++ b/_test/cases/inc/parser/xhtml_htmlphp.test.php
@@ -5,9 +5,7 @@ require_once 'parser.inc.php';
require_once DOKU_INC.'inc/parser/xhtml.php';
require_once DOKU_INC.'inc/geshi.php';
-if ( !extension_loaded('runkit') &&
- !@dl('runkit.dll') &&
- !@dl('runkit.so' ) ){
+if (!extension_loaded('runkit')) {
SimpleTestOptions::ignore('xhtml_htmlphp_test');
trigger_error('Skipping xhtml_htmlphp_test - http://www.php.net/runkit required');
}
diff --git a/_test/cases/inc/safefn.test.php b/_test/cases/inc/safefn.test.php
new file mode 100644
index 000000000..fb0d812d7
--- /dev/null
+++ b/_test/cases/inc/safefn.test.php
@@ -0,0 +1,33 @@
+<?php
+// use no mbstring help here
+if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);
+require_once DOKU_INC.'inc/utf8.php';
+require_once DOKU_INC.'inc/SafeFN.class.php';
+
+class safeFN_test extends UnitTestCase {
+
+
+ function test1(){
+ // we test multiple cases here - format: string, repl, additional, test
+ $tests = array();
+ $tests[] = array('asciistring','asciistring');
+ $tests[] = array('ascii-_/.string','ascii-_/.string');
+ $tests[] = array('AName','%x%1a.ame');
+ $tests[] = array('A Name','%x%0%1a.ame');
+ $tests[] = array('Another...Name','%x.nother...%1a.ame');
+ $tests[] = array('Aß∂ƒName','%x%5b%6oy%aa%1a.ame');
+ $tests[] = array('A%ß-∂_.ƒName','%x%%5b.-%6oy._.%aa%1a.ame');
+ $tests[] = array('A%%ß-∂_.ƒName','%x%%%5b.-%6oy._.%aa%1a.ame');
+ $tests[] = array('데이터도 함께 복원됩니다. 강력한','%zf4%13dg%15ao%zhg%0%164o%yig%0%11at%138w%zk9%zag%zb8..%0%xyt%10cl%164c');
+ $tests[] = array('совместимая','%td%ta%sy%t8%t1%td%te%t4%t8%sw%tr');
+ $tests[] = array('нехватка_файлового_пространства_на_сервере_p0-squid.some.domain.1270211897.txt.gz','%t9%t1%th%sy%sw%te%t6%sw._%tg%sw%t5%t7%ta%sy%ta%sz%ta._%tb%tc%ta%td%te%tc%sw%t9%td%te%sy%sw._%t9%sw._%td%t1%tc%sy%t1%tc%t1._p0-squid.some.domain.1270211897.txt.gz');
+
+ foreach($tests as $test){
+ list($utf8,$safe) = $test;
+ $this->assertEqual(SafeFN::encode($utf8),$safe);
+ $this->assertEqual(SafeFN::decode($safe),$utf8);
+ }
+ }
+
+}
+//Setup VIM: ex: et ts=4 enc=utf-8 :
diff --git a/_test/cases/lib/exe/js_js_compress.test.php b/_test/cases/lib/exe/js_js_compress.test.php
index b7de9257d..9051dfb01 100644
--- a/_test/cases/lib/exe/js_js_compress.test.php
+++ b/_test/cases/lib/exe/js_js_compress.test.php
@@ -71,7 +71,7 @@ class js_js_compress_test extends UnitTestCase {
function test_dquotrunaway(){
$text = 'var foo="Now where does it end';
- $this->assertEqual(js_compress($text), "$text");
+ $this->assertEqual(js_compress($text), $text);
}
function test_squot1(){
@@ -81,7 +81,7 @@ class js_js_compress_test extends UnitTestCase {
function test_squotrunaway(){
$text = "var foo='Now where does it end";
- $this->assertEqual(js_compress($text), "$text");
+ $this->assertEqual(js_compress($text), $text);
}
function test_nl1(){
diff --git a/_test/index.php b/_test/index.php
index 87cc10a35..f59c44cf4 100644
--- a/_test/index.php
+++ b/_test/index.php
@@ -130,6 +130,30 @@ function DW_TESTS_PaintGroupTestList() {
}
}
+function DW_TESTS_PaintPluginTestCaseList() {
+ switch ( DW_TESTS_OUTPUT ) {
+ case DW_TESTS_OUTPUT_XML:
+ echo XMLTestManager::getPluginTestCaseList(TEST_PLUGINS);
+ break;
+ case DW_TESTS_OUTPUT_HTML:
+ default:
+ echo HTMLTestManager::getPluginTestCaseList(TEST_PLUGINS);
+ break;
+ }
+}
+
+function DW_TESTS_PaintPluginGroupTestList() {
+ switch ( DW_TESTS_OUTPUT ) {
+ case DW_TESTS_OUTPUT_XML:
+ echo XMLTestManager::getPluginGroupTestList(TEST_PLUGINS);
+ break;
+ case DW_TESTS_OUTPUT_HTML:
+ default:
+ echo HTMLTestManager::getPluginGroupTestList(TEST_PLUGINS);
+ break;
+ }
+}
+
function DW_TESTS_PaintFooter() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
@@ -160,6 +184,19 @@ if (isset($_GET['group'])) {
exit();
}
+// If it's a plugin group test
+if (isset($_GET['plugin_group'])) {
+ if ('all' == $_GET['plugin_group']) {
+ TestManager::runAllPluginTests(DW_TESTS_GetReporter());
+ } else {
+ TestManager::runGroupTest(ucfirst($_GET['plugin_group']),
+ TEST_PLUGINS,
+ DW_TESTS_GetReporter());
+ }
+ DW_TESTS_PaintRunMore();
+ exit();
+}
+
// If it's a single test case
if (isset($_GET['case'])) {
TestManager::runTestCase($_GET['case'], TEST_CASES, DW_TESTS_GetReporter());
@@ -167,6 +204,13 @@ if (isset($_GET['case'])) {
exit();
}
+// If it's a single plugin test case
+if (isset($_GET['plugin_case'])) {
+ TestManager::runTestCase($_GET['plugin_case'], TEST_PLUGINS, DW_TESTS_GetReporter());
+ DW_TESTS_PaintRunMore();
+ exit();
+}
+
// Else it's the main page
DW_TESTS_PaintHeader();
@@ -174,9 +218,11 @@ DW_TESTS_PaintSuiteHeader();
if (isset($_GET['show']) && $_GET['show'] == 'cases') {
DW_TESTS_PaintCaseList();
+ DW_TESTS_PaintPluginTestCaseList();
} else {
/* no group specified, so list them all */
DW_TESTS_PaintGroupTestList();
+ DW_TESTS_PaintPluginGroupTestList();
}
DW_TESTS_PaintFooter();
diff --git a/_test/lib/testmanager.php b/_test/lib/testmanager.php
index def86ca27..96c9a57a2 100644
--- a/_test/lib/testmanager.php
+++ b/_test/lib/testmanager.php
@@ -5,9 +5,10 @@
define('TEST_GROUPS',realpath(dirname(__FILE__).'/../cases'));
define('TEST_CASES',realpath(dirname(__FILE__).'/../cases'));
+define('TEST_PLUGINS',realpath(dirname(__FILE__).'/../../lib/plugins'));
// try to load runkit extension
-if (!extension_loaded('runkit')) {
+if (!extension_loaded('runkit') && function_exists('dl')) {
if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
@dl('php_runkit.dll');
} else {
@@ -15,7 +16,6 @@ if (!extension_loaded('runkit')) {
}
}
-
class TestManager {
var $_testcase_extension = '.test.php';
var $_grouptest_extension = '.group.php';
@@ -60,6 +60,17 @@ class TestManager {
$test->run($reporter);
}
+ function runAllPluginTests(&$reporter) {
+ $manager =& new TestManager();
+ $test_cases =& $manager->_getTestFileList(TEST_PLUGINS);
+ $test =& new GroupTest('All Plugin Tests');
+ foreach ($test_cases as $test_case) {
+ $test->addTestFile($test_case);
+ }
+ $test->run($reporter);
+ }
+
+
function runTestCase($testcase_name, $test_case_directory, &$reporter) {
$manager =& new TestManager();
@@ -126,12 +137,12 @@ class TestManager {
}
function &_getTestCaseList($directory = '.') {
- $base = TEST_GROUPS . DIRECTORY_SEPARATOR;
$file_list =& $this->_getTestFileList($directory);
$testcases = array();
foreach ($file_list as $testcase_file) {
$case = str_replace($this->_testcase_extension, '',$testcase_file);
- $case = str_replace($base, '', $case);
+ $case = str_replace(TEST_GROUPS . DIRECTORY_SEPARATOR, '', $case);
+ $case = str_replace(TEST_PLUGINS . DIRECTORY_SEPARATOR, '', $case);
$case = str_replace(DIRECTORY_SEPARATOR, ':', $case);
$testcases[$testcase_file] = $case;
}
@@ -143,6 +154,16 @@ class TestManager {
array(&$this, '_isTestCaseFile'));
}
+ function &getPluginTestCaseList($directory = '.') {
+ $manager =& new TestManager();
+ return $manager->_getTestCaseList($directory);
+ }
+
+ function &getPluginGroupTestList($directory = '.') {
+ $manager =& new TestManager();
+ return $manager->_getTestGroupList($directory);
+ }
+
function &getGroupTestList($directory = '.') {
$manager =& new TestManager();
return $manager->_getTestGroupList($directory);
@@ -154,12 +175,12 @@ class TestManager {
}
function &_getTestGroupList($directory = '.') {
- $base = TEST_GROUPS . DIRECTORY_SEPARATOR;
$file_list =& $this->_getTestGroupFileList($directory);
$grouptests = array();
foreach ($file_list as $grouptest_file) {
$group = str_replace($this->_grouptest_extension, '',$grouptest_file);
- $group = str_replace($base, '', $group);
+ $group = str_replace(TEST_GROUPS . DIRECTORY_SEPARATOR, '', $group);
+ $group = str_replace(TEST_PLUGINS . DIRECTORY_SEPARATOR, '', $group);
$group = str_replace(DIRECTORY_SEPARATOR, ':', $group);
$grouptests[$grouptest_file] = $group;
}
@@ -169,7 +190,7 @@ class TestManager {
function &_getGroupTestClassNames($grouptest_file) {
$file = implode("\n", file($grouptest_file));
- preg_match("~lass\s+?(.*)\s+?extends GroupTest~", $file, $matches);
+ preg_match("~lass\s+?(.*)\s+?extends .*?GroupTest~", $file, $matches);
if (! empty($matches)) {
unset($matches[0]);
return $matches;
@@ -243,6 +264,29 @@ class CLITestManager extends TestManager {
}
return $buffer . "\n";
}
+
+ function &getPluginTestCaseList($directory = '.') {
+ $manager =& new CLITestManager();
+ $test_cases =& $manager->_getTestCaseList($directory);
+
+ $buffer = "Available test cases:\n";
+ foreach ($test_cases as $test_case) {
+ $buffer .= " " . $test_case . "\n";
+ }
+ return $buffer . "\n";
+ }
+
+ function &getPluginGroupTestList($directory = '.') {
+ $manager =& new CLITestManager();
+ $test_cases =& $manager->_getTestGroupList($directory);
+
+ $buffer = "Available test cases:\n";
+ foreach ($test_cases as $test_case) {
+ $buffer .= " " . $test_case . "\n";
+ }
+ return $buffer . "\n";
+ }
+
}
class HTMLTestManager extends TestManager {
@@ -290,6 +334,42 @@ class HTMLTestManager extends TestManager {
$buffer .= "</ul>\n";
return $buffer;
}
+
+ function &getPluginTestCaseList($directory = '.') {
+ $manager =& new HTMLTestManager();
+ $testcases =& $manager->_getTestCaseList($directory);
+
+ if (1 > count($testcases)) {
+ return "<p>No plugin test cases set up!</p>";
+ }
+ $buffer = "<p>Available plugin test cases:</p>\n<ul>";
+ foreach ($testcases as $testcase) {
+ $buffer .= "<li><a href='" . $manager->getBaseURL() .
+ "?plugin_case=" . urlencode($testcase) . "'>" .
+ $testcase . "</a></li>\n";
+ }
+
+ $buffer .= "</ul>\n";
+ return $buffer;
+ }
+
+ function &getPluginGroupTestList($directory = '.') {
+ $manager =& new HTMLTestManager();
+ $group_tests =& $manager->_getTestGroupList($directory);
+ if (1 > count($group_tests)) {
+ return "<p>No plugin test groups set up!</p>";
+ }
+ $buffer = "<p>Available plugin groups:</p>\n<ul>";
+ $buffer .= "<li><a href='" . $manager->getBaseURL() . "?plugin_group=all'>All tests</a></li>\n";
+ foreach ($group_tests as $group_test) {
+ $buffer .= "<li><a href='" . $manager->getBaseURL() . "?plugin_group={$group_test}'>" .
+ $group_test . "</a></li>\n";
+ }
+
+ $buffer .= "</ul>\n";
+ return $buffer;
+ }
+
}
/**
diff --git a/_test/lib/unittest.php b/_test/lib/unittest.php
new file mode 100644
index 000000000..220aa6c1b
--- /dev/null
+++ b/_test/lib/unittest.php
@@ -0,0 +1,5 @@
+<?php
+class Doku_UnitTestCase extends UnitTestCase {
+}
+class Doku_GroupTest extends GroupTest {
+}
diff --git a/_test/runtests.php b/_test/runtests.php
index c4a4f36b4..8b93efec3 100755
--- a/_test/runtests.php
+++ b/_test/runtests.php
@@ -9,7 +9,6 @@ require_once(DOKU_INC.'inc/events.php');
define('TEST_ROOT', dirname(__FILE__));
define('TMPL_FILESCHEME_PATH', TEST_ROOT . '/filescheme/');
-error_reporting(E_ALL ^ E_NOTICE);
require_once 'lib/testmanager.php';
TestManager::setup();
@@ -22,11 +21,17 @@ passes is printed on STDOUT. If ANY of the test cases fail (or raise
errors) details are printed on STDERR and this script returns a non-zero
exit code.
-c --case=NAME specify a test case by it's ID (see -i for list)
+ --pcase=NAME specify a plugin test case by it's ID
+ (see --plugincaselist for list)
-f --file=NAME specify a test case file (full or relative path)
-g --group=NAME specify a grouptest. If no grouptest is
specified, all test cases will be run.
+ --pgroup=NAME specify a plugin grouptest. If no grouptest is
+ specified, all test cases will be run.
-i --caselist list individual test cases by their ID
-l --grouplist list available grouptests
+ --plugincaselist list all individual plugin test cases by their ID
+ --plugingrouplist list avialable plugin grouptests
-s, --separator=SEP set the character(s) used to separate fail
details to SEP
-p, --path path to SimpleTest installation
@@ -41,14 +46,18 @@ EOD;
$opt_separator = '->';
$opt_caselist = FALSE;
$opt_grouplist = FALSE;
+$opt_plugincaselist = FALSE;
+$opt_plugingrouplist = FALSE;
$opt_caseid = FALSE;
+$top_plugincaseid = FALSE;
$opt_casefile = FALSE;
$opt_groupfile = FALSE;
+$opt_plugingroupfile = FALSE;
include_once(DOKU_INC.'inc/cliopts.php');
$short_opts = "c:f:g:hils:p:";
-$long_opts = array("case=","caselist","help", "file=", "group=", "grouplist", "separator=", "path=");
+$long_opts = array("case=","pcase=","caselist","help", "file=", "group=", "pgroup=", "grouplist", "plugincaselist", "plugingrouplist", "separator=", "path=");
$OPTS = Doku_Cli_Opts::getOptions(__FILE__,$short_opts,$long_opts);
if ( $OPTS->isError() ) {
fwrite( STDERR, $OPTS->getMessage() . "\n");
@@ -62,6 +71,9 @@ foreach ($OPTS->options as $key => $val) {
case 'case':
$opt_caseid = $val;
break;
+ case 'pcase':
+ $opt_plugincaseid = $val;
+ break;
case 'h':
case 'help':
usage();
@@ -74,6 +86,9 @@ foreach ($OPTS->options as $key => $val) {
case 'group':
$opt_groupfile = $val;
break;
+ case 'pgroup':
+ $opt_plugingroupfile = $val;
+ break;
case 'i':
case 'caselist':
$opt_caselist = TRUE;
@@ -82,6 +97,12 @@ foreach ($OPTS->options as $key => $val) {
case 'grouplist':
$opt_grouplist = TRUE;
break;
+ case 'plugincaselist':
+ $opt_plugincaselist = TRUE;
+ break;
+ case 'plugingrouplist':
+ $opt_plugingrouplist = TRUE;
+ break;
case 's':
case 'separator':
$opt_separator = $val;
@@ -111,8 +132,18 @@ if ($opt_caselist) {
echo CLITestManager::getTestCaseList(TEST_CASES);
}
+/* list plugin test cases */
+if ($opt_plugincaselist) {
+ echo CLITestManager::getPluginTestCaseList(TEST_PLUGINS);
+}
+
+/* list plugin group tests */
+if($opt_plugingrouplist) {
+ echo CLITestManager::getPluginGroupTestList(TEST_PLUGINS);
+}
+
/* exit if we've displayed a list */
-if ( $opt_grouplist || $opt_caselist ) {
+if ( $opt_grouplist || $opt_caselist || $opt_plugincaselist || $opt_plugingrouplist ) {
exit(0);
}
@@ -121,17 +152,35 @@ if ($opt_casefile) {
TestManager::runTestFile($opt_casefile, new CLIReporter($opt_separator));
exit(0);
}
-/* run a test case by id*/
+
+/* run a test case by id */
if ($opt_caseid) {
TestManager::runTestCase($opt_caseid, TEST_CASES, new CLIReporter($opt_separator));
exit(0);
}
+
+/* run a plugin test by case id */
+if ($opt_plugincaseid) {
+ TestManager::runTestCase($opt_plugincaseid, TEST_PLUGINS, new CLIReporter($opt_separator));
+ exit(0);
+}
+
/* run a grouptest */
if ($opt_groupfile) {
TestManager::runGroupTest($opt_groupfile, TEST_GROUPS,
new CLIReporter($opt_separator));
exit(0);
}
+
+/* run a plugin grouptest */
+if ($opt_plugingroupfile) {
+ TestManager::runGroupTest($opt_plugingroupfile, TEST_PLUGINS,
+ new CLIReporter($opt_separator));
+ exit(0);
+}
+
+/* run a plugin group test */
+//FIXME
/* run all tests */
TestManager::runAllTests(new CLIReporter($opt_separator));
exit(0);