1*504c13e8SAndreas Gohr<?php 2*504c13e8SAndreas Gohr 3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\ParserMode; 4*504c13e8SAndreas Gohr 5*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Acronym; 6*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Deleted; 7*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Emphasis; 8*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Header; 9*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Monospace; 10*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Strong; 11*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Subscript; 12*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Superscript; 13*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Underline; 14*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Internallink; 15*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Table; 16*504c13e8SAndreas Gohr 17*504c13e8SAndreas Gohrclass I18nTest extends ParserTestBase 18*504c13e8SAndreas Gohr{ 19*504c13e8SAndreas Gohr 20*504c13e8SAndreas Gohr function testFormatting() { 21*504c13e8SAndreas Gohr $formats = [ 22*504c13e8SAndreas Gohr 'strong' => new Strong(), 23*504c13e8SAndreas Gohr 'emphasis' => new Emphasis(), 24*504c13e8SAndreas Gohr 'underline' => new Underline(), 25*504c13e8SAndreas Gohr 'monospace' => new Monospace(), 26*504c13e8SAndreas Gohr 'subscript' => new Subscript(), 27*504c13e8SAndreas Gohr 'superscript' => new Superscript(), 28*504c13e8SAndreas Gohr 'deleted' => new Deleted(), 29*504c13e8SAndreas Gohr ]; 30*504c13e8SAndreas Gohr foreach ($formats as $name => $obj) { 31*504c13e8SAndreas Gohr $this->P->addMode($name, $obj); 32*504c13e8SAndreas Gohr } 33*504c13e8SAndreas Gohr $this->P->parse("I**ñ**t__ë__r//n//â<sup>t</sup>i<sub>ô</sub>n''à''liz<del>æ</del>tiøn"); 34*504c13e8SAndreas Gohr $calls = [ 35*504c13e8SAndreas Gohr ['document_start',[]], 36*504c13e8SAndreas Gohr ['p_open',[]], 37*504c13e8SAndreas Gohr ['cdata',["\nI"]], 38*504c13e8SAndreas Gohr ['strong_open',[]], 39*504c13e8SAndreas Gohr ['cdata',['ñ']], 40*504c13e8SAndreas Gohr ['strong_close',[]], 41*504c13e8SAndreas Gohr ['cdata',['t']], 42*504c13e8SAndreas Gohr ['underline_open',[]], 43*504c13e8SAndreas Gohr ['cdata',['ë']], 44*504c13e8SAndreas Gohr ['underline_close',[]], 45*504c13e8SAndreas Gohr ['cdata',['r']], 46*504c13e8SAndreas Gohr ['emphasis_open',[]], 47*504c13e8SAndreas Gohr ['cdata',['n']], 48*504c13e8SAndreas Gohr ['emphasis_close',[]], 49*504c13e8SAndreas Gohr ['cdata',['â']], 50*504c13e8SAndreas Gohr ['superscript_open',[]], 51*504c13e8SAndreas Gohr ['cdata',['t']], 52*504c13e8SAndreas Gohr ['superscript_close',[]], 53*504c13e8SAndreas Gohr ['cdata',['i']], 54*504c13e8SAndreas Gohr ['subscript_open',[]], 55*504c13e8SAndreas Gohr ['cdata',['ô']], 56*504c13e8SAndreas Gohr ['subscript_close',[]], 57*504c13e8SAndreas Gohr ['cdata',['n']], 58*504c13e8SAndreas Gohr ['monospace_open',[]], 59*504c13e8SAndreas Gohr ['cdata',['à']], 60*504c13e8SAndreas Gohr ['monospace_close',[]], 61*504c13e8SAndreas Gohr ['cdata',['liz']], 62*504c13e8SAndreas Gohr ['deleted_open',[]], 63*504c13e8SAndreas Gohr ['cdata',['æ']], 64*504c13e8SAndreas Gohr ['deleted_close',[]], 65*504c13e8SAndreas Gohr ['cdata',["tiøn"]], 66*504c13e8SAndreas Gohr ['p_close',[]], 67*504c13e8SAndreas Gohr ['document_end',[]], 68*504c13e8SAndreas Gohr ]; 69*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 70*504c13e8SAndreas Gohr } 71*504c13e8SAndreas Gohr 72*504c13e8SAndreas Gohr function testHeader() { 73*504c13e8SAndreas Gohr $this->P->addMode('header',new Header()); 74*504c13e8SAndreas Gohr $this->P->parse("Foo\n ==== Iñtërnâtiônàlizætiøn ==== \n Bar"); 75*504c13e8SAndreas Gohr $calls = [ 76*504c13e8SAndreas Gohr ['document_start',[]], 77*504c13e8SAndreas Gohr ['p_open',[]], 78*504c13e8SAndreas Gohr ['cdata',["\nFoo"]], 79*504c13e8SAndreas Gohr ['p_close',[]], 80*504c13e8SAndreas Gohr ['header',['Iñtërnâtiônàlizætiøn',3,5]], 81*504c13e8SAndreas Gohr ['section_open',[3]], 82*504c13e8SAndreas Gohr ['p_open',[]], 83*504c13e8SAndreas Gohr ['cdata',["\n Bar"]], 84*504c13e8SAndreas Gohr ['p_close',[]], 85*504c13e8SAndreas Gohr ['section_close',[]], 86*504c13e8SAndreas Gohr ['document_end',[]], 87*504c13e8SAndreas Gohr ]; 88*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 89*504c13e8SAndreas Gohr } 90*504c13e8SAndreas Gohr 91*504c13e8SAndreas Gohr function testTable() { 92*504c13e8SAndreas Gohr $this->P->addMode('table',new Table()); 93*504c13e8SAndreas Gohr $this->P->parse(' 94*504c13e8SAndreas Gohrabc 95*504c13e8SAndreas Gohr| Row 0 Col 1 | Iñtërnâtiônàlizætiøn | Row 0 Col 3 | 96*504c13e8SAndreas Gohr| Row 1 Col 1 | Iñtërnâtiônàlizætiøn | Row 1 Col 3 | 97*504c13e8SAndreas Gohrdef'); 98*504c13e8SAndreas Gohr $calls = [ 99*504c13e8SAndreas Gohr ['document_start',[]], 100*504c13e8SAndreas Gohr ['p_open',[]], 101*504c13e8SAndreas Gohr ['cdata',["\n\nabc"]], 102*504c13e8SAndreas Gohr ['p_close',[]], 103*504c13e8SAndreas Gohr ['table_open',[3, 2, 6]], 104*504c13e8SAndreas Gohr ['tablerow_open',[]], 105*504c13e8SAndreas Gohr ['tablecell_open',[1,'left',1]], 106*504c13e8SAndreas Gohr ['cdata',[' Row 0 Col 1 ']], 107*504c13e8SAndreas Gohr ['tablecell_close',[]], 108*504c13e8SAndreas Gohr ['tablecell_open',[1,'left',1]], 109*504c13e8SAndreas Gohr ['cdata',[' Iñtërnâtiônàlizætiøn ']], 110*504c13e8SAndreas Gohr ['tablecell_close',[]], 111*504c13e8SAndreas Gohr ['tablecell_open',[1,'left',1]], 112*504c13e8SAndreas Gohr ['cdata',[' Row 0 Col 3 ']], 113*504c13e8SAndreas Gohr ['tablecell_close',[]], 114*504c13e8SAndreas Gohr ['tablerow_close',[]], 115*504c13e8SAndreas Gohr ['tablerow_open',[]], 116*504c13e8SAndreas Gohr ['tablecell_open',[1,'left',1]], 117*504c13e8SAndreas Gohr ['cdata',[' Row 1 Col 1 ']], 118*504c13e8SAndreas Gohr ['tablecell_close',[]], 119*504c13e8SAndreas Gohr ['tablecell_open',[1,'left',1]], 120*504c13e8SAndreas Gohr ['cdata',[' Iñtërnâtiônàlizætiøn ']], 121*504c13e8SAndreas Gohr ['tablecell_close',[]], 122*504c13e8SAndreas Gohr ['tablecell_open',[1,'left',1]], 123*504c13e8SAndreas Gohr ['cdata',[' Row 1 Col 3 ']], 124*504c13e8SAndreas Gohr ['tablecell_close',[]], 125*504c13e8SAndreas Gohr ['tablerow_close',[]], 126*504c13e8SAndreas Gohr ['table_close',[153]], 127*504c13e8SAndreas Gohr ['p_open',[]], 128*504c13e8SAndreas Gohr ['cdata',['def']], 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 testAcronym() { 136*504c13e8SAndreas Gohr $t = ['Iñtërnâtiônàlizætiøn']; 137*504c13e8SAndreas Gohr $this->P->addMode('acronym',new Acronym($t)); 138*504c13e8SAndreas Gohr $this->P->parse("Foo Iñtërnâtiônàlizætiøn Bar"); 139*504c13e8SAndreas Gohr $calls = [ 140*504c13e8SAndreas Gohr ['document_start',[]], 141*504c13e8SAndreas Gohr ['p_open',[]], 142*504c13e8SAndreas Gohr ['cdata',["\nFoo "]], 143*504c13e8SAndreas Gohr ['acronym',['Iñtërnâtiônàlizætiøn']], 144*504c13e8SAndreas Gohr ['cdata',[" Bar"]], 145*504c13e8SAndreas Gohr ['p_close',[]], 146*504c13e8SAndreas Gohr ['document_end',[]], 147*504c13e8SAndreas Gohr ]; 148*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 149*504c13e8SAndreas Gohr } 150*504c13e8SAndreas Gohr 151*504c13e8SAndreas Gohr function testInterwiki() { 152*504c13e8SAndreas Gohr $this->P->addMode('internallink',new InternalLink()); 153*504c13e8SAndreas Gohr $this->P->parse("Foo [[wp>Iñtërnâtiônàlizætiøn|Iñtërnâtiônàlizætiøn]] Bar"); 154*504c13e8SAndreas Gohr $calls = [ 155*504c13e8SAndreas Gohr ['document_start',[]], 156*504c13e8SAndreas Gohr ['p_open',[]], 157*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 158*504c13e8SAndreas Gohr ['interwikilink',['wp>Iñtërnâtiônàlizætiøn','Iñtërnâtiônàlizætiøn','wp','Iñtërnâtiônàlizætiøn']], 159*504c13e8SAndreas Gohr ['cdata',[' Bar']], 160*504c13e8SAndreas Gohr ['p_close',[]], 161*504c13e8SAndreas Gohr ['document_end',[]], 162*504c13e8SAndreas Gohr ]; 163*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 164*504c13e8SAndreas Gohr } 165*504c13e8SAndreas Gohr 166*504c13e8SAndreas Gohr function testInternalLink() { 167*504c13e8SAndreas Gohr $this->P->addMode('internallink',new InternalLink()); 168*504c13e8SAndreas Gohr $this->P->parse("Foo [[x:Iñtërnâtiônàlizætiøn:y:foo_bar:z|Iñtërnâtiônàlizætiøn]] Bar"); 169*504c13e8SAndreas Gohr $calls = [ 170*504c13e8SAndreas Gohr ['document_start',[]], 171*504c13e8SAndreas Gohr ['p_open',[]], 172*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 173*504c13e8SAndreas Gohr ['internallink',['x:Iñtërnâtiônàlizætiøn:y:foo_bar:z','Iñtërnâtiônàlizætiøn']], 174*504c13e8SAndreas Gohr ['cdata',[' Bar']], 175*504c13e8SAndreas Gohr ['p_close',[]], 176*504c13e8SAndreas Gohr ['document_end',[]], 177*504c13e8SAndreas Gohr ]; 178*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 179*504c13e8SAndreas Gohr } 180*504c13e8SAndreas Gohr 181*504c13e8SAndreas Gohr} 182