1<?php 2 3namespace dokuwiki\test\Parsing\ParserMode; 4 5use dokuwiki\Parsing\ParserMode\Eol; 6use dokuwiki\Parsing\ParserMode\Linebreak; 7 8class EolTest extends ParserTestBase 9{ 10 11 function testEol() { 12 $this->P->addMode('eol',new Eol()); 13 $this->P->parse("Foo\nBar"); 14 $calls = [ 15 ['document_start',[]], 16 ['p_open',[]], 17 ['cdata',["Foo"."\n"."Bar"]], 18 ['p_close',[]], 19 ['document_end',[]], 20 ]; 21 $this->assertCalls($calls, $this->H->calls); 22 } 23 24 function testEolMultiple() { 25 $this->P->addMode('eol',new Eol()); 26 $this->P->parse("Foo\n\nbar\nFoo"); 27 $calls = [ 28 ['document_start',[]], 29 ['p_open',[]], 30 ['cdata',["Foo"]], 31 ['p_close',[]], 32 ['p_open',[]], 33 ['cdata',["bar"."\n"."Foo"]], 34 ['p_close',[]], 35 ['document_end',[]], 36 ]; 37 $this->assertCalls($calls, $this->H->calls); 38 } 39 40 function testWinEol() { 41 $this->P->addMode('eol',new Eol()); 42 $this->P->parse("Foo\r\nBar"); 43 $calls = [ 44 ['document_start',[]], 45 ['p_open',[]], 46 ['cdata',["Foo"."\n"."Bar"]], 47 ['p_close',[]], 48 ['document_end',[]], 49 ]; 50 $this->assertCalls($calls, $this->H->calls); 51 } 52 53 function testLinebreak() { 54 $this->P->addMode('linebreak',new Linebreak()); 55 $this->P->parse('Foo\\\\ Bar'); 56 $calls = [ 57 ['document_start',[]], 58 ['p_open',[]], 59 ['cdata',["\nFoo"]], 60 ['linebreak',[]], 61 ['cdata',["Bar"]], 62 ['p_close',[]], 63 ['document_end',[]], 64 ]; 65 $this->assertCalls($calls, $this->H->calls); 66 } 67 68 function testLinebreakPlusEol() { 69 $this->P->addMode('linebreak',new Linebreak()); 70 $this->P->addMode('eol',new Eol()); 71 $this->P->parse('Foo\\\\'."\n\n".'Bar'); 72 73 $calls = [ 74 ['document_start',[]], 75 ['p_open',[]], 76 ['cdata',["Foo"]], 77 ['linebreak',[]], 78 ['p_close',[]], 79 ['p_open',[]], 80 ['cdata',["Bar"]], 81 ['p_close',[]], 82 ['document_end',[]], 83 ]; 84 $this->assertCalls($calls, $this->H->calls); 85 } 86 87 function testLinebreakInvalid() { 88 $this->P->addMode('linebreak',new Linebreak()); 89 $this->P->parse('Foo\\\\Bar'); 90 $calls = [ 91 ['document_start',[]], 92 ['p_open',[]], 93 ['cdata',["\n".'Foo\\\\Bar']], 94 ['p_close',[]], 95 ['document_end',[]], 96 ]; 97 $this->assertCalls($calls, $this->H->calls); 98 } 99 100} 101