From 8af66ab927067b9d8f9d71963e266a08967fa9d1 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 29 Jan 2010 17:08:40 +0100 Subject: table: Remove redundant parser data, update tests --- _test/cases/inc/parser/parser_footnote.test.php | 2 +- _test/cases/inc/parser/parser_i18n.test.php | 3 +-- _test/cases/inc/parser/parser_table.test.php | 32 ++++++++++++------------- 3 files changed, 18 insertions(+), 19 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/parser/parser_footnote.test.php b/_test/cases/inc/parser/parser_footnote.test.php index 2b00a0b2e..08d199182 100644 --- a/_test/cases/inc/parser/parser_footnote.test.php +++ b/_test/cases/inc/parser/parser_footnote.test.php @@ -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(8, 123)), array('cdata',array(' ')), array('footnote_close',array()), ))), diff --git a/_test/cases/inc/parser/parser_i18n.test.php b/_test/cases/inc/parser/parser_i18n.test.php index 8d587fe0e..e97a0cf51 100644 --- a/_test/cases/inc/parser/parser_i18n.test.php +++ b/_test/cases/inc/parser/parser_i18n.test.php @@ -110,13 +110,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(6, 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..981f85217 100644 --- a/_test/cases/inc/parser/parser_table.test.php +++ b/_test/cases/inc/parser/parser_table.test.php @@ -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(6, 121)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -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(6, 121)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -106,13 +106,13 @@ def'); array('table_open',array(0,1)), array('tablerow_open',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(6, 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); } @@ -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(6, 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); } @@ -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(6, 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); } @@ -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(6, 31)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -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(6, 51)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',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(6, 27)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -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(6, 121)), array('p_open',array()), array('cdata',array('def'.DOKU_PARSER_EOL)), array('p_close',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(6, 129)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',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(6, 155)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -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(6, 123)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',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(6, 129)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), -- cgit v1.2.3 From eba9da2d4784b9ff1fb8cdc545118a081c546e93 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 1 Feb 2010 11:39:00 +0100 Subject: Fix auth_ismanager calls in test cases --- _test/cases/inc/auth_admincheck.test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to '_test') 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); -- cgit v1.2.3 From f8f3bfb0816ee4940fd5efe295903a0f6b5e03f8 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 1 Feb 2010 11:56:51 +0100 Subject: Add tests for em from old bug reports (failing) --- _test/cases/inc/parser/parser_formatting.test.php | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to '_test') 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'); -- cgit v1.2.3 From 90df9a4d69a2e467433b419b94fe799d11590539 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 4 Feb 2010 14:50:10 +0100 Subject: Rewrite section edit handling according to #1860 --- _test/cases/inc/parser/parser_footnote.test.php | 4 +- _test/cases/inc/parser/parser_headers.test.php | 21 ---------- _test/cases/inc/parser/parser_i18n.test.php | 6 +-- _test/cases/inc/parser/parser_table.test.php | 52 ++++++++++++------------- 4 files changed, 30 insertions(+), 53 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/parser/parser_footnote.test.php b/_test/cases/inc/parser/parser_footnote.test.php index 08d199182..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(8, 123)), + array('table_close',array(123)), array('cdata',array(' ')), array('footnote_close',array()), ))), 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 e97a0cf51..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,7 +108,7 @@ def'); array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array(6, 153)), + array('table_close',array(153)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), diff --git a/_test/cases/inc/parser/parser_table.test.php b/_test/cases/inc/parser/parser_table.test.php index 981f85217..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(6, 121)), + 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(6, 121)), + array('table_close',array(121)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -103,10 +103,10 @@ 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(6, 7)), + array('table_close',array(7)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -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,7 +140,7 @@ def'); array('cdata',array(' Z ')), array('tableheader_close',array()), array('tablerow_close',array()), - array('table_close',array(6, 19)), + array('table_close',array(19)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -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,7 +175,7 @@ def'); array('cdata',array(' Z ')), array('tableheader_close',array()), array('tablerow_close',array()), - array('table_close',array(6, 23)), + array('table_close',array(23)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -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(6, 31)), + 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(6, 51)), + 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(6, 27)), + 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(6, 121)), + 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(6, 129)), + 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(6, 155)), + 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(6, 123)), + 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(6, 129)), + array('table_close',array(129)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), -- cgit v1.2.3 From 1542144fa455b70975cbc45f1f8160472be717a0 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 27 Feb 2010 19:31:01 +0100 Subject: Added new testcase for getID with Apache/CGI --- _test/cases/inc/pageutils_getid.test.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to '_test') diff --git a/_test/cases/inc/pageutils_getid.test.php b/_test/cases/inc/pageutils_getid.test.php index 8233ffb42..14a21cae2 100644 --- a/_test/cases/inc/pageutils_getid.test.php +++ b/_test/cases/inc/pageutils_getid.test.php @@ -64,5 +64,24 @@ 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'] = '/test/dokuwiki'; + $_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php'; + $_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki'; + + $this->assertEqual(getID(), 'wiki:dokuwiki'); + } + } //Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3 From 60f1722dc25b5fac36c90d94741fe95c6088078a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 28 Feb 2010 11:08:17 +0100 Subject: leave error reporting setting to init.php in runtests.php --- _test/runtests.php | 1 - 1 file changed, 1 deletion(-) (limited to '_test') diff --git a/_test/runtests.php b/_test/runtests.php index c4a4f36b4..e122c59fb 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(); -- cgit v1.2.3 From 06368e4dbb72cef5e440312251d11fbaea6242a9 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 2 Mar 2010 19:00:37 +0100 Subject: Fixed testcase and getID - FS#1908 FS#1831 FS#1838 $_SERVER['PATH_INFO'] is used now to determine the page id when using internal rewriting, in all testcases I've seen so far this variable was set correctly. There are also a couple of fallbacks if the variable doesn't exist, $_SERVER['SCRIPT_NAME'] is now preferred instead of custom path extraction which fails when doku.php is outside the document root. --- _test/cases/inc/pageutils_getid.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test') diff --git a/_test/cases/inc/pageutils_getid.test.php b/_test/cases/inc/pageutils_getid.test.php index 14a21cae2..790c869d1 100644 --- a/_test/cases/inc/pageutils_getid.test.php +++ b/_test/cases/inc/pageutils_getid.test.php @@ -76,7 +76,7 @@ class init_getID_test extends UnitTestCase { $_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'] = '/test/dokuwiki'; + $_SERVER['PATH_INFO'] = '/wiki/dokuwiki'; $_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php'; $_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki'; -- cgit v1.2.3 From 83e9d7a593638d1e91db108f2c285bb38207c437 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 2 Mar 2010 19:17:24 +0100 Subject: New testcase for getID() with data from FS#1838 --- _test/cases/inc/pageutils_getid.test.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to '_test') diff --git a/_test/cases/inc/pageutils_getid.test.php b/_test/cases/inc/pageutils_getid.test.php index 790c869d1..e3932a579 100644 --- a/_test/cases/inc/pageutils_getid.test.php +++ b/_test/cases/inc/pageutils_getid.test.php @@ -83,5 +83,24 @@ 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 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 : -- cgit v1.2.3 From b0ffdb5e96bb2bdbf27087b2f1335f7949ab8598 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 23 Mar 2010 15:22:21 +0100 Subject: Make tests PHP 5.3 compatible --- _test/cases/inc/html_hilight.test.php | 4 +--- _test/cases/inc/parser/xhtml_htmlphp.test.php | 4 +--- _test/cases/lib/exe/js_js_compress.test.php | 4 ++-- _test/lib/testmanager.php | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) (limited to '_test') 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/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/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/lib/testmanager.php b/_test/lib/testmanager.php index def86ca27..14cc20bf3 100644 --- a/_test/lib/testmanager.php +++ b/_test/lib/testmanager.php @@ -7,7 +7,7 @@ define('TEST_GROUPS',realpath(dirname(__FILE__).'/../cases')); define('TEST_CASES',realpath(dirname(__FILE__).'/../cases')); // 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 +15,6 @@ if (!extension_loaded('runkit')) { } } - class TestManager { var $_testcase_extension = '.test.php'; var $_grouptest_extension = '.group.php'; -- cgit v1.2.3 From 229529655f061863ec76db9ea557fef8b1a5161b Mon Sep 17 00:00:00 2001 From: YoBoY Date: Tue, 23 Mar 2010 22:50:41 +0100 Subject: Limiting use of readdir in the idx_indexLengths function (v2). Each searches on the wiki use this function. Scanning the index directory eachtime is time consuming with a constant series of disk access. Switching a normal search to use file_exists 1 or more times, and not readdir all the directory. Switching a wildcard search to use a lengths.idx file containing all the word lengths used in the wiki, file generated if a new configuration parameter $conf[readdircache] is not 0 and fixed to a time in second. Creation of a new function idx_listIndexLengths to do this part. --- _test/cases/inc/indexer_idx_indexlengths.test.php | 121 ++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 _test/cases/inc/indexer_idx_indexlengths.test.php (limited to '_test') 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 @@ +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 : -- cgit v1.2.3 From 08d7babffe1bded4620d0a3624bdd80522283138 Mon Sep 17 00:00:00 2001 From: Michael Klier Date: Tue, 30 Mar 2010 11:15:08 +0200 Subject: added support for plugin unittests This patch adds support to include plugin tests in the DokuWiki testsuite. Plugin tests are located in a dedicated directory _test/within a plugin directory. The naming convention of the test files follows the one used in DokuWikis testsuite. /_test/*.test.php -> single test /_test/*.group.php -> group test The plugin tests are accessible via the web interface of the test suite and via the cli interface. It is recommend to bundle plugin test in a plugin group test. The webinterface also allows to run all plugin tests at once. Test files must include: /_test/lib/unittest.php Example Test: require_once(DOKU_INC.'_test/lib/unittest.php'); class plugin_test extends Doku_UnitTestCase { function test() { $this->assertEqual(1,1); } } Example Group Test: require_once(DOKU_INC.'_test/lib/unittest.php'); class plugin_group_test extends Doku_GroupTest { function group_test() { $dir = dirname(__FILE__).'/'; $this->GroupTest('plugin_grouptest'); $this->addTestFile($dir . 'plugin.test1.php'); $this->addTestFile($dir . 'plugin.test2.php'); $this->addTestFile($dir . 'plugin.test3.php'); } } At the moment unittest.php contains only two meta classes so plugins tests don't have to inherit from the simpletest classes. This patch should be treated as intermediate step to allow for plugin tests. The testsuite wasn't designed to include plugin tests. It should probably be refactored at a later point. --- _test/index.php | 46 ++++++++++++++++++++++++ _test/lib/testmanager.php | 91 ++++++++++++++++++++++++++++++++++++++++++++--- _test/lib/unittest.php | 5 +++ _test/runtests.php | 56 +++++++++++++++++++++++++++-- 4 files changed, 190 insertions(+), 8 deletions(-) create mode 100644 _test/lib/unittest.php (limited to '_test') 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 14cc20bf3..96c9a57a2 100644 --- a/_test/lib/testmanager.php +++ b/_test/lib/testmanager.php @@ -5,6 +5,7 @@ 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') && function_exists('dl')) { @@ -59,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(); @@ -125,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; } @@ -142,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); @@ -153,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; } @@ -168,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; @@ -242,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 { @@ -289,6 +334,42 @@ class HTMLTestManager extends TestManager { $buffer .= "\n"; return $buffer; } + + function &getPluginTestCaseList($directory = '.') { + $manager =& new HTMLTestManager(); + $testcases =& $manager->_getTestCaseList($directory); + + if (1 > count($testcases)) { + return "

No plugin test cases set up!

"; + } + $buffer = "

Available plugin test cases:

\n
    "; + foreach ($testcases as $testcase) { + $buffer .= "
  • " . + $testcase . "
  • \n"; + } + + $buffer .= "
\n"; + return $buffer; + } + + function &getPluginGroupTestList($directory = '.') { + $manager =& new HTMLTestManager(); + $group_tests =& $manager->_getTestGroupList($directory); + if (1 > count($group_tests)) { + return "

No plugin test groups set up!

"; + } + $buffer = "

Available plugin groups:

\n\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 @@ +'; $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"); @@ -61,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(); @@ -73,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; @@ -81,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; @@ -110,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); } @@ -120,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); -- cgit v1.2.3 From c5c9e5ff8543947d9d7de31b2c4db510ebc41866 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sun, 4 Apr 2010 22:26:50 +0100 Subject: SafeFN test cases --- _test/cases/inc/safefn.test.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 _test/cases/inc/safefn.test.php (limited to '_test') 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 @@ +assertEqual(SafeFN::encode($utf8),$safe); + $this->assertEqual(SafeFN::decode($safe),$utf8); + } + } + +} +//Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3 From 5ab78106b0f9170d5e4930d0901862e4373a686f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 9 Jun 2010 21:43:10 +0200 Subject: Make XMLRPC date parsing more flexible FS#1966 Since the specs aren't 100% clear, dates might be passed in different formats by various XMLRPC clients. This patch makes date parsing a bit more flexible. Unit tests included. --- _test/cases/inc/IXR_Library_date.test.php | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 _test/cases/inc/IXR_Library_date.test.php (limited to '_test') 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 @@ +assertEqual($dt->getTimeStamp(),$test[1]); + } + } + +} +//Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3 From 8a52cdf35af9a714e9b330fa0aace6606b071c89 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 1 Jul 2010 19:43:47 +0200 Subject: XML-RPC fix for untyped string values FS#1993 includes unit tests. Extensions welcome. --- _test/cases/inc/IXR_Library_IXR_Message.test.php | 139 +++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 _test/cases/inc/IXR_Library_IXR_Message.test.php (limited to '_test') 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 @@ +wiki.getBackLinks change '; + + $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 = ' + + wiki.getBackLinks + + + change + + + '; + + $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 = 'wiki.getBackLinks change '; + + $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 = ' + + wiki.getBackLinks + + + + change + + + + '; + + $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 = 'wiki.getBackLinks'; + + $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 = ' + + wiki.getBackLinks + + + + + + + + '; + + $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 = ' + + wiki.putPage + + + start + + + test text + + + + + sum + xmlrpc edit + + + minor + 1 + + + + + '; + + $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 : -- cgit v1.2.3