From f05a1cc5fcdb4c2b6ee3cbf499f980f800dbd105 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 17 Oct 2013 23:11:33 +0200 Subject: Wrap thead around 1st row, when 1st cell at 1st row is tableheader. Implements FS#1764 --- _test/tests/inc/parser/parser_table.test.php | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/parser/parser_table.test.php b/_test/tests/inc/parser/parser_table.test.php index 542a307b8..5258afe3d 100644 --- a/_test/tests/inc/parser/parser_table.test.php +++ b/_test/tests/inc/parser/parser_table.test.php @@ -125,6 +125,7 @@ def'); array('cdata',array("\n\nabc")), array('p_close',array()), array('table_open',array(3, 1, 6)), + array('tablethead_open',array()), array('tablerow_open',array()), array('tableheader_open',array(1,NULL,1)), array('cdata',array(' X ')), @@ -136,6 +137,7 @@ def'); array('cdata',array(' Z ')), array('tableheader_close',array()), array('tablerow_close',array()), + array('tablethead_close',array()), array('table_close',array(19)), array('p_open',array()), array('cdata',array('def')), @@ -146,6 +148,55 @@ def'); $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); } + + function testTableHeadersMultilines() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X | Y ^ Z | +| A | B | C | +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 2, 6)), + array('tablethead_open',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X ')), + array('tableheader_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' Y ')), + array('tablecell_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablethead_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' A ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' B ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' C ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('table_close',array(33)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + + } function testCellAlignment() { $this->P->addMode('table',new Doku_Parser_Mode_Table()); -- cgit v1.2.3 From 688ce8d8ab7995792e25b09b8481dc04c8363aab Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 18 Oct 2013 14:38:10 +0100 Subject: update tests for use with changes --- _test/tests/inc/parser/parser_table.test.php | 195 +++++++++++++++++++++++++-- 1 file changed, 183 insertions(+), 12 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/parser/parser_table.test.php b/_test/tests/inc/parser/parser_table.test.php index 5258afe3d..6961d568c 100644 --- a/_test/tests/inc/parser/parser_table.test.php +++ b/_test/tests/inc/parser/parser_table.test.php @@ -125,7 +125,6 @@ def'); array('cdata',array("\n\nabc")), array('p_close',array()), array('table_open',array(3, 1, 6)), - array('tablethead_open',array()), array('tablerow_open',array()), array('tableheader_open',array(1,NULL,1)), array('cdata',array(' X ')), @@ -137,7 +136,6 @@ def'); array('cdata',array(' Z ')), array('tableheader_close',array()), array('tablerow_close',array()), - array('tablethead_close',array()), array('table_close',array(19)), array('p_open',array()), array('cdata',array('def')), @@ -145,16 +143,15 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } - function testTableHeadersMultilines() { + function testTableHead() { $this->P->addMode('table',new Doku_Parser_Mode_Table()); $this->P->parse(' abc -^ X | Y ^ Z | -| A | B | C | +^ X ^ Y ^ Z ^ def'); $calls = array ( @@ -162,20 +159,70 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3, 2, 6)), + array('table_open',array(3, 1, 6)), array('tablethead_open',array()), array('tablerow_open',array()), array('tableheader_open',array(1,NULL,1)), array('cdata',array(' X ')), array('tableheader_close',array()), - array('tablecell_open',array(1,NULL,1)), + array('tableheader_open',array(1,NULL,1)), array('cdata',array(' Y ')), - array('tablecell_close',array()), + array('tableheader_close',array()), array('tableheader_open',array(1,NULL,1)), array('cdata',array(' Z ')), array('tableheader_close',array()), array('tablerow_close',array()), array('tablethead_close',array()), + array('table_close',array(19)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); + + } + + function testTableHeadMultiline() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X1 ^ Y1 ^ Z1 ^ +^ X2 ^ Y2 ^ Z2 ^ +| A | B | C | +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 3, 6)), + array('tablethead_open',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Y1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z1 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X2 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Y2 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z2 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablethead_close',array()), array('tablerow_open',array()), array('tablecell_open',array(1,NULL,1)), array('cdata',array(' A ')), @@ -187,14 +234,14 @@ def'); array('cdata',array(' C ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array(33)), + array('table_close',array(53)), array('p_open',array()), array('cdata',array('def')), array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } @@ -380,6 +427,131 @@ def'); $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); } + function testRowSpanTableHead() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X1 ^ Y1 ^ Z1 ^ +^ X2 ^ ::: ^ Z2 ^ +| A3 | B3 | C3 | +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 3, 6)), + array('tablethead_open',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,2)), + array('cdata',array(' Y1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z1 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X2 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z2 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablethead_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' A3 ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' B3 ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' C3 ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('table_close',array(57)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); + + } + + function testRowSpanAcrossTableHeadBoundary() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X1 ^ Y1 ^ Z1 ^ +^ X2 ^ ::: ^ Z2 ^ +| A3 | ::: | C3 | +| A4 | ::: | C4 | +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 4, 6)), + array('tablethead_open',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,2)), + array('cdata',array(' Y1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z1 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X2 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z2 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablethead_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' A3 ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,2)), + array('cdata',array('')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' C3 ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' A4 ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' C4 ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('table_close',array(76)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); + + } + function testCellAlignmentFormatting() { $this->P->addMode('table',new Doku_Parser_Mode_Table()); $this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong')); @@ -678,4 +850,3 @@ def'); $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); } } - -- cgit v1.2.3 From e0328e30d24321e319e2733192bf829b9000c5eb Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 18 Oct 2013 14:42:46 +0100 Subject: swap order ot test parameters to match expected,actual as per documentation & test output --- _test/tests/inc/parser/parser_table.test.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/parser/parser_table.test.php b/_test/tests/inc/parser/parser_table.test.php index 6961d568c..d4596bc8a 100644 --- a/_test/tests/inc/parser/parser_table.test.php +++ b/_test/tests/inc/parser/parser_table.test.php @@ -44,7 +44,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testTableWinEOL() { @@ -84,7 +84,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testEmptyTable() { @@ -109,7 +109,7 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testTableHeaders() { @@ -276,7 +276,7 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testCellSpan() { @@ -318,7 +318,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testCellRowSpan() { @@ -366,7 +366,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testCellRowSpanFirstRow() { @@ -424,7 +424,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testRowSpanTableHead() { @@ -588,7 +588,7 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } @@ -634,7 +634,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } // This is really a failing test - formatting able to spread across cols @@ -689,7 +689,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } // This is really a failing test - unformatted able to spread across cols @@ -740,7 +740,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testTableLinebreak() { @@ -788,7 +788,7 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } // This is really a failing test - footnote able to spread across cols @@ -847,6 +847,6 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } } -- cgit v1.2.3 From 7ec53b177159137ba25d9a02a6551f7a5c870827 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 12 Mar 2014 18:19:04 +0000 Subject: fix io_rmdir_test::test_nopes() for symlinks in paths --- _test/tests/inc/io_rmdir.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test') diff --git a/_test/tests/inc/io_rmdir.test.php b/_test/tests/inc/io_rmdir.test.php index 3de57fa86..1c0eccb38 100644 --- a/_test/tests/inc/io_rmdir.test.php +++ b/_test/tests/inc/io_rmdir.test.php @@ -4,7 +4,7 @@ class io_rmdir_test extends DokuWikiTest { function test_nopes(){ // set up test dir - $dir = io_mktmpdir(); + $dir = realpath(io_mktmpdir()); $top = dirname($dir); $this->assertTrue($dir !== false); $this->assertTrue(is_dir($dir)); -- cgit v1.2.3 From e950d12fe605bb70cca7a030eab49f5e29719f0b Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Thu, 13 Mar 2014 17:55:21 +0000 Subject: improvements to double quote matching --- _test/tests/inc/parser/parser_quotes.test.php | 131 ++++++++++++++++++++------ 1 file changed, 103 insertions(+), 28 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/parser/parser_quotes.test.php b/_test/tests/inc/parser/parser_quotes.test.php index b82328212..6f174ddae 100644 --- a/_test/tests/inc/parser/parser_quotes.test.php +++ b/_test/tests/inc/parser/parser_quotes.test.php @@ -10,8 +10,9 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { } function testSingleQuoteOpening() { + $raw = "Foo 'hello Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo 'hello Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -23,12 +24,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuoteOpeningSpecial() { + $raw = "Foo said:'hello Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo said:'hello Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -40,12 +42,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuoteClosing() { + $raw = "Foo hello' Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo hello' Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -57,12 +60,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuoteClosingSpecial() { + $raw = "Foo hello') Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo hello') Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -74,12 +78,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuotes() { + $raw = "Foo 'hello' Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo 'hello' Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -93,12 +98,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testApostrophe() { + $raw = "hey it's fine weather today"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("hey it's fine weather today"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -110,13 +116,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuotesSpecial() { + $raw = "Foo ('hello') Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo ('hello') Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -130,12 +137,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteOpening() { + $raw = 'Foo "hello Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo "hello Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -147,12 +155,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteOpeningSpecial() { + $raw = 'Foo said:"hello Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo said:"hello Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -164,12 +173,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteClosing() { + $raw = 'Foo hello" Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo hello" Bar'); + $this->H->status['doublequote'] = 1; + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -181,12 +192,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteClosingSpecial() { + $raw = 'Foo hello") Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo hello") Bar'); + $this->H->status['doublequote'] = 1; + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -198,12 +211,31 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); + } + function testDoubleQuoteClosingSpecial2() { + $raw = 'Foo hello") Bar'; + $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); + $this->H->status['doublequote'] = 0; + $this->P->parse($raw); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo hello')), + array('doublequoteopening',array()), + array('cdata',array(') Bar')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuotes() { + $raw = 'Foo "hello" Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo "hello" Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -217,12 +249,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuotesSpecial() { + $raw = 'Foo ("hello") Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo ("hello") Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -236,12 +269,54 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); + } + + function testDoubleQuotesEnclosingBrackets() { + $raw = 'Foo "{hello}" Bar'; + $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); + $this->P->parse($raw); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('doublequoteopening',array()), + array('cdata',array('{hello}')), + array('doublequoteclosing',array()), + array('cdata',array(' Bar')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext - '.$raw); + } + + function testDoubleQuotesEnclosingLink() { + $raw = 'Foo "[[www.domain.com]]" Bar'; + $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); + $this->P->parse($raw); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('doublequoteopening',array()), + array('cdata',array('[[www.domain.com]]')), + array('doublequoteclosing',array()), + array('cdata',array(' Bar')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw); } + function testAllQuotes() { + $raw = 'There was written "He thought \'It\'s a man\'s world\'".'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('There was written "He thought \'It\'s a man\'s world\'".'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -262,7 +337,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw); } } -- cgit v1.2.3 From 410c9c400f5c72e45e32761bf18d9816b62f865e Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Thu, 13 Mar 2014 20:05:58 +0000 Subject: remove test expectation for E_USER_WARNING --- _test/tests/inc/parserutils_get_renderer.test.php | 4 ---- 1 file changed, 4 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/parserutils_get_renderer.test.php b/_test/tests/inc/parserutils_get_renderer.test.php index 69aeb3b19..0f373227d 100644 --- a/_test/tests/inc/parserutils_get_renderer.test.php +++ b/_test/tests/inc/parserutils_get_renderer.test.php @@ -45,10 +45,6 @@ class parserutils_get_renderer_test extends DokuWikiTest { } // test fallback fails - /** - * @expectedException PHPUnit_Framework_Error - * @expectedExceptionCode E_USER_WARNING - */ function test_p_get_renderer_fallback_fail() { global $conf; -- cgit v1.2.3 From b23560022e3a99310a04296b3c385325e7abb747 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sun, 16 Mar 2014 18:32:07 +0000 Subject: Fix longstanding issue with cache class & cachetime setting 1. cachetime setting should only be applied to the cache_renderer class. Previously it was applied to cache_parser (and by extension cache_handler). 2. two special cachetime values, -1 & 0, weren't handled, per FS#2183 To handle the cachetime setting, -1, disable caching, a new property _nocache is added. When that property is true, any cache file must not be used and storecache() should not store any values --- _test/tests/inc/cache_use.test.php | 56 ++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/cache_use.test.php b/_test/tests/inc/cache_use.test.php index f5349df13..292f5c975 100644 --- a/_test/tests/inc/cache_use.test.php +++ b/_test/tests/inc/cache_use.test.php @@ -6,22 +6,22 @@ * Tests if caching can actually be used */ class cache_use_test extends DokuWikiTest { - /** @var cache_renderer $cache */ + /** @var cache_parser $cache */ private $cache; function setUp() { - global $ID; + global $ID, $conf; parent::setUp(); $ID = 'cached'; $file = wikiFN($ID); + $conf['cachetime'] = 0; // ensure the value is not -1, which disables caching saveWikiText($ID, 'Content', 'Created'); // set the modification time a second in the past in order to ensure that the cache is newer than the page touch($file, time()-1); - # Create cache. Note that the metadata cache is used as the xhtml cache triggers metadata rendering - $this->cache = new cache_renderer($ID, $file, 'metadata'); + $this->cache = new cache_renderer($ID, $file, 'xhtml'); $this->cache->storeCache('Test'); } @@ -29,8 +29,52 @@ class cache_use_test extends DokuWikiTest { $this->assertTrue($this->cache->useCache()); } - + /** + * In all the following tests the cache should not be usable + * as such, they are meaningless if test_use didn't pass. + * + * @depends test_use + */ function test_purge() { - $this->assertFalse($this->cache->useCache(array('purge' => true))); + /* @var Input $INPUT */ + global $INPUT; + $INPUT->set('purge',1); + + $this->assertFalse($this->cache->useCache()); + $this->assertNotEmpty($this->cache->depends['purge']); + } + + /** + * @depends test_use + */ + function test_filedependency() { + // give the dependent src file the same mtime as the cache + touch($this->cache->file, filemtime($this->cache->cache)); + $this->assertFalse($this->cache->useCache()); + } + + /** + * @depends test_use + */ + function test_age() { + // need to age both our source file & the cache + $age = 10; + $time = time() - $age - 1; // older than age + + touch($this->cache->file, $time - 1); + touch($this->cache->cache, $time); + + $this->assertFalse($this->cache->useCache(array('age' => $age))); + } + + /** + * @depends test_use + */ + function test_confnocaching() { + global $conf; + $conf['cachetime'] = -1; // disables renderer caching + + $this->assertFalse($this->cache->useCache()); + $this->assertNotEmpty($this->cache->_nocache); } } \ No newline at end of file -- cgit v1.2.3 From 5f3da53e253bc878946671173feef853a48604b8 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sun, 16 Mar 2014 19:43:40 +0000 Subject: put PHPDocs comment back the way it should be --- _test/tests/inc/cache_use.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test') diff --git a/_test/tests/inc/cache_use.test.php b/_test/tests/inc/cache_use.test.php index 292f5c975..c54a472a3 100644 --- a/_test/tests/inc/cache_use.test.php +++ b/_test/tests/inc/cache_use.test.php @@ -6,7 +6,7 @@ * Tests if caching can actually be used */ class cache_use_test extends DokuWikiTest { - /** @var cache_parser $cache */ + /** @var cache_renderer $cache */ private $cache; function setUp() { -- cgit v1.2.3 From c2a1d01e2e905ab3d7fa3009aeb140fcefc32f9e Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sun, 16 Mar 2014 20:26:44 +0000 Subject: update unittests for THEAD rules --- _test/tests/inc/parser/parser_table.test.php | 49 +++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to '_test') diff --git a/_test/tests/inc/parser/parser_table.test.php b/_test/tests/inc/parser/parser_table.test.php index 3e9651d14..a9b4e284c 100644 --- a/_test/tests/inc/parser/parser_table.test.php +++ b/_test/tests/inc/parser/parser_table.test.php @@ -152,6 +152,7 @@ def'); $this->P->parse(' abc ^ X ^ Y ^ Z ^ +| x | y | z | def'); $calls = array ( @@ -159,7 +160,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3, 1, 6)), + array('table_open',array(3, 2, 6)), array('tablethead_open',array()), array('tablerow_open',array()), array('tableheader_open',array(1,NULL,1)), @@ -173,6 +174,52 @@ def'); array('tableheader_close',array()), array('tablerow_close',array()), array('tablethead_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' x ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' y ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' z ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('table_close',array(33)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); + + } + + function testTableHeadOneRowTable() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X ^ Y ^ Z ^ +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 1, 6)), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Y ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z ')), + array('tableheader_close',array()), + array('tablerow_close',array()), array('table_close',array(19)), array('p_open',array()), array('cdata',array('def')), -- cgit v1.2.3 From 496e3a6f34d97e44e44340c1fbd2d3cbc262c05c Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 17 Mar 2014 23:03:53 +0100 Subject: completely new base for CLI scripts This introduces an abstract base class that command line tools need to inherit from. It provides a simple framework for registering accepted command line options and provides commonly needed things like help output and colored text. Existing CLI scripts still need to be converted. --- _test/tests/inc/cli_options.test.php | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 _test/tests/inc/cli_options.test.php (limited to '_test') diff --git a/_test/tests/inc/cli_options.test.php b/_test/tests/inc/cli_options.test.php new file mode 100644 index 000000000..1d121d7ce --- /dev/null +++ b/_test/tests/inc/cli_options.test.php @@ -0,0 +1,56 @@ +registerOption('exclude', 'exclude files', 'x', true); + + $args = array('-x', 'foo', 'bang'); + $options->parseOptions($args); + + $this->assertEquals('foo', $options->getOpt('exclude')); + $this->assertEquals(array('bang'), $args); + $this->assertFalse($options->getOpt('nothing')); + } + + function test_simplelong1() { + $options = new DokuCLI_Options(); + $options->registerOption('exclude', 'exclude files', 'x', true); + + $args = array('--exclude', 'foo', 'bang'); + $options->parseOptions($args); + + $this->assertEquals('foo', $options->getOpt('exclude')); + $this->assertEquals(array('bang'), $args); + $this->assertFalse($options->getOpt('nothing')); + } + + function test_simplelong2() { + $options = new DokuCLI_Options(); + $options->registerOption('exclude', 'exclude files', 'x', true); + + $args = array('--exclude=foo', 'bang'); + $options->parseOptions($args); + + $this->assertEquals('foo', $options->getOpt('exclude')); + $this->assertEquals(array('bang'), $args); + $this->assertFalse($options->getOpt('nothing')); + } + + function test_complex() { + $options = new DokuCLI_Options(); + + $options->registerOption('plugins', 'run on plugins only', 'p'); + $options->registerCommand('status', 'display status info'); + $options->registerOption('long', 'display long lines', 'l', false, 'status'); + + $args = array('-p', 'status', '--long', 'foo'); + $options->parseOptions($args); + + $this->assertEquals('status', $options->getCmd()); + $this->assertTrue($options->getOpt('plugins')); + $this->assertTrue($options->getOpt('long')); + $this->assertEquals(array('foo'), $args); + } +} \ No newline at end of file -- cgit v1.2.3 From d48bcdb42c1e80fa258ebbd70d9fe6f649237a78 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 20 Mar 2014 21:01:06 +0100 Subject: fixed tests --- _test/tests/inc/cli_options.test.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/cli_options.test.php b/_test/tests/inc/cli_options.test.php index 1d121d7ce..ab03ee29b 100644 --- a/_test/tests/inc/cli_options.test.php +++ b/_test/tests/inc/cli_options.test.php @@ -4,37 +4,37 @@ class cli_options extends DokuWikiTest { function test_simpleshort() { $options = new DokuCLI_Options(); - $options->registerOption('exclude', 'exclude files', 'x', true); + $options->registerOption('exclude', 'exclude files', 'x', 'file'); - $args = array('-x', 'foo', 'bang'); - $options->parseOptions($args); + $options->args = array('-x', 'foo', 'bang'); + $options->parseOptions(); $this->assertEquals('foo', $options->getOpt('exclude')); - $this->assertEquals(array('bang'), $args); + $this->assertEquals(array('bang'), $options->args); $this->assertFalse($options->getOpt('nothing')); } function test_simplelong1() { $options = new DokuCLI_Options(); - $options->registerOption('exclude', 'exclude files', 'x', true); + $options->registerOption('exclude', 'exclude files', 'x', 'file'); - $args = array('--exclude', 'foo', 'bang'); - $options->parseOptions($args); + $options->args = array('--exclude', 'foo', 'bang'); + $options->parseOptions(); $this->assertEquals('foo', $options->getOpt('exclude')); - $this->assertEquals(array('bang'), $args); + $this->assertEquals(array('bang'), $options->args); $this->assertFalse($options->getOpt('nothing')); } function test_simplelong2() { $options = new DokuCLI_Options(); - $options->registerOption('exclude', 'exclude files', 'x', true); + $options->registerOption('exclude', 'exclude files', 'x', 'file'); - $args = array('--exclude=foo', 'bang'); - $options->parseOptions($args); + $options->args = array('--exclude=foo', 'bang'); + $options->parseOptions(); $this->assertEquals('foo', $options->getOpt('exclude')); - $this->assertEquals(array('bang'), $args); + $this->assertEquals(array('bang'), $options->args); $this->assertFalse($options->getOpt('nothing')); } @@ -45,12 +45,12 @@ class cli_options extends DokuWikiTest { $options->registerCommand('status', 'display status info'); $options->registerOption('long', 'display long lines', 'l', false, 'status'); - $args = array('-p', 'status', '--long', 'foo'); - $options->parseOptions($args); + $options->args = array('-p', 'status', '--long', 'foo'); + $options->parseOptions(); $this->assertEquals('status', $options->getCmd()); $this->assertTrue($options->getOpt('plugins')); $this->assertTrue($options->getOpt('long')); - $this->assertEquals(array('foo'), $args); + $this->assertEquals(array('foo'), $options->args); } } \ No newline at end of file -- cgit v1.2.3 From 56ecd4f4244ec276b92fb0d96ae23484463e6484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 14 Apr 2014 23:07:56 +0300 Subject: tar: test. skip instead of error if bz2 or zlib extension is missing --- _test/tests/inc/tar.test.php | 51 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 417f1a853..91e71632c 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -1,6 +1,32 @@ markTestSkipped('skipping all zlib tests. Need zlib extension'); + } + } + + /** + * dependency test to test available extensions + * fills $this->extensions array + */ + public function test_extensions() { + if (!extension_loaded('zlib')) { + $this->markTestSkipped('skipping all zlib tests. Need zlib extension'); + } + if (!extension_loaded('bz2')) { + $this->markTestSkipped('skipping all bz2 tests. Need bz2 extension'); + } + } /** * simple test that checks that the given filenames and contents can be grepped from @@ -58,8 +84,6 @@ class Tar_TestCase extends DokuWikiTest { $tar->addData('another/testdata3.txt', 'testcontent3'); $tar->close(); -copy ($tmp, '/tmp/test.tar'); - $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number $data = file_get_contents($tmp); @@ -85,11 +109,12 @@ copy ($tmp, '/tmp/test.tar'); /** * List the contents of the prebuilt TAR files + * @depends test_extensions */ public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -107,12 +132,13 @@ copy ($tmp, '/tmp/test.tar'); /** * Extract the prebuilt tar files + * @depends test_extensions */ public function test_tarextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -133,12 +159,13 @@ copy ($tmp, '/tmp/test.tar'); /** * Extract the prebuilt tar files with component stripping + * @depends test_extensions */ public function test_compstripextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -159,12 +186,13 @@ copy ($tmp, '/tmp/test.tar'); /** * Extract the prebuilt tar files with prefix stripping + * @depends test_extensions */ public function test_prefixstripextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -185,12 +213,13 @@ copy ($tmp, '/tmp/test.tar'); /** * Extract the prebuilt tar files with include regex + * @depends test_extensions */ public function test_includeextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -210,12 +239,13 @@ copy ($tmp, '/tmp/test.tar'); /** * Extract the prebuilt tar files with exclude regex + * @depends test_extensions */ public function test_excludeextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -235,6 +265,7 @@ copy ($tmp, '/tmp/test.tar'); /** * Check the extension to compression guesser + * @depends test_extensions */ public function test_filetype() { $tar = new Tar(); @@ -249,6 +280,9 @@ copy ($tmp, '/tmp/test.tar'); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } + /** + * @depends test_ext_zlib + */ public function test_longpathextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); @@ -338,6 +372,7 @@ copy ($tmp, '/tmp/test.tar'); /** * Extract a tarbomomb + * @depends test_ext_zlib */ public function test_tarbomb() { $dir = dirname(__FILE__).'/tar'; -- cgit v1.2.3 From 9efc0669141c20c5c3cf1c76384b8c85734788c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 14 Apr 2014 23:16:49 +0300 Subject: run as much as possible (fill extensions conditionally), skip missing ext once --- _test/tests/inc/tar.test.php | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 91e71632c..76037d401 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -4,7 +4,16 @@ class Tar_TestCase extends DokuWikiTest { /** * file extensions that several tests use */ - protected $extensions = array('tar', 'tgz', 'tbz'); + protected $extensions = array('tar'); + + public function setUp() { + if (extension_loaded('zlib')) { + $this->extensions[] = 'tgz'; + } + if (extension_loaded('bz2')) { + $this->extensions[] = 'tbz'; + } + } /* * dependency for tests needing zlib extension to pass @@ -15,16 +24,12 @@ class Tar_TestCase extends DokuWikiTest { } } - /** - * dependency test to test available extensions - * fills $this->extensions array + /* + * dependency for tests needing zlib extension to pass */ - public function test_extensions() { - if (!extension_loaded('zlib')) { - $this->markTestSkipped('skipping all zlib tests. Need zlib extension'); - } + public function test_ext_bz2() { if (!extension_loaded('bz2')) { - $this->markTestSkipped('skipping all bz2 tests. Need bz2 extension'); + $this->markTestSkipped('skipping all bzip2 tests. Need bz2 extension'); } } @@ -109,7 +114,6 @@ class Tar_TestCase extends DokuWikiTest { /** * List the contents of the prebuilt TAR files - * @depends test_extensions */ public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; @@ -132,7 +136,6 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files - * @depends test_extensions */ public function test_tarextract() { $dir = dirname(__FILE__).'/tar'; @@ -159,7 +162,6 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with component stripping - * @depends test_extensions */ public function test_compstripextract() { $dir = dirname(__FILE__).'/tar'; @@ -186,7 +188,6 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with prefix stripping - * @depends test_extensions */ public function test_prefixstripextract() { $dir = dirname(__FILE__).'/tar'; @@ -213,7 +214,6 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with include regex - * @depends test_extensions */ public function test_includeextract() { $dir = dirname(__FILE__).'/tar'; @@ -239,7 +239,6 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with exclude regex - * @depends test_extensions */ public function test_excludeextract() { $dir = dirname(__FILE__).'/tar'; @@ -265,7 +264,6 @@ class Tar_TestCase extends DokuWikiTest { /** * Check the extension to compression guesser - * @depends test_extensions */ public function test_filetype() { $tar = new Tar(); -- cgit v1.2.3 From 64d063f11abb3946bad9d076a56b0fc51ccff127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 16 Apr 2014 11:22:46 +0300 Subject: call parent constructor as well --- _test/tests/inc/tar.test.php | 1 + 1 file changed, 1 insertion(+) (limited to '_test') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 76037d401..15453b16d 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -7,6 +7,7 @@ class Tar_TestCase extends DokuWikiTest { protected $extensions = array('tar'); public function setUp() { + parent::setUp(); if (extension_loaded('zlib')) { $this->extensions[] = 'tgz'; } -- cgit v1.2.3 From 7a7b77ef2f397e944e30abb47e0d348639e1b821 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 30 Apr 2014 16:06:00 +0200 Subject: some updates on phpunit docs and settings --- _test/README | 56 +++++++++++++++++++------------------------------------ _test/phpunit.xml | 5 ++++- 2 files changed, 23 insertions(+), 38 deletions(-) (limited to '_test') diff --git a/_test/README b/_test/README index 5220248b2..f0db2a550 100644 --- a/_test/README +++ b/_test/README @@ -9,35 +9,28 @@ This is the test suite to automatically test various parts of DokuWiki. ===== PHPUnit Installation ====== -==== via PEAR installer ==== +You can install phpunit through your distribution's package manager or simply +download the newest phar file into the _test directory: - pear config-set auto_discover 1 - pear install pear.phpunit.de/PHPUnit - -==== via Composer ==== - -Include a composer.json file in your project, which can be as minimal as: - - -{ - "require-dev": { - "phpunit/phpunit": "3.7.*" - } -} - - -==== via PHP archive (PHAR) ==== - -Download http://pear.phpunit.de/get/phpunit.phar and make it executable on your system. + cd _test/ + wget https://phar.phpunit.de/phpunit.phar ===== Running all tests ===== -Just change to the ''_test'' directory and run phpunit: +Just change to the ''_test'' directory and run phpunit (depending on your install +method): cd _test/ phpunit +or + + cd _test/ + php phpunit.phar + +===== Troubleshooting ===== + PHPUnit will fail on some systems with a //headers already sent// error. This is a known problem with PHPUnit, the error can be avoided by passing the '--stderr' flag to phpunit: @@ -46,8 +39,10 @@ This is a known problem with PHPUnit, the error can be avoided by passing the On windows you may have to enable OpenSSL support for https tests. Some of them point to httpclient_http.tests.php on the failure. -To enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' to your ''windows\system32'' folder -and add the following line to your php.ini in the extension section: +To enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' +to your ''windows\system32'' folder and add the following line to your php.ini +in the extension section: + extension=php_openssl.dll @@ -56,13 +51,13 @@ extension=php_openssl.dll You can run a single test file by providing it as an argument to phpunit: - phpunit --stderr tests/inc/common_cleanText.test.php + phpunit tests/inc/common_cleanText.test.php You can also use groups to exclude certain test from running. For example use the following command to avoid long running test or tests accessing the Internet. - phpunit --stderr --exclude-group slow,internet + phpunit --exclude-group slow,internet ===== Create new Tests ===== @@ -71,23 +66,10 @@ folder. Please respect the folder structure and naming convention. Inside the file, implement a class, extending 'DokuWikiTest'. Every method, starting with 'test' will be called as a test (e.g. 'testIfThisIsValid'); - ===== TODO for the test framework ===== - * test cross platform compatibility: especially test windows - * update http://www.dokuwiki.org/devel:unittesting * optional: add helper methods to TestRequest for easy form submission * createForm(), ... * check PHP Unit test_helpers https://github.com/sebastianbergmann/php-test-helpers -===== Migration Protocol ===== - -The following tests were not migrated: - - * inc/indexer_idx_indexlengths (fs dependencies) - * inc/mail_send (integration test) - * inc/parser/parser_formatting - * inc/parser/xhtml_htmlphp (runkit) - * inc/parser/xhtml_links - diff --git a/_test/phpunit.xml b/_test/phpunit.xml index fc7dd8be0..25506b1ae 100644 --- a/_test/phpunit.xml +++ b/_test/phpunit.xml @@ -1,7 +1,10 @@ + convertNoticesToExceptions="false" + colors="true" + stderr="true" + > -- cgit v1.2.3 From 6920d2fd3e30c9cb3abd500fe18273974da7182f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 30 Apr 2014 19:44:50 +0200 Subject: add new valid() method to $INPUT #667 --- _test/tests/inc/input.test.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php index 59b5ea4b9..bedfcfdba 100644 --- a/_test/tests/inc/input.test.php +++ b/_test/tests/inc/input.test.php @@ -214,6 +214,24 @@ class input_test extends DokuWikiTest { $this->assertEquals('bla',$test); } + public function test_valid(){ + $_REQUEST = $this->data; + $_POST = $this->data; + $_GET = $this->data; + $INPUT = new Input(); + + $valids = array(17, 'foo'); + $this->assertSame(null, $INPUT->valid('nope', $valids)); + $this->assertSame('bang', $INPUT->valid('nope', $valids, 'bang')); + $this->assertSame(17, $INPUT->valid('int', $valids)); + $this->assertSame('foo', $INPUT->valid('string', $valids)); + + $valids = array(true); + $this->assertSame(true, $INPUT->valid('string', $valids)); + $this->assertSame(true, $INPUT->valid('one', $valids)); + $this->assertSame(null, $INPUT->valid('zero', $valids)); + } + public function test_extract(){ $_REQUEST = $this->data; $_POST = $this->data; -- cgit v1.2.3 From 363404184fcd4ec7b0149662d99a22f2cc78020b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 30 Apr 2014 20:03:13 +0200 Subject: fixed some test inheriting from the wrong parent --- _test/tests/inc/PassHash.test.php | 2 +- _test/tests/inc/auth_password.test.php | 2 +- _test/tests/inc/parser/parser.inc.php | 2 +- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 2 +- _test/tests/inc/utf8_romanize.test.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/PassHash.test.php b/_test/tests/inc/PassHash.test.php index b6cb07090..1d34aa696 100644 --- a/_test/tests/inc/PassHash.test.php +++ b/_test/tests/inc/PassHash.test.php @@ -5,7 +5,7 @@ * * most tests are in auth_password.test.php */ -class PassHash_test extends PHPUnit_Framework_TestCase { +class PassHash_test extends DokuWikiTest { function test_hmac(){ // known hashes taken from https://code.google.com/p/yii/issues/detail?id=1942 diff --git a/_test/tests/inc/auth_password.test.php b/_test/tests/inc/auth_password.test.php index 27e03be60..07b9f5bb2 100644 --- a/_test/tests/inc/auth_password.test.php +++ b/_test/tests/inc/auth_password.test.php @@ -1,6 +1,6 @@ Date: Wed, 30 Apr 2014 20:05:35 +0200 Subject: added another test for arrays --- _test/tests/inc/input.test.php | 1 + 1 file changed, 1 insertion(+) (limited to '_test') diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php index bedfcfdba..cec0b80f6 100644 --- a/_test/tests/inc/input.test.php +++ b/_test/tests/inc/input.test.php @@ -225,6 +225,7 @@ class input_test extends DokuWikiTest { $this->assertSame('bang', $INPUT->valid('nope', $valids, 'bang')); $this->assertSame(17, $INPUT->valid('int', $valids)); $this->assertSame('foo', $INPUT->valid('string', $valids)); + $this->assertSame(null, $INPUT->valid('array', $valids)); $valids = array(true); $this->assertSame(true, $INPUT->valid('string', $valids)); -- cgit v1.2.3 From 9d60a747702d8da1436fda4de3126116a7db002b Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 13 May 2014 16:14:44 +0100 Subject: Issue 694: fix failing test - set filemtimes explicitly in test setup --- _test/tests/inc/cache_use.test.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/cache_use.test.php b/_test/tests/inc/cache_use.test.php index c54a472a3..02fe329de 100644 --- a/_test/tests/inc/cache_use.test.php +++ b/_test/tests/inc/cache_use.test.php @@ -18,11 +18,14 @@ class cache_use_test extends DokuWikiTest { $conf['cachetime'] = 0; // ensure the value is not -1, which disables caching saveWikiText($ID, 'Content', 'Created'); - // set the modification time a second in the past in order to ensure that the cache is newer than the page - touch($file, time()-1); $this->cache = new cache_renderer($ID, $file, 'xhtml'); $this->cache->storeCache('Test'); + + // set the modification times explicitly (overcome Issue #694) + $time = time(); + touch($file, $time-1); + touch($this->cache->cache, $time); } function test_use() { -- cgit v1.2.3 From e80146ebf289d9243a864b9c8db1d97ba9516724 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 13 May 2014 20:01:51 +0200 Subject: added another test for fe5a50 That commit did not test what it actually made for. Handling protocol relative URLs in CSS. --- _test/tests/lib/exe/css_css_compress.test.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to '_test') diff --git a/_test/tests/lib/exe/css_css_compress.test.php b/_test/tests/lib/exe/css_css_compress.test.php index f0eb17968..4769684a8 100644 --- a/_test/tests/lib/exe/css_css_compress.test.php +++ b/_test/tests/lib/exe/css_css_compress.test.php @@ -53,6 +53,13 @@ class css_css_compress_test extends DokuWikiTest { $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); } + function test_slcom6(){ + $text = '#foo { + background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is all commented + }'; + $this->assertEquals('#foo{background-image:url(//foo.bar/baz.jpg);}', css_compress($text)); + } + function test_hack(){ $text = '/* Mac IE will not see this and continue with inline-block */ /* \\*/ -- cgit v1.2.3 From 918a4468877109c2ba2f82fa4e1a225a4738ed9a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 14 May 2014 19:24:01 +0200 Subject: don't treat double slashes as comments when used in string This avoids treating double slashes as single line comments in CSS when they are used in a filter or content string. closes #638 --- _test/tests/lib/exe/css_css_compress.test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to '_test') diff --git a/_test/tests/lib/exe/css_css_compress.test.php b/_test/tests/lib/exe/css_css_compress.test.php index 4769684a8..807317ca6 100644 --- a/_test/tests/lib/exe/css_css_compress.test.php +++ b/_test/tests/lib/exe/css_css_compress.test.php @@ -60,6 +60,14 @@ class css_css_compress_test extends DokuWikiTest { $this->assertEquals('#foo{background-image:url(//foo.bar/baz.jpg);}', css_compress($text)); } + function test_slcom7(){ + $text = '#foo a[href ^="https://"], #foo a[href ^=\'https://\'] { + background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is \'all\' "commented" + }'; + $this->assertEquals('#foo a[href ^="https://"],#foo a[href ^=\'https://\']{background-image:url(//foo.bar/baz.jpg);}', css_compress($text)); + } + + function test_hack(){ $text = '/* Mac IE will not see this and continue with inline-block */ /* \\*/ -- cgit v1.2.3 From c42f789c87b115a747a7436d81e7aee886d0ac88 Mon Sep 17 00:00:00 2001 From: Enrico Tagliavini Date: Thu, 30 Jan 2014 15:42:09 +0000 Subject: Adding unit test for is_ssl() this should test the correctness of the return value of is_ssl() function based on various combinations of PHP environment variables --- _test/tests/inc/init_checkssl.test.php | 81 ++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 _test/tests/inc/init_checkssl.test.php (limited to '_test') diff --git a/_test/tests/inc/init_checkssl.test.php b/_test/tests/inc/init_checkssl.test.php new file mode 100644 index 000000000..c57d3c37e --- /dev/null +++ b/_test/tests/inc/init_checkssl.test.php @@ -0,0 +1,81 @@ +assertEquals(is_ssl(), true); + } + + /** + * Running behind a plain HTTP proxy, HTTP between server and proxy + * HTTPS not set + * HTTP_X_FORWARDED_PROTO set to http + */ + function test2() { + $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'http'; + + $this->assertEquals(is_ssl(), false); + } + + /** + * Running behind an SSL proxy, HTTP between server and proxy + * HTTPS set to off, + * HTTP_X_FORWARDED_PROTO set to https + */ + function test3() { + $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; + $_SERVER['HTTPS'] = 'off'; + + $this->assertEquals(is_ssl(), true); + } + + /** + * Not running behind a proxy, HTTPS server + * HTTPS set to on, + * HTTP_X_FORWARDED_PROTO not set + */ + function test4() { + $_SERVER['HTTPS'] = 'on'; + + $this->assertEquals(is_ssl(), true); + } + + /** + * Not running behind a proxy, plain HTTP server + * HTTPS not set + * HTTP_X_FORWARDED_PROTO not set + */ + function test5() { + $this->assertEquals(is_ssl(), false); + } + + /** + * Not running behind a proxy, plain HTTP server + * HTTPS set to off + * HTTP_X_FORWARDED_PROTO not set + */ + function test6() { + $_SERVER['HTTPS'] = 'off'; + $this->assertEquals(is_ssl(), false); + } + + /** + * Running behind an SSL proxy, SSL between proxy and HTTP server + * HTTPS set to on, + * HTTP_X_FORWARDED_PROTO set to https + */ + function test7() { + $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; + $_SERVER['HTTPS'] = 'on'; + + $this->assertEquals(is_ssl(), true); + } +} -- cgit v1.2.3 From a5ac1d91deb9f263c360e34096a469b3beb681f9 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 18 Jul 2014 12:19:31 +0200 Subject: skip cache test until #694 has been fixed --- _test/tests/inc/cache_use.test.php | 3 +++ 1 file changed, 3 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/cache_use.test.php b/_test/tests/inc/cache_use.test.php index 02fe329de..3ea212d50 100644 --- a/_test/tests/inc/cache_use.test.php +++ b/_test/tests/inc/cache_use.test.php @@ -29,6 +29,9 @@ class cache_use_test extends DokuWikiTest { } function test_use() { + $this->markTestSkipped('Disabled until Ticket #694 has been fixed'); + return; + $this->assertTrue($this->cache->useCache()); } -- cgit v1.2.3