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/lexer.test.php4
-rw-r--r--_test/tests/inc/parser/parser_footnote.test.php2
-rw-r--r--_test/tests/inc/parser/parser_lists.test.php20
-rw-r--r--_test/tests/inc/parser/parser_media.test.php103
-rw-r--r--_test/tests/inc/parser/renderer_resolveinterwiki.test.php22
5 files changed, 128 insertions, 23 deletions
diff --git a/_test/tests/inc/parser/lexer.test.php b/_test/tests/inc/parser/lexer.test.php
index d0965a13e..c50665928 100644
--- a/_test/tests/inc/parser/lexer.test.php
+++ b/_test/tests/inc/parser/lexer.test.php
@@ -146,7 +146,7 @@ class TestOfLexerStateStack extends DokuWikiTest {
}
class TestParser {
- function TestParser() {
+ function __construct() {
}
function accept() {
}
@@ -364,7 +364,7 @@ class TestOfLexerHandlers extends DokuWikiTest {
class TestParserByteIndex {
- function TestParserByteIndex() {}
+ function __construct() {}
function ignore() {}
diff --git a/_test/tests/inc/parser/parser_footnote.test.php b/_test/tests/inc/parser/parser_footnote.test.php
index b47a575de..2457fb031 100644
--- a/_test/tests/inc/parser/parser_footnote.test.php
+++ b/_test/tests/inc/parser/parser_footnote.test.php
@@ -303,7 +303,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('nest', array ( array (
array('footnote_open',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
diff --git a/_test/tests/inc/parser/parser_lists.test.php b/_test/tests/inc/parser/parser_lists.test.php
index e4ef1f83e..6acaff637 100644
--- a/_test/tests/inc/parser/parser_lists.test.php
+++ b/_test/tests/inc/parser/parser_lists.test.php
@@ -13,7 +13,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -46,7 +46,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listo_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -80,7 +80,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listo_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -109,7 +109,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -138,7 +138,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listo_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -188,7 +188,7 @@ Bar');
array('cdata',array("Foo")),
array('p_close',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -227,7 +227,7 @@ Bar');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('strong_open',array()),
array('cdata',array("A")),
@@ -262,7 +262,7 @@ Bar');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('unformatted',array("A")),
array('listcontent_close',array()),
@@ -291,7 +291,7 @@ Bar');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('linebreak',array()),
@@ -355,7 +355,7 @@ Bar');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('nest', array( array(
array('footnote_open',array()),
diff --git a/_test/tests/inc/parser/parser_media.test.php b/_test/tests/inc/parser/parser_media.test.php
new file mode 100644
index 000000000..d9a0626f5
--- /dev/null
+++ b/_test/tests/inc/parser/parser_media.test.php
@@ -0,0 +1,103 @@
+<?php
+require_once 'parser.inc.php';
+
+/**
+ * Tests for the implementation of audio and video files
+ *
+ * @author Michael Große <grosse@cosmocode.de>
+*/
+class TestOfDoku_Parser_Media extends TestOfDoku_Parser {
+
+ function testVideoOGVExternal() {
+ $file = 'http://some.where.far/away.ogv';
+ $parser_response = p_get_instructions('{{' . $file . '}}');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('externalmedia',array($file,null,null,null,null,'cache','details')),
+ array('cdata',array(null)),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex',$parser_response),$calls);
+
+ $Renderer = new Doku_Renderer_xhtml();
+ $url = $Renderer->externalmedia($file,null,null,null,null,'cache','details',true);
+ //print_r("url: " . $url);
+ $video = '<video class="media" width="320" height="240" controls="controls">';
+ $this->assertEquals(substr($url,0,66),$video);
+ $source = '<source src="http://some.where.far/away.ogv" type="video/ogg" />';
+ $this->assertEquals(substr($url,67,64),$source);
+ // work around random token
+ $a_first_part = '<a href="/./lib/exe/fetch.php?cache=&amp;tok=';
+ $a_second_part = '&amp;media=http%3A%2F%2Fsome.where.far%2Faway.ogv" class="media mediafile mf_ogv" title="http://some.where.far/away.ogv">';
+ $this->assertEquals(substr($url,132,45),$a_first_part);
+ $this->assertEquals(substr($url,183,121),$a_second_part);
+ $rest = 'away.ogv</a></video>'."\n";
+ $this->assertEquals(substr($url,304),$rest);
+ }
+
+ /**
+ * unknown extension of external media file
+ */
+ function testVideoVIDExternal() {
+ $file = 'http://some.where.far/away.vid';
+ $parser_response = p_get_instructions('{{' . $file . '}}');
+
+ $calls = array(
+ array('document_start', array()),
+ array('p_open', array()),
+ array('externalmedia', array($file, null, null, null, null, 'cache', 'details')),
+ array('cdata', array(null)),
+ array('p_close', array()),
+ array('document_end', array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex', $parser_response), $calls);
+
+ $Renderer = new Doku_Renderer_xhtml();
+ $url = $Renderer->externalmedia($file, null, null, null, null, 'cache', 'details', true);
+ // work around random token
+ $a_first_part = '<a href="/./lib/exe/fetch.php?tok=';
+ $a_second_part = '&amp;media=http%3A%2F%2Fsome.where.far%2Faway.vid" class="media mediafile mf_vid" title="http://some.where.far/away.vid">';
+ $this->assertEquals(substr($url,0,34),$a_first_part);
+ $this->assertEquals(substr($url,40,121),$a_second_part);
+ $rest = 'away.vid</a>';
+ $this->assertEquals(substr($url,161),$rest);
+ }
+
+
+ function testVideoOGVInternal() {
+ $file = 'wiki:kind_zu_katze.ogv';
+ $parser_response = p_get_instructions('{{' . $file . '}}');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('internalmedia',array($file,null,null,null,null,'cache','details')),
+ array('cdata',array(null)),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex',$parser_response),$calls);
+
+ $Renderer = new Doku_Renderer_xhtml();
+ $url = $Renderer->externalmedia($file,null,null,null,null,'cache','details',true);
+
+ $video = '<video class="media" width="320" height="240" controls="controls" poster="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.png">';
+ $this->assertEquals(substr($url,0,125),$video);
+
+ $source_webm = '<source src="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.webm" type="video/webm" />';
+ $this->assertEquals(substr($url,126,85),$source_webm);
+ $source_ogv = '<source src="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.ogv" type="video/ogg" />';
+ $this->assertEquals(substr($url,212,83),$source_ogv);
+
+ $a_webm = '<a href="/./lib/exe/fetch.php?id=&amp;cache=&amp;media=wiki:kind_zu_katze.webm" class="media mediafile mf_webm" title="wiki:kind_zu_katze.webm (99.1 KB)">kind_zu_katze.webm</a>';
+ $a_ogv = '<a href="/./lib/exe/fetch.php?id=&amp;cache=&amp;media=wiki:kind_zu_katze.ogv" class="media mediafile mf_ogv" title="wiki:kind_zu_katze.ogv (44.8 KB)">kind_zu_katze.ogv</a>';
+ $this->assertEquals(substr($url,296,176),$a_webm);
+ $this->assertEquals(substr($url,472,172),$a_ogv);
+
+ $rest = '</video>'."\n";
+ $this->assertEquals(substr($url,644),$rest);
+ }
+}
diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
index dd1ed1d3f..772001b99 100644
--- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
+++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
@@ -14,21 +14,23 @@ class Test_resolveInterwiki extends DokuWikiTest {
$Renderer->interwiki['withslash'] = '/test';
$Renderer->interwiki['onlytext'] = ':onlytext{NAME}'; //with {URL} double urlencoded
$Renderer->interwiki['withquery'] = ':anyns:{NAME}?do=edit';
+ //this was the only link with host/port/path/query. Keep it here for regression
+ $Renderer->interwiki['coral'] = 'http://{HOST}.{PORT}.nyud.net:8090{PATH}?{QUERY}';
$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('wp', 'foo [\\]^`{|}~@+#%?/#txt', 'https://en.wikipedia.org/wiki/foo %5B%5C%5D%5E%60%7B%7C%7D~@+%23%25?/#txt'),
+ array('amazon', 'foo [\\]^`{|}~@+#%?/#txt', 'https://www.amazon.com/exec/obidos/ASIN/foo%20%5B%5C%5D%5E%60%7B%7C%7D~%40%2B%23%25%3F%2F/splitbrain-20/#txt'),
+ array('doku', 'foo [\\]^`{|}~@+#%?/#txt', 'https://www.dokuwiki.org/foo%20%5B%5C%5D%5E%60%7B%7C%7D~%40%2B%23%25%3F%2F#txt'),
+ array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%3F%2F', 'http://example.com.83.nyud.net:8090/path/naar/?query=foo%20%40%2B%25%3F%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'),
+ array('withslash', 'foo [\\]^`{|}~@+#%?/#txt', '/testfoo%20%5B%5C%5D%5E%60%7B%7C%7D~%40%2B%23%25%3F%2F#txt'),
+ array('skype', 'foo [\\]^`{|}~@+#%?/#txt', 'skype:foo %5B%5C%5D%5E%60%7B%7C%7D~@+%23%25?/#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')
+ 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) {
@@ -45,7 +47,7 @@ class Test_resolveInterwiki extends DokuWikiTest {
$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';
+ $expected = 'https://www.google.com/search?q=foo%20%40%2B%25%2F&amp;btnI=lucky';
$this->assertEquals($expected, $url);
}