1*504c13e8SAndreas Gohr<?php 2*504c13e8SAndreas Gohr 3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\ParserMode; 4*504c13e8SAndreas Gohr 5*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Code; 6*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Eol; 7*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\File; 8*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Header; 9*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Listblock; 10*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Preformatted; 11*504c13e8SAndreas Gohr 12*504c13e8SAndreas Gohrclass PreformattedTest extends ParserTestBase 13*504c13e8SAndreas Gohr{ 14*504c13e8SAndreas Gohr 15*504c13e8SAndreas Gohr function testFile() { 16*504c13e8SAndreas Gohr $this->P->addMode('file',new File()); 17*504c13e8SAndreas Gohr $this->P->parse('Foo <file>testing</file> Bar'); 18*504c13e8SAndreas Gohr $calls = [ 19*504c13e8SAndreas Gohr ['document_start',[]], 20*504c13e8SAndreas Gohr ['p_open',[]], 21*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 22*504c13e8SAndreas Gohr ['p_close',[]], 23*504c13e8SAndreas Gohr ['file',['testing',null,null]], 24*504c13e8SAndreas Gohr ['p_open',[]], 25*504c13e8SAndreas Gohr ['cdata',[' Bar']], 26*504c13e8SAndreas Gohr ['p_close',[]], 27*504c13e8SAndreas Gohr ['document_end',[]], 28*504c13e8SAndreas Gohr ]; 29*504c13e8SAndreas Gohr 30*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 31*504c13e8SAndreas Gohr } 32*504c13e8SAndreas Gohr 33*504c13e8SAndreas Gohr function testCode() { 34*504c13e8SAndreas Gohr $this->P->addMode('code',new Code()); 35*504c13e8SAndreas Gohr $this->P->parse('Foo <code>testing</code> Bar'); 36*504c13e8SAndreas Gohr $calls = [ 37*504c13e8SAndreas Gohr ['document_start',[]], 38*504c13e8SAndreas Gohr ['p_open',[]], 39*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 40*504c13e8SAndreas Gohr ['p_close',[]], 41*504c13e8SAndreas Gohr ['code',['testing', null, null]], 42*504c13e8SAndreas Gohr ['p_open',[]], 43*504c13e8SAndreas Gohr ['cdata',[' Bar']], 44*504c13e8SAndreas Gohr ['p_close',[]], 45*504c13e8SAndreas Gohr ['document_end',[]], 46*504c13e8SAndreas Gohr ]; 47*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 48*504c13e8SAndreas Gohr } 49*504c13e8SAndreas Gohr 50*504c13e8SAndreas Gohr function testCodeWhitespace() { 51*504c13e8SAndreas Gohr $this->P->addMode('code',new Code()); 52*504c13e8SAndreas Gohr $this->P->parse("Foo <code \n>testing</code> Bar"); 53*504c13e8SAndreas Gohr $calls = [ 54*504c13e8SAndreas Gohr ['document_start',[]], 55*504c13e8SAndreas Gohr ['p_open',[]], 56*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 57*504c13e8SAndreas Gohr ['p_close',[]], 58*504c13e8SAndreas Gohr ['code',['testing', null, null]], 59*504c13e8SAndreas Gohr ['p_open',[]], 60*504c13e8SAndreas Gohr ['cdata',[' Bar']], 61*504c13e8SAndreas Gohr ['p_close',[]], 62*504c13e8SAndreas Gohr ['document_end',[]], 63*504c13e8SAndreas Gohr ]; 64*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 65*504c13e8SAndreas Gohr } 66*504c13e8SAndreas Gohr 67*504c13e8SAndreas Gohr function testCodeLang() { 68*504c13e8SAndreas Gohr $this->P->addMode('code',new Code()); 69*504c13e8SAndreas Gohr $this->P->parse("Foo <code php>testing</code> Bar"); 70*504c13e8SAndreas Gohr $calls = [ 71*504c13e8SAndreas Gohr ['document_start',[]], 72*504c13e8SAndreas Gohr ['p_open',[]], 73*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 74*504c13e8SAndreas Gohr ['p_close',[]], 75*504c13e8SAndreas Gohr ['code',['testing', 'php', null]], 76*504c13e8SAndreas Gohr ['p_open',[]], 77*504c13e8SAndreas Gohr ['cdata',[' Bar']], 78*504c13e8SAndreas Gohr ['p_close',[]], 79*504c13e8SAndreas Gohr ['document_end',[]], 80*504c13e8SAndreas Gohr ]; 81*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 82*504c13e8SAndreas Gohr } 83*504c13e8SAndreas Gohr 84*504c13e8SAndreas Gohr function testPreformatted() { 85*504c13e8SAndreas Gohr $this->P->addMode('preformatted',new Preformatted()); 86*504c13e8SAndreas Gohr $this->P->parse("F oo\n x \n y \nBar\n"); 87*504c13e8SAndreas Gohr $calls = [ 88*504c13e8SAndreas Gohr ['document_start',[]], 89*504c13e8SAndreas Gohr ['p_open',[]], 90*504c13e8SAndreas Gohr ['cdata',["\nF oo"]], 91*504c13e8SAndreas Gohr ['p_close',[]], 92*504c13e8SAndreas Gohr ['preformatted',["x \n y "]], 93*504c13e8SAndreas Gohr ['p_open',[]], 94*504c13e8SAndreas Gohr ['cdata',['Bar']], 95*504c13e8SAndreas Gohr ['p_close',[]], 96*504c13e8SAndreas Gohr ['document_end',[]], 97*504c13e8SAndreas Gohr ]; 98*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 99*504c13e8SAndreas Gohr } 100*504c13e8SAndreas Gohr 101*504c13e8SAndreas Gohr function testPreformattedWinEOL() { 102*504c13e8SAndreas Gohr $this->P->addMode('preformatted',new Preformatted()); 103*504c13e8SAndreas Gohr $this->P->parse("F oo\r\n x \r\n y \r\nBar\r\n"); 104*504c13e8SAndreas Gohr $calls = [ 105*504c13e8SAndreas Gohr ['document_start',[]], 106*504c13e8SAndreas Gohr ['p_open',[]], 107*504c13e8SAndreas Gohr ['cdata',["\nF oo"]], 108*504c13e8SAndreas Gohr ['p_close',[]], 109*504c13e8SAndreas Gohr ['preformatted',["x \n y "]], 110*504c13e8SAndreas Gohr ['p_open',[]], 111*504c13e8SAndreas Gohr ['cdata',['Bar']], 112*504c13e8SAndreas Gohr ['p_close',[]], 113*504c13e8SAndreas Gohr ['document_end',[]], 114*504c13e8SAndreas Gohr ]; 115*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 116*504c13e8SAndreas Gohr } 117*504c13e8SAndreas Gohr 118*504c13e8SAndreas Gohr function testPreformattedTab() { 119*504c13e8SAndreas Gohr $this->P->addMode('preformatted',new Preformatted()); 120*504c13e8SAndreas Gohr $this->P->parse("F oo\n\tx\t\n\t\ty\t\nBar\n"); 121*504c13e8SAndreas Gohr $calls = [ 122*504c13e8SAndreas Gohr ['document_start',[]], 123*504c13e8SAndreas Gohr ['p_open',[]], 124*504c13e8SAndreas Gohr ['cdata',["\nF oo"]], 125*504c13e8SAndreas Gohr ['p_close',[]], 126*504c13e8SAndreas Gohr ['preformatted',["x\t\n\ty\t"]], 127*504c13e8SAndreas Gohr ['p_open',[]], 128*504c13e8SAndreas Gohr ['cdata',["Bar"]], 129*504c13e8SAndreas Gohr ['p_close',[]], 130*504c13e8SAndreas Gohr ['document_end',[]], 131*504c13e8SAndreas Gohr ]; 132*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 133*504c13e8SAndreas Gohr } 134*504c13e8SAndreas Gohr 135*504c13e8SAndreas Gohr function testPreformattedTabWinEOL() { 136*504c13e8SAndreas Gohr $this->P->addMode('preformatted',new Preformatted()); 137*504c13e8SAndreas Gohr $this->P->parse("F oo\r\n\tx\t\r\n\t\ty\t\r\nBar\r\n"); 138*504c13e8SAndreas Gohr $calls = [ 139*504c13e8SAndreas Gohr ['document_start',[]], 140*504c13e8SAndreas Gohr ['p_open',[]], 141*504c13e8SAndreas Gohr ['cdata',["\nF oo"]], 142*504c13e8SAndreas Gohr ['p_close',[]], 143*504c13e8SAndreas Gohr ['preformatted',["x\t\n\ty\t"]], 144*504c13e8SAndreas Gohr ['p_open',[]], 145*504c13e8SAndreas Gohr ['cdata',["Bar"]], 146*504c13e8SAndreas Gohr ['p_close',[]], 147*504c13e8SAndreas Gohr ['document_end',[]], 148*504c13e8SAndreas Gohr ]; 149*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 150*504c13e8SAndreas Gohr } 151*504c13e8SAndreas Gohr 152*504c13e8SAndreas Gohr function testPreformattedList() { 153*504c13e8SAndreas Gohr $this->P->addMode('preformatted',new Preformatted()); 154*504c13e8SAndreas Gohr $this->P->addMode('listblock',new Listblock()); 155*504c13e8SAndreas Gohr $this->P->parse(" - x \n * y \nF oo\n x \n y \n -X\n *Y\nBar\n"); 156*504c13e8SAndreas Gohr $calls = [ 157*504c13e8SAndreas Gohr ['document_start',[]], 158*504c13e8SAndreas Gohr ['listo_open',[]], 159*504c13e8SAndreas Gohr ['listitem_open',[1]], 160*504c13e8SAndreas Gohr ['listcontent_open',[]], 161*504c13e8SAndreas Gohr ['cdata',[" x "]], 162*504c13e8SAndreas Gohr ['listcontent_close',[]], 163*504c13e8SAndreas Gohr ['listitem_close',[]], 164*504c13e8SAndreas Gohr ['listo_close',[]], 165*504c13e8SAndreas Gohr ['listu_open',[]], 166*504c13e8SAndreas Gohr ['listitem_open',[1]], 167*504c13e8SAndreas Gohr ['listcontent_open',[]], 168*504c13e8SAndreas Gohr ['cdata',[" y "]], 169*504c13e8SAndreas Gohr ['listcontent_close',[]], 170*504c13e8SAndreas Gohr ['listitem_close',[]], 171*504c13e8SAndreas Gohr ['listu_close',[]], 172*504c13e8SAndreas Gohr ['p_open',[]], 173*504c13e8SAndreas Gohr ['cdata',["F oo"]], 174*504c13e8SAndreas Gohr ['p_close',[]], 175*504c13e8SAndreas Gohr ['preformatted',["x \n y \n-X\n*Y"]], 176*504c13e8SAndreas Gohr ['p_open',[]], 177*504c13e8SAndreas Gohr ['cdata',["Bar"]], 178*504c13e8SAndreas Gohr ['p_close',[]], 179*504c13e8SAndreas Gohr ['document_end',[]], 180*504c13e8SAndreas Gohr ]; 181*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 182*504c13e8SAndreas Gohr } 183*504c13e8SAndreas Gohr 184*504c13e8SAndreas Gohr 185*504c13e8SAndreas Gohr function testPreformattedPlusHeaderAndEol() { 186*504c13e8SAndreas Gohr // Note that EOL must come after preformatted! 187*504c13e8SAndreas Gohr $this->P->addMode('preformatted',new Preformatted()); 188*504c13e8SAndreas Gohr $this->P->addMode('header',new Header()); 189*504c13e8SAndreas Gohr $this->P->addMode('eol',new Eol()); 190*504c13e8SAndreas Gohr $this->P->parse("F oo\n ==Test==\n y \nBar\n"); 191*504c13e8SAndreas Gohr $calls = [ 192*504c13e8SAndreas Gohr ['document_start',[]], 193*504c13e8SAndreas Gohr ['p_open',[]], 194*504c13e8SAndreas Gohr ['cdata',["F oo"]], 195*504c13e8SAndreas Gohr ['p_close',[]], 196*504c13e8SAndreas Gohr ['preformatted',["==Test==\n y "]], 197*504c13e8SAndreas Gohr ['p_open',[]], 198*504c13e8SAndreas Gohr ['cdata',['Bar']], 199*504c13e8SAndreas Gohr ['p_close',[]], 200*504c13e8SAndreas Gohr ['document_end',[]], 201*504c13e8SAndreas Gohr ]; 202*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 203*504c13e8SAndreas Gohr } 204*504c13e8SAndreas Gohr} 205