summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorGuy Brand <gb@unistra.fr>2013-07-31 11:38:44 +0200
committerGuy Brand <gb@unistra.fr>2013-07-31 11:38:44 +0200
commitf2bbf30b71b15efa7a918944b4ffc74f8b1747a9 (patch)
treec46780c1bc360bdcb15eec84b12a39e9d045566a /_test
parentfc498a423a295d14127239e3838b6fb7bb0c8529 (diff)
downloadrpg-f2bbf30b71b15efa7a918944b4ffc74f8b1747a9.tar.gz
rpg-f2bbf30b71b15efa7a918944b4ffc74f8b1747a9.tar.bz2
Simple test cases for code and file token fix
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/parser/parser_code.test.php56
-rw-r--r--_test/tests/inc/parser/parser_file.test.php28
2 files changed, 84 insertions, 0 deletions
diff --git a/_test/tests/inc/parser/parser_code.test.php b/_test/tests/inc/parser/parser_code.test.php
new file mode 100644
index 000000000..4f89b4826
--- /dev/null
+++ b/_test/tests/inc/parser/parser_code.test.php
@@ -0,0 +1,56 @@
+<?php
+require_once 'parser.inc.php';
+
+class TestOfDoku_Parser_Code extends TestOfDoku_Parser {
+
+ function setUp() {
+ parent::setUp();
+ $this->P->addMode('code',new Doku_Parser_Mode_Code());
+ }
+
+ function testCode() {
+ $this->P->parse('Foo <code>Test</code> Bar');
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo ')),
+ array('p_close',array()),
+ array('code',array('Test',null,null)),
+ array('p_open',array()),
+ array('cdata',array(' Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testCodeBash() {
+ $this->P->parse('Foo <code bash>Test</code> Bar');
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo ')),
+ array('p_close',array()),
+ array('code',array('Test','bash',null)),
+ array('p_open',array()),
+ array('cdata',array(' Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testCodeToken() {
+ $this->P->parse('Foo <code2>Bar</code2><code>Test</code>');
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo <code2>Bar</code2>')),
+ array('p_close',array()),
+ array('code',array('Test',null,null)),
+ array('document_end',array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+}
+
diff --git a/_test/tests/inc/parser/parser_file.test.php b/_test/tests/inc/parser/parser_file.test.php
new file mode 100644
index 000000000..924b00382
--- /dev/null
+++ b/_test/tests/inc/parser/parser_file.test.php
@@ -0,0 +1,28 @@
+<?php
+require_once 'parser.inc.php';
+
+class TestOfDoku_Parser_File extends TestOfDoku_Parser {
+
+ function setUp() {
+ parent::setUp();
+ $this->P->addMode('file',new Doku_Parser_Mode_File());
+ }
+
+ function testFile() {
+ $this->P->parse('Foo <file>Test</file> Bar');
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo ')),
+ array('p_close',array()),
+ array('file',array('Test',null,null)),
+ array('p_open',array()),
+ array('cdata',array(' Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+}
+