1*504c13e8SAndreas Gohr<?php 2*504c13e8SAndreas Gohr 3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\ParserMode; 4*504c13e8SAndreas Gohr 5*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Quotes; 6*504c13e8SAndreas Gohr 7*504c13e8SAndreas Gohrclass QuotesTest extends ParserTestBase 8*504c13e8SAndreas Gohr{ 9*504c13e8SAndreas Gohr 10*504c13e8SAndreas Gohr function setUp() : void { 11*504c13e8SAndreas Gohr parent::setUp(); 12*504c13e8SAndreas Gohr global $conf; 13*504c13e8SAndreas Gohr $conf['typography'] = 2; 14*504c13e8SAndreas Gohr } 15*504c13e8SAndreas Gohr 16*504c13e8SAndreas Gohr function testSingleQuoteOpening() { 17*504c13e8SAndreas Gohr $raw = "Foo 'hello Bar"; 18*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 19*504c13e8SAndreas Gohr $this->P->parse($raw); 20*504c13e8SAndreas Gohr 21*504c13e8SAndreas Gohr $calls = [ 22*504c13e8SAndreas Gohr ['document_start',[]], 23*504c13e8SAndreas Gohr ['p_open',[]], 24*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 25*504c13e8SAndreas Gohr ['singlequoteopening',[]], 26*504c13e8SAndreas Gohr ['cdata',['hello Bar']], 27*504c13e8SAndreas Gohr ['p_close',[]], 28*504c13e8SAndreas Gohr ['document_end',[]], 29*504c13e8SAndreas Gohr ]; 30*504c13e8SAndreas Gohr 31*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 32*504c13e8SAndreas Gohr } 33*504c13e8SAndreas Gohr 34*504c13e8SAndreas Gohr function testSingleQuoteOpeningSpecial() { 35*504c13e8SAndreas Gohr $raw = "Foo said:'hello Bar"; 36*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 37*504c13e8SAndreas Gohr $this->P->parse($raw); 38*504c13e8SAndreas Gohr 39*504c13e8SAndreas Gohr $calls = [ 40*504c13e8SAndreas Gohr ['document_start',[]], 41*504c13e8SAndreas Gohr ['p_open',[]], 42*504c13e8SAndreas Gohr ['cdata',["\n".'Foo said:']], 43*504c13e8SAndreas Gohr ['singlequoteopening',[]], 44*504c13e8SAndreas Gohr ['cdata',['hello Bar']], 45*504c13e8SAndreas Gohr ['p_close',[]], 46*504c13e8SAndreas Gohr ['document_end',[]], 47*504c13e8SAndreas Gohr ]; 48*504c13e8SAndreas Gohr 49*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 50*504c13e8SAndreas Gohr } 51*504c13e8SAndreas Gohr 52*504c13e8SAndreas Gohr function testSingleQuoteClosing() { 53*504c13e8SAndreas Gohr $raw = "Foo hello' Bar"; 54*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 55*504c13e8SAndreas Gohr $this->P->parse($raw); 56*504c13e8SAndreas Gohr 57*504c13e8SAndreas Gohr $calls = [ 58*504c13e8SAndreas Gohr ['document_start',[]], 59*504c13e8SAndreas Gohr ['p_open',[]], 60*504c13e8SAndreas Gohr ['cdata',["\n".'Foo hello']], 61*504c13e8SAndreas Gohr ['singlequoteclosing',[]], 62*504c13e8SAndreas Gohr ['cdata',[' Bar']], 63*504c13e8SAndreas Gohr ['p_close',[]], 64*504c13e8SAndreas Gohr ['document_end',[]], 65*504c13e8SAndreas Gohr ]; 66*504c13e8SAndreas Gohr 67*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 68*504c13e8SAndreas Gohr } 69*504c13e8SAndreas Gohr 70*504c13e8SAndreas Gohr function testSingleQuoteClosingSpecial() { 71*504c13e8SAndreas Gohr $raw = "Foo hello') Bar"; 72*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 73*504c13e8SAndreas Gohr $this->P->parse($raw); 74*504c13e8SAndreas Gohr 75*504c13e8SAndreas Gohr $calls = [ 76*504c13e8SAndreas Gohr ['document_start',[]], 77*504c13e8SAndreas Gohr ['p_open',[]], 78*504c13e8SAndreas Gohr ['cdata',["\n".'Foo hello']], 79*504c13e8SAndreas Gohr ['singlequoteclosing',[]], 80*504c13e8SAndreas Gohr ['cdata',[') Bar']], 81*504c13e8SAndreas Gohr ['p_close',[]], 82*504c13e8SAndreas Gohr ['document_end',[]], 83*504c13e8SAndreas Gohr ]; 84*504c13e8SAndreas Gohr 85*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 86*504c13e8SAndreas Gohr } 87*504c13e8SAndreas Gohr 88*504c13e8SAndreas Gohr function testSingleQuotes() { 89*504c13e8SAndreas Gohr $raw = "Foo 'hello' Bar"; 90*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 91*504c13e8SAndreas Gohr $this->P->parse($raw); 92*504c13e8SAndreas Gohr 93*504c13e8SAndreas Gohr $calls = [ 94*504c13e8SAndreas Gohr ['document_start',[]], 95*504c13e8SAndreas Gohr ['p_open',[]], 96*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 97*504c13e8SAndreas Gohr ['singlequoteopening',[]], 98*504c13e8SAndreas Gohr ['cdata',['hello']], 99*504c13e8SAndreas Gohr ['singlequoteclosing',[]], 100*504c13e8SAndreas Gohr ['cdata',[' Bar']], 101*504c13e8SAndreas Gohr ['p_close',[]], 102*504c13e8SAndreas Gohr ['document_end',[]], 103*504c13e8SAndreas Gohr ]; 104*504c13e8SAndreas Gohr 105*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 106*504c13e8SAndreas Gohr } 107*504c13e8SAndreas Gohr 108*504c13e8SAndreas Gohr function testApostrophe() { 109*504c13e8SAndreas Gohr $raw = "hey it's fine weather today"; 110*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 111*504c13e8SAndreas Gohr $this->P->parse($raw); 112*504c13e8SAndreas Gohr 113*504c13e8SAndreas Gohr $calls = [ 114*504c13e8SAndreas Gohr ['document_start',[]], 115*504c13e8SAndreas Gohr ['p_open',[]], 116*504c13e8SAndreas Gohr ['cdata',["\n".'hey it']], 117*504c13e8SAndreas Gohr ['apostrophe',[]], 118*504c13e8SAndreas Gohr ['cdata',['s fine weather today']], 119*504c13e8SAndreas Gohr ['p_close',[]], 120*504c13e8SAndreas Gohr ['document_end',[]], 121*504c13e8SAndreas Gohr ]; 122*504c13e8SAndreas Gohr 123*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 124*504c13e8SAndreas Gohr } 125*504c13e8SAndreas Gohr 126*504c13e8SAndreas Gohr 127*504c13e8SAndreas Gohr function testSingleQuotesSpecial() { 128*504c13e8SAndreas Gohr $raw = "Foo ('hello') Bar"; 129*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 130*504c13e8SAndreas Gohr $this->P->parse($raw); 131*504c13e8SAndreas Gohr 132*504c13e8SAndreas Gohr $calls = [ 133*504c13e8SAndreas Gohr ['document_start',[]], 134*504c13e8SAndreas Gohr ['p_open',[]], 135*504c13e8SAndreas Gohr ['cdata',["\n".'Foo (']], 136*504c13e8SAndreas Gohr ['singlequoteopening',[]], 137*504c13e8SAndreas Gohr ['cdata',['hello']], 138*504c13e8SAndreas Gohr ['singlequoteclosing',[]], 139*504c13e8SAndreas Gohr ['cdata',[') Bar']], 140*504c13e8SAndreas Gohr ['p_close',[]], 141*504c13e8SAndreas Gohr ['document_end',[]], 142*504c13e8SAndreas Gohr ]; 143*504c13e8SAndreas Gohr 144*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 145*504c13e8SAndreas Gohr } 146*504c13e8SAndreas Gohr 147*504c13e8SAndreas Gohr function testDoubleQuoteOpening() { 148*504c13e8SAndreas Gohr $raw = 'Foo "hello Bar'; 149*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 150*504c13e8SAndreas Gohr $this->P->parse($raw); 151*504c13e8SAndreas Gohr 152*504c13e8SAndreas Gohr $calls = [ 153*504c13e8SAndreas Gohr ['document_start',[]], 154*504c13e8SAndreas Gohr ['p_open',[]], 155*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 156*504c13e8SAndreas Gohr ['doublequoteopening',[]], 157*504c13e8SAndreas Gohr ['cdata',['hello Bar']], 158*504c13e8SAndreas Gohr ['p_close',[]], 159*504c13e8SAndreas Gohr ['document_end',[]], 160*504c13e8SAndreas Gohr ]; 161*504c13e8SAndreas Gohr 162*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 163*504c13e8SAndreas Gohr } 164*504c13e8SAndreas Gohr 165*504c13e8SAndreas Gohr function testDoubleQuoteOpeningSpecial() { 166*504c13e8SAndreas Gohr $raw = 'Foo said:"hello Bar'; 167*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 168*504c13e8SAndreas Gohr $this->P->parse($raw); 169*504c13e8SAndreas Gohr 170*504c13e8SAndreas Gohr $calls = [ 171*504c13e8SAndreas Gohr ['document_start',[]], 172*504c13e8SAndreas Gohr ['p_open',[]], 173*504c13e8SAndreas Gohr ['cdata',["\n".'Foo said:']], 174*504c13e8SAndreas Gohr ['doublequoteopening',[]], 175*504c13e8SAndreas Gohr ['cdata',['hello Bar']], 176*504c13e8SAndreas Gohr ['p_close',[]], 177*504c13e8SAndreas Gohr ['document_end',[]], 178*504c13e8SAndreas Gohr ]; 179*504c13e8SAndreas Gohr 180*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 181*504c13e8SAndreas Gohr } 182*504c13e8SAndreas Gohr 183*504c13e8SAndreas Gohr function testDoubleQuoteClosing() { 184*504c13e8SAndreas Gohr $raw = 'Foo hello" Bar'; 185*504c13e8SAndreas Gohr $this->P->addMode('quotes', new Quotes()); 186*504c13e8SAndreas Gohr $this->H->setStatus('doublequote', 1); 187*504c13e8SAndreas Gohr $this->P->parse($raw); 188*504c13e8SAndreas Gohr 189*504c13e8SAndreas Gohr $calls = [ 190*504c13e8SAndreas Gohr ['document_start',[]], 191*504c13e8SAndreas Gohr ['p_open',[]], 192*504c13e8SAndreas Gohr ['cdata',["\n".'Foo hello']], 193*504c13e8SAndreas Gohr ['doublequoteclosing',[]], 194*504c13e8SAndreas Gohr ['cdata',[' Bar']], 195*504c13e8SAndreas Gohr ['p_close',[]], 196*504c13e8SAndreas Gohr ['document_end',[]], 197*504c13e8SAndreas Gohr ]; 198*504c13e8SAndreas Gohr 199*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 200*504c13e8SAndreas Gohr } 201*504c13e8SAndreas Gohr 202*504c13e8SAndreas Gohr function testDoubleQuoteClosingSpecial() { 203*504c13e8SAndreas Gohr $raw = 'Foo hello") Bar'; 204*504c13e8SAndreas Gohr $this->P->addMode('quotes', new Quotes()); 205*504c13e8SAndreas Gohr $this->H->setStatus('doublequote', 1); 206*504c13e8SAndreas Gohr 207*504c13e8SAndreas Gohr $this->P->parse($raw); 208*504c13e8SAndreas Gohr 209*504c13e8SAndreas Gohr $calls = [ 210*504c13e8SAndreas Gohr ['document_start',[]], 211*504c13e8SAndreas Gohr ['p_open',[]], 212*504c13e8SAndreas Gohr ['cdata',["\n".'Foo hello']], 213*504c13e8SAndreas Gohr ['doublequoteclosing',[]], 214*504c13e8SAndreas Gohr ['cdata',[') Bar']], 215*504c13e8SAndreas Gohr ['p_close',[]], 216*504c13e8SAndreas Gohr ['document_end',[]], 217*504c13e8SAndreas Gohr ]; 218*504c13e8SAndreas Gohr 219*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 220*504c13e8SAndreas Gohr } 221*504c13e8SAndreas Gohr function testDoubleQuoteClosingSpecial2() { 222*504c13e8SAndreas Gohr $raw = 'Foo hello") Bar'; 223*504c13e8SAndreas Gohr $this->P->addMode('quotes', new Quotes()); 224*504c13e8SAndreas Gohr 225*504c13e8SAndreas Gohr $this->P->parse($raw); 226*504c13e8SAndreas Gohr 227*504c13e8SAndreas Gohr $calls = [ 228*504c13e8SAndreas Gohr ['document_start',[]], 229*504c13e8SAndreas Gohr ['p_open',[]], 230*504c13e8SAndreas Gohr ['cdata',["\n".'Foo hello']], 231*504c13e8SAndreas Gohr ['doublequoteopening',[]], 232*504c13e8SAndreas Gohr ['cdata',[') Bar']], 233*504c13e8SAndreas Gohr ['p_close',[]], 234*504c13e8SAndreas Gohr ['document_end',[]], 235*504c13e8SAndreas Gohr ]; 236*504c13e8SAndreas Gohr 237*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 238*504c13e8SAndreas Gohr } 239*504c13e8SAndreas Gohr 240*504c13e8SAndreas Gohr function testDoubleQuotes() { 241*504c13e8SAndreas Gohr $raw = 'Foo "hello" Bar'; 242*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 243*504c13e8SAndreas Gohr $this->P->parse($raw); 244*504c13e8SAndreas Gohr 245*504c13e8SAndreas Gohr $calls = [ 246*504c13e8SAndreas Gohr ['document_start',[]], 247*504c13e8SAndreas Gohr ['p_open',[]], 248*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 249*504c13e8SAndreas Gohr ['doublequoteopening',[]], 250*504c13e8SAndreas Gohr ['cdata',['hello']], 251*504c13e8SAndreas Gohr ['doublequoteclosing',[]], 252*504c13e8SAndreas Gohr ['cdata',[' Bar']], 253*504c13e8SAndreas Gohr ['p_close',[]], 254*504c13e8SAndreas Gohr ['document_end',[]], 255*504c13e8SAndreas Gohr ]; 256*504c13e8SAndreas Gohr 257*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 258*504c13e8SAndreas Gohr } 259*504c13e8SAndreas Gohr 260*504c13e8SAndreas Gohr function testDoubleQuotesSpecial() { 261*504c13e8SAndreas Gohr $raw = 'Foo ("hello") Bar'; 262*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 263*504c13e8SAndreas Gohr $this->P->parse($raw); 264*504c13e8SAndreas Gohr 265*504c13e8SAndreas Gohr $calls = [ 266*504c13e8SAndreas Gohr ['document_start',[]], 267*504c13e8SAndreas Gohr ['p_open',[]], 268*504c13e8SAndreas Gohr ['cdata',["\n".'Foo (']], 269*504c13e8SAndreas Gohr ['doublequoteopening',[]], 270*504c13e8SAndreas Gohr ['cdata',['hello']], 271*504c13e8SAndreas Gohr ['doublequoteclosing',[]], 272*504c13e8SAndreas Gohr ['cdata',[') Bar']], 273*504c13e8SAndreas Gohr ['p_close',[]], 274*504c13e8SAndreas Gohr ['document_end',[]], 275*504c13e8SAndreas Gohr ]; 276*504c13e8SAndreas Gohr 277*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 278*504c13e8SAndreas Gohr } 279*504c13e8SAndreas Gohr 280*504c13e8SAndreas Gohr function testDoubleQuotesEnclosingBrackets() { 281*504c13e8SAndreas Gohr $raw = 'Foo "{hello}" Bar'; 282*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 283*504c13e8SAndreas Gohr $this->P->parse($raw); 284*504c13e8SAndreas Gohr 285*504c13e8SAndreas Gohr $calls = [ 286*504c13e8SAndreas Gohr ['document_start',[]], 287*504c13e8SAndreas Gohr ['p_open',[]], 288*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 289*504c13e8SAndreas Gohr ['doublequoteopening',[]], 290*504c13e8SAndreas Gohr ['cdata',['{hello}']], 291*504c13e8SAndreas Gohr ['doublequoteclosing',[]], 292*504c13e8SAndreas Gohr ['cdata',[' Bar']], 293*504c13e8SAndreas Gohr ['p_close',[]], 294*504c13e8SAndreas Gohr ['document_end',[]], 295*504c13e8SAndreas Gohr ]; 296*504c13e8SAndreas Gohr 297*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext - '.$raw); 298*504c13e8SAndreas Gohr } 299*504c13e8SAndreas Gohr 300*504c13e8SAndreas Gohr function testDoubleQuotesEnclosingLink() { 301*504c13e8SAndreas Gohr $raw = 'Foo "[[www.domain.com]]" Bar'; 302*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 303*504c13e8SAndreas Gohr $this->P->parse($raw); 304*504c13e8SAndreas Gohr 305*504c13e8SAndreas Gohr $calls = [ 306*504c13e8SAndreas Gohr ['document_start',[]], 307*504c13e8SAndreas Gohr ['p_open',[]], 308*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 309*504c13e8SAndreas Gohr ['doublequoteopening',[]], 310*504c13e8SAndreas Gohr ['cdata',['[[www.domain.com]]']], 311*504c13e8SAndreas Gohr ['doublequoteclosing',[]], 312*504c13e8SAndreas Gohr ['cdata',[' Bar']], 313*504c13e8SAndreas Gohr ['p_close',[]], 314*504c13e8SAndreas Gohr ['document_end',[]], 315*504c13e8SAndreas Gohr ]; 316*504c13e8SAndreas Gohr 317*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 318*504c13e8SAndreas Gohr } 319*504c13e8SAndreas Gohr 320*504c13e8SAndreas Gohr 321*504c13e8SAndreas Gohr function testAllQuotes() { 322*504c13e8SAndreas Gohr $raw = 'There was written "He thought \'It\'s a man\'s world\'".'; 323*504c13e8SAndreas Gohr $this->P->addMode('quotes',new Quotes()); 324*504c13e8SAndreas Gohr $this->P->parse($raw); 325*504c13e8SAndreas Gohr 326*504c13e8SAndreas Gohr $calls = [ 327*504c13e8SAndreas Gohr ['document_start',[]], 328*504c13e8SAndreas Gohr ['p_open',[]], 329*504c13e8SAndreas Gohr ['cdata',["\n".'There was written ']], 330*504c13e8SAndreas Gohr ['doublequoteopening',[]], 331*504c13e8SAndreas Gohr ['cdata',['He thought ']], 332*504c13e8SAndreas Gohr ['singlequoteopening',[]], 333*504c13e8SAndreas Gohr ['cdata',['It']], 334*504c13e8SAndreas Gohr ['apostrophe',[]], 335*504c13e8SAndreas Gohr ['cdata',['s a man']], 336*504c13e8SAndreas Gohr ['apostrophe',[]], 337*504c13e8SAndreas Gohr ['cdata',['s world']], 338*504c13e8SAndreas Gohr ['singlequoteclosing',[]], 339*504c13e8SAndreas Gohr ['doublequoteclosing',[]], 340*504c13e8SAndreas Gohr ['cdata',["."]], 341*504c13e8SAndreas Gohr ['p_close',[]], 342*504c13e8SAndreas Gohr ['document_end',[]], 343*504c13e8SAndreas Gohr ]; 344*504c13e8SAndreas Gohr 345*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, 'wikitext => '.$raw); 346*504c13e8SAndreas Gohr } 347*504c13e8SAndreas Gohr 348*504c13e8SAndreas Gohr} 349