summaryrefslogtreecommitdiff
path: root/_test/tests/inc/parser/parser_quotes.test.php
diff options
context:
space:
mode:
authorAnika Henke <anika@selfthinker.org>2012-06-29 17:51:09 +0100
committerAnika Henke <anika@selfthinker.org>2012-06-29 17:51:09 +0100
commit0c06a181819249c6a4a2a6c60e13f739df1f2253 (patch)
tree859377c572d0acbfc520b02304ef515bf3aebbe0 /_test/tests/inc/parser/parser_quotes.test.php
parentef7e36e4fd2a168977754f0aac1d855fb651f104 (diff)
parent5d0aaf958325f500ce69cfb79e69eb0d8f83fdeb (diff)
downloadrpg-0c06a181819249c6a4a2a6c60e13f739df1f2253.tar.gz
rpg-0c06a181819249c6a4a2a6c60e13f739df1f2253.tar.bz2
Merge branch 'master' of github.com:splitbrain/dokuwiki into frontend_improvements
Conflicts: lib/tpl/dokuwiki/css/basic.css
Diffstat (limited to '_test/tests/inc/parser/parser_quotes.test.php')
-rw-r--r--_test/tests/inc/parser/parser_quotes.test.php269
1 files changed, 269 insertions, 0 deletions
diff --git a/_test/tests/inc/parser/parser_quotes.test.php b/_test/tests/inc/parser/parser_quotes.test.php
new file mode 100644
index 000000000..b2dae1039
--- /dev/null
+++ b/_test/tests/inc/parser/parser_quotes.test.php
@@ -0,0 +1,269 @@
+<?php
+require_once 'parser.inc.php';
+
+class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
+
+ function setup() {
+ parent::setup();
+ global $conf;
+ $conf['typography'] = 2;
+ }
+
+ function testSingleQuoteOpening() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse("Foo 'hello Bar");
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo ')),
+ array('singlequoteopening',array()),
+ array('cdata',array('hello Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testSingleQuoteOpeningSpecial() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse("Foo said:'hello Bar");
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo said:')),
+ array('singlequoteopening',array()),
+ array('cdata',array('hello Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testSingleQuoteClosing() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse("Foo hello' Bar");
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo hello')),
+ array('singlequoteclosing',array()),
+ array('cdata',array(' Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testSingleQuoteClosingSpecial() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse("Foo hello') Bar");
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo hello')),
+ array('singlequoteclosing',array()),
+ array('cdata',array(') Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testSingleQuotes() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse("Foo 'hello' Bar");
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo ')),
+ array('singlequoteopening',array()),
+ array('cdata',array('hello')),
+ array('singlequoteclosing',array()),
+ array('cdata',array(' Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testApostrophe() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse("hey it's fine weather today");
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'hey it')),
+ array('apostrophe',array()),
+ array('cdata',array('s fine weather today')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+
+ function testSingleQuotesSpecial() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse("Foo ('hello') Bar");
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo (')),
+ array('singlequoteopening',array()),
+ array('cdata',array('hello')),
+ array('singlequoteclosing',array()),
+ array('cdata',array(') Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testDoubleQuoteOpening() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse('Foo "hello Bar');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo ')),
+ array('doublequoteopening',array()),
+ array('cdata',array('hello Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testDoubleQuoteOpeningSpecial() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse('Foo said:"hello Bar');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo said:')),
+ array('doublequoteopening',array()),
+ array('cdata',array('hello Bar')),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+ function testDoubleQuoteClosing() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse('Foo hello" Bar');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo 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);
+ }
+
+ function testDoubleQuoteClosingSpecial() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse('Foo hello") Bar');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'Foo 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);
+ }
+
+ function testDoubleQuotes() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse('Foo "hello" Bar');
+
+ $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);
+ }
+
+ function testDoubleQuotesSpecial() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse('Foo ("hello") Bar');
+
+ $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);
+ }
+
+ function testAllQuotes() {
+ $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
+ $this->P->parse('There was written "He thought \'It\'s a man\'s world\'".');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('cdata',array("\n".'There was written ')),
+ array('doublequoteopening',array()),
+ array('cdata',array('He thought ')),
+ array('singlequoteopening',array()),
+ array('cdata',array('It')),
+ array('apostrophe',array()),
+ array('cdata',array('s a man')),
+ array('apostrophe',array()),
+ array('cdata',array('s world')),
+ array('singlequoteclosing',array()),
+ array('doublequoteclosing',array()),
+ array('cdata',array(".")),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+
+ $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
+ }
+
+}
+