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/tests/inc/parser') 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/tests/inc/parser') 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/tests/inc/parser') 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 2d6df7955d82d34f7a58b289fa04755c5ab9146e Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 00:49:18 +0100 Subject: added tests for Doku_Renderer::_resolveInterWiki --- .../inc/parser/renderer_resolveinterwiki.test.php | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 _test/tests/inc/parser/renderer_resolveinterwiki.test.php (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php new file mode 100644 index 000000000..5ce54fac6 --- /dev/null +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -0,0 +1,54 @@ +interwiki = getInterwiki(); + $Renderer->interwiki['scheme'] = '{SCHEME}://example.com'; + $Renderer->interwiki['slash'] = '/test'; + $Renderer->interwiki['onlytext'] = 'onlytext'; + + //var_dump($Renderer->interwiki); + + $tests = array( + // shortcut, reference and expected + array('wp', 'foo @+%/', 'http://en.wikipedia.org/wiki/foo @+%/'), + array('amazon', 'foo @+%/', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/'), + array('doku', 'foo @+%/', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F'), + //ToDo: Check needed, is double slash in path desired + array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090//path/naar/?query=foo%20%40%2B%25%2F'), + array('scheme', 'ftp://foo @+%/', 'ftp://example.com'), + //relative url + array('slash', 'foo @+%/', '/testfoo%20%40%2B%25%2F'), + //dokuwiki id's + array('onlytext', 'foo @+%/', 'onlytextfoo%20%40%2B%25%2F'), + array('user', 'foo @+%/', 'wiki:users:foo%20%40%2B%25%2F') + ); + + foreach($tests as $test) { + $url = $Renderer->_resolveInterWiki($test[0], $test[1]); + + $this->assertEquals($test[2], $url); + } + } + + function testNonexisting() { + $Renderer = new Doku_Renderer(); + $Renderer->interwiki = getInterwiki(); + + $shortcut = 'nonexisting'; + $reference = 'foo @+%/'; + $url = $Renderer->_resolveInterWiki($shortcut, $reference); + $expected = 'http://www.google.com/search?q=foo%20%40%2B%25%2F&btnI=lucky'; + + $this->assertEquals($expected, $url); + } + +} \ No newline at end of file -- cgit v1.2.3 From 2345e871e407dbece52f3181cd8b077f07cbb0c1 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:11:15 +0100 Subject: wikilink creating refactored to _resolveinterwiki(). Added DOKU_BASE for local target --- .../inc/parser/renderer_resolveinterwiki.test.php | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index 5ce54fac6..f17838f92 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -7,29 +7,28 @@ require_once DOKU_INC . 'inc/parser/renderer.php'; */ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { - function testDefaults() { $Renderer = new Doku_Renderer(); $Renderer->interwiki = getInterwiki(); $Renderer->interwiki['scheme'] = '{SCHEME}://example.com'; - $Renderer->interwiki['slash'] = '/test'; - $Renderer->interwiki['onlytext'] = 'onlytext'; - - //var_dump($Renderer->interwiki); + $Renderer->interwiki['withslash'] = '/test'; + $Renderer->interwiki['onlytext'] = 'onlytext{NAME}'; //with {URL} double urlencoded + $Renderer->interwiki['withquery'] = 'anyns:{NAME}?do=edit'; $tests = array( // shortcut, reference and expected - array('wp', 'foo @+%/', 'http://en.wikipedia.org/wiki/foo @+%/'), - array('amazon', 'foo @+%/', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/'), - array('doku', 'foo @+%/', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F'), + array('wp', 'foo @+%/#txt', 'http://en.wikipedia.org/wiki/foo @+%/#txt'), + array('amazon', 'foo @+%/#txt', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/#txt'), + array('doku', 'foo @+%/#txt', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F#txt'), //ToDo: Check needed, is double slash in path desired array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090//path/naar/?query=foo%20%40%2B%25%2F'), - array('scheme', 'ftp://foo @+%/', 'ftp://example.com'), + array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'), //relative url - array('slash', 'foo @+%/', '/testfoo%20%40%2B%25%2F'), + array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), //dokuwiki id's - array('onlytext', 'foo @+%/', 'onlytextfoo%20%40%2B%25%2F'), - array('user', 'foo @+%/', 'wiki:users:foo%20%40%2B%25%2F') + array('onlytext', 'foo @+%#txt', '/tmp/doku.php?id=onlytextfoo%20%40%2B%25#txt'), + array('user', 'foo @+%#txt', '/tmp/doku.php?id=wiki:users:foo%20%40%2B%25#txt'), + array('withquery', 'foo @+%#txt', '/tmp/doku.php?id=anyns:foo%20%40%2B%25&do=edit#txt') ); foreach($tests as $test) { -- cgit v1.2.3 From 4485a8917160fb9f955e5b8aa28c1a5499c608b0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:28:09 +0100 Subject: Fix double slash in coral interwikilink --- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index f17838f92..ea4f99511 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -20,8 +20,7 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { array('wp', 'foo @+%/#txt', 'http://en.wikipedia.org/wiki/foo @+%/#txt'), array('amazon', 'foo @+%/#txt', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/#txt'), array('doku', 'foo @+%/#txt', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F#txt'), - //ToDo: Check needed, is double slash in path desired - array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090//path/naar/?query=foo%20%40%2B%25%2F'), + array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090/path/naar/?query=foo%20%40%2B%25%2F'), array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'), //relative url array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), -- cgit v1.2.3 From ddb55c702f2393a435c309fd7d4e169acb2675f7 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:29:33 +0100 Subject: Use DOKU_BASE in resolveinterwiki unittest --- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index ea4f99511..a71895b34 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -25,9 +25,9 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { //relative url array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), //dokuwiki id's - array('onlytext', 'foo @+%#txt', '/tmp/doku.php?id=onlytextfoo%20%40%2B%25#txt'), - array('user', 'foo @+%#txt', '/tmp/doku.php?id=wiki:users:foo%20%40%2B%25#txt'), - array('withquery', 'foo @+%#txt', '/tmp/doku.php?id=anyns:foo%20%40%2B%25&do=edit#txt') + array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo%20%40%2B%25#txt'), + array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=wiki:users:foo%20%40%2B%25#txt'), + array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo%20%40%2B%25&do=edit#txt') ); foreach($tests as $test) { -- cgit v1.2.3 From 6496c33fc8e98f6e3acaaa5db0234d9c07bec4fe Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 14:34:26 +0100 Subject: interwiki : prefixed configurls handled as wikilinks --- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index a71895b34..e78930934 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -12,8 +12,8 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { $Renderer->interwiki = getInterwiki(); $Renderer->interwiki['scheme'] = '{SCHEME}://example.com'; $Renderer->interwiki['withslash'] = '/test'; - $Renderer->interwiki['onlytext'] = 'onlytext{NAME}'; //with {URL} double urlencoded - $Renderer->interwiki['withquery'] = 'anyns:{NAME}?do=edit'; + $Renderer->interwiki['onlytext'] = ':onlytext{NAME}'; //with {URL} double urlencoded + $Renderer->interwiki['withquery'] = ':anyns:{NAME}?do=edit'; $tests = array( // shortcut, reference and expected @@ -24,10 +24,11 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'), //relative url array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), + array('skype', 'foo @+%/#txt', 'skype:foo @+%/#txt'), //dokuwiki id's - array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo%20%40%2B%25#txt'), - array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=wiki:users:foo%20%40%2B%25#txt'), - array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo%20%40%2B%25&do=edit#txt') + array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'), + array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=wiki:users:foo#txt'), + array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo&do=edit#txt') ); foreach($tests as $test) { -- cgit v1.2.3 From 118e00521560a4a93c92ba7439e5cf5463e0efe7 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 17 Feb 2014 00:51:10 +0100 Subject: update unittest with interwiki.conf change as well --- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index e78930934..7b43b6d62 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -27,7 +27,7 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { array('skype', 'foo @+%/#txt', 'skype:foo @+%/#txt'), //dokuwiki id's array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'), - array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=wiki:users:foo#txt'), + array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=user:foo#txt'), array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo&do=edit#txt') ); -- 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/tests/inc/parser') 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 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/tests/inc/parser') 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 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/parser/parser.inc.php | 2 +- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/parser.inc.php b/_test/tests/inc/parser/parser.inc.php index 61f15678b..f1207b119 100644 --- a/_test/tests/inc/parser/parser.inc.php +++ b/_test/tests/inc/parser/parser.inc.php @@ -3,7 +3,7 @@ require_once DOKU_INC . 'inc/parser/parser.php'; require_once DOKU_INC . 'inc/parser/handler.php'; -abstract class TestOfDoku_Parser extends PHPUnit_Framework_TestCase { +abstract class TestOfDoku_Parser extends DokuWikiTest { var $P; var $H; diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index 7b43b6d62..dd1ed1d3f 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -5,7 +5,7 @@ require_once DOKU_INC . 'inc/parser/renderer.php'; /** * Tests for Doku_Renderer::_resolveInterWiki() */ -class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { +class Test_resolveInterwiki extends DokuWikiTest { function testDefaults() { $Renderer = new Doku_Renderer(); -- cgit v1.2.3