summaryrefslogtreecommitdiff
path: root/_test/tests/inc/parser
diff options
context:
space:
mode:
Diffstat (limited to '_test/tests/inc/parser')
-rw-r--r--_test/tests/inc/parser/parser.inc.php2
-rw-r--r--_test/tests/inc/parser/parser_quotes.test.php131
-rw-r--r--_test/tests/inc/parser/parser_table.test.php299
-rw-r--r--_test/tests/inc/parser/renderer_resolveinterwiki.test.php53
4 files changed, 441 insertions, 44 deletions
diff --git a/_test/tests/inc/parser/parser.inc.php b/_test/tests/inc/parser/parser.inc.php
index 61f15678b..f1207b119 100644
--- a/_test/tests/inc/parser/parser.inc.php
+++ b/_test/tests/inc/parser/parser.inc.php
@@ -3,7 +3,7 @@
require_once DOKU_INC . 'inc/parser/parser.php';
require_once DOKU_INC . 'inc/parser/handler.php';
-abstract class TestOfDoku_Parser extends PHPUnit_Framework_TestCase {
+abstract class TestOfDoku_Parser extends DokuWikiTest {
var $P;
var $H;
diff --git a/_test/tests/inc/parser/parser_quotes.test.php b/_test/tests/inc/parser/parser_quotes.test.php
index b82328212..6f174ddae 100644
--- a/_test/tests/inc/parser/parser_quotes.test.php
+++ b/_test/tests/inc/parser/parser_quotes.test.php
@@ -10,8 +10,9 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
}
function testSingleQuoteOpening() {
+ $raw = "Foo 'hello Bar";
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse("Foo 'hello Bar");
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -23,12 +24,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testSingleQuoteOpeningSpecial() {
+ $raw = "Foo said:'hello Bar";
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse("Foo said:'hello Bar");
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -40,12 +42,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testSingleQuoteClosing() {
+ $raw = "Foo hello' Bar";
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse("Foo hello' Bar");
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -57,12 +60,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testSingleQuoteClosingSpecial() {
+ $raw = "Foo hello') Bar";
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse("Foo hello') Bar");
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -74,12 +78,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testSingleQuotes() {
+ $raw = "Foo 'hello' Bar";
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse("Foo 'hello' Bar");
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -93,12 +98,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testApostrophe() {
+ $raw = "hey it's fine weather today";
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse("hey it's fine weather today");
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -110,13 +116,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testSingleQuotesSpecial() {
+ $raw = "Foo ('hello') Bar";
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse("Foo ('hello') Bar");
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -130,12 +137,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testDoubleQuoteOpening() {
+ $raw = 'Foo "hello Bar';
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse('Foo "hello Bar');
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -147,12 +155,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testDoubleQuoteOpeningSpecial() {
+ $raw = 'Foo said:"hello Bar';
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse('Foo said:"hello Bar');
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -164,12 +173,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testDoubleQuoteClosing() {
+ $raw = 'Foo hello" Bar';
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse('Foo hello" Bar');
+ $this->H->status['doublequote'] = 1;
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -181,12 +192,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testDoubleQuoteClosingSpecial() {
+ $raw = 'Foo hello") Bar';
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse('Foo hello") Bar');
+ $this->H->status['doublequote'] = 1;
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -198,12 +211,31 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
+ }
+ function testDoubleQuoteClosingSpecial2() {
+ $raw = 'Foo hello") Bar';
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->H->status['doublequote'] = 0;
+ $this->P->parse($raw);
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo hello')),
+ array('doublequoteopening',array()),
+ array('cdata',array(') Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testDoubleQuotes() {
+ $raw = 'Foo "hello" Bar';
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse('Foo "hello" Bar');
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -217,12 +249,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
}
function testDoubleQuotesSpecial() {
+ $raw = 'Foo ("hello") Bar';
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse('Foo ("hello") Bar');
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -236,12 +269,54 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
+ }
+
+ function testDoubleQuotesEnclosingBrackets() {
+ $raw = 'Foo "{hello}" Bar';
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse($raw);
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo ')),
+ array('doublequoteopening',array()),
+ array('cdata',array('{hello}')),
+ array('doublequoteclosing',array()),
+ array('cdata',array(' Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext - '.$raw);
+ }
+
+ function testDoubleQuotesEnclosingLink() {
+ $raw = 'Foo "[[www.domain.com]]" Bar';
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse($raw);
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo ')),
+ array('doublequoteopening',array()),
+ array('cdata',array('[[www.domain.com]]')),
+ array('doublequoteclosing',array()),
+ array('cdata',array(' Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw);
}
+
function testAllQuotes() {
+ $raw = 'There was written "He thought \'It\'s a man\'s world\'".';
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
- $this->P->parse('There was written "He thought \'It\'s a man\'s world\'".');
+ $this->P->parse($raw);
$calls = array (
array('document_start',array()),
@@ -262,7 +337,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw);
}
}
diff --git a/_test/tests/inc/parser/parser_table.test.php b/_test/tests/inc/parser/parser_table.test.php
index bc19ebff9..a9b4e284c 100644
--- a/_test/tests/inc/parser/parser_table.test.php
+++ b/_test/tests/inc/parser/parser_table.test.php
@@ -44,7 +44,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testTableWinEOL() {
@@ -84,7 +84,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testEmptyTable() {
@@ -109,7 +109,7 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testTableHeaders() {
@@ -143,7 +143,152 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
+ function testTableHead() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X ^ Y ^ Z ^
+| x | y | z |
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 2, 6)),
+ array('tablethead_open',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Y ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablethead_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' x ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' y ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' z ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(33)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
+ function testTableHeadOneRowTable() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X ^ Y ^ Z ^
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 1, 6)),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Y ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(19)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
+ function testTableHeadMultiline() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X1 ^ Y1 ^ Z1 ^
+^ X2 ^ Y2 ^ Z2 ^
+| A | B | C |
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 3, 6)),
+ array('tablethead_open',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Y1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z1 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X2 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Y2 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z2 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablethead_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' A ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' B ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' C ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(53)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
@@ -178,7 +323,7 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testCellSpan() {
@@ -220,7 +365,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testCellRowSpan() {
@@ -268,7 +413,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testCellRowSpanFirstRow() {
@@ -326,9 +471,134 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
+ function testRowSpanTableHead() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X1 ^ Y1 ^ Z1 ^
+^ X2 ^ ::: ^ Z2 ^
+| A3 | B3 | C3 |
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 3, 6)),
+ array('tablethead_open',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,2)),
+ array('cdata',array(' Y1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z1 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X2 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z2 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablethead_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' A3 ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' B3 ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' C3 ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(57)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
+ function testRowSpanAcrossTableHeadBoundary() {
+ $this->P->addMode('table',new Doku_Parser_Mode_Table());
+ $this->P->parse('
+abc
+^ X1 ^ Y1 ^ Z1 ^
+^ X2 ^ ::: ^ Z2 ^
+| A3 | ::: | C3 |
+| A4 | ::: | C4 |
+def');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n\nabc")),
+ array('p_close',array()),
+ array('table_open',array(3, 4, 6)),
+ array('tablethead_open',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,2)),
+ array('cdata',array(' Y1 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z1 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablerow_open',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' X2 ')),
+ array('tableheader_close',array()),
+ array('tableheader_open',array(1,NULL,1)),
+ array('cdata',array(' Z2 ')),
+ array('tableheader_close',array()),
+ array('tablerow_close',array()),
+ array('tablethead_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' A3 ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,2)),
+ array('cdata',array('')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' C3 ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('tablerow_open',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' A4 ')),
+ array('tablecell_close',array()),
+ array('tablecell_open',array(1,NULL,1)),
+ array('cdata',array(' C4 ')),
+ array('tablecell_close',array()),
+ array('tablerow_close',array()),
+ array('table_close',array(76)),
+ array('p_open',array()),
+ array('cdata',array('def')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
+
+ }
+
function testCellAlignmentFormatting() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
@@ -365,7 +635,7 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
@@ -411,7 +681,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
// This is really a failing test - formatting able to spread across cols
@@ -466,7 +736,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
// This is really a failing test - unformatted able to spread across cols
@@ -517,7 +787,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testTableLinebreak() {
@@ -565,7 +835,7 @@ def');
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
// This is really a failing test - footnote able to spread across cols
@@ -624,7 +894,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
- $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls));
}
function testTable_FS1833() {
@@ -646,4 +916,3 @@ def');
}
}
-
diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
new file mode 100644
index 000000000..dd1ed1d3f
--- /dev/null
+++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
@@ -0,0 +1,53 @@
+<?php
+
+require_once DOKU_INC . 'inc/parser/renderer.php';
+
+/**
+ * Tests for Doku_Renderer::_resolveInterWiki()
+ */
+class Test_resolveInterwiki extends DokuWikiTest {
+
+ function testDefaults() {
+ $Renderer = new Doku_Renderer();
+ $Renderer->interwiki = getInterwiki();
+ $Renderer->interwiki['scheme'] = '{SCHEME}://example.com';
+ $Renderer->interwiki['withslash'] = '/test';
+ $Renderer->interwiki['onlytext'] = ':onlytext{NAME}'; //with {URL} double urlencoded
+ $Renderer->interwiki['withquery'] = ':anyns:{NAME}?do=edit';
+
+ $tests = array(
+ // shortcut, reference and expected
+ array('wp', 'foo @+%/#txt', 'http://en.wikipedia.org/wiki/foo @+%/#txt'),
+ array('amazon', 'foo @+%/#txt', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/#txt'),
+ array('doku', 'foo @+%/#txt', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F#txt'),
+ array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090/path/naar/?query=foo%20%40%2B%25%2F'),
+ array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'),
+ //relative url
+ array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'),
+ array('skype', 'foo @+%/#txt', 'skype:foo @+%/#txt'),
+ //dokuwiki id's
+ array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'),
+ array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=user:foo#txt'),
+ array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo&amp;do=edit#txt')
+ );
+
+ foreach($tests as $test) {
+ $url = $Renderer->_resolveInterWiki($test[0], $test[1]);
+
+ $this->assertEquals($test[2], $url);
+ }
+ }
+
+ function testNonexisting() {
+ $Renderer = new Doku_Renderer();
+ $Renderer->interwiki = getInterwiki();
+
+ $shortcut = 'nonexisting';
+ $reference = 'foo @+%/';
+ $url = $Renderer->_resolveInterWiki($shortcut, $reference);
+ $expected = 'http://www.google.com/search?q=foo%20%40%2B%25%2F&amp;btnI=lucky';
+
+ $this->assertEquals($expected, $url);
+ }
+
+} \ No newline at end of file