1*504c13e8SAndreas Gohr<?php 2*504c13e8SAndreas Gohr 3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\ParserMode; 4*504c13e8SAndreas Gohr 5*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Camelcaselink; 6*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Emaillink; 7*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Externallink; 8*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Filelink; 9*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Internallink; 10*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Media; 11*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Windowssharelink; 12*504c13e8SAndreas Gohr 13*504c13e8SAndreas Gohr/** 14*504c13e8SAndreas Gohr * Tests for the implementation of link syntax 15*504c13e8SAndreas Gohr * 16*504c13e8SAndreas Gohr * @group parser_links 17*504c13e8SAndreas Gohr*/ 18*504c13e8SAndreas Gohrclass LinksTest extends ParserTestBase 19*504c13e8SAndreas Gohr{ 20*504c13e8SAndreas Gohr 21*504c13e8SAndreas Gohr function testExternalLinkSimple() { 22*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 23*504c13e8SAndreas Gohr $this->P->parse("Foo http://www.google.com Bar"); 24*504c13e8SAndreas Gohr $calls = [ 25*504c13e8SAndreas Gohr ['document_start',[]], 26*504c13e8SAndreas Gohr ['p_open',[]], 27*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 28*504c13e8SAndreas Gohr ['externallink',['http://www.google.com', null]], 29*504c13e8SAndreas Gohr ['cdata',[' Bar']], 30*504c13e8SAndreas Gohr ['p_close',[]], 31*504c13e8SAndreas Gohr ['document_end',[]], 32*504c13e8SAndreas Gohr ]; 33*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 34*504c13e8SAndreas Gohr } 35*504c13e8SAndreas Gohr 36*504c13e8SAndreas Gohr function testExternalLinkCase() { 37*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 38*504c13e8SAndreas Gohr $this->P->parse("Foo HTTP://WWW.GOOGLE.COM Bar"); 39*504c13e8SAndreas Gohr $calls = [ 40*504c13e8SAndreas Gohr ['document_start',[]], 41*504c13e8SAndreas Gohr ['p_open',[]], 42*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 43*504c13e8SAndreas Gohr ['externallink',['HTTP://WWW.GOOGLE.COM', null]], 44*504c13e8SAndreas Gohr ['cdata',[' Bar']], 45*504c13e8SAndreas Gohr ['p_close',[]], 46*504c13e8SAndreas Gohr ['document_end',[]], 47*504c13e8SAndreas Gohr ]; 48*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 49*504c13e8SAndreas Gohr } 50*504c13e8SAndreas Gohr 51*504c13e8SAndreas Gohr function testExternalIPv4() { 52*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 53*504c13e8SAndreas Gohr $this->P->parse("Foo http://123.123.3.21/foo Bar"); 54*504c13e8SAndreas Gohr $calls = [ 55*504c13e8SAndreas Gohr ['document_start',[]], 56*504c13e8SAndreas Gohr ['p_open',[]], 57*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 58*504c13e8SAndreas Gohr ['externallink',['http://123.123.3.21/foo', null]], 59*504c13e8SAndreas Gohr ['cdata',[' Bar']], 60*504c13e8SAndreas Gohr ['p_close',[]], 61*504c13e8SAndreas Gohr ['document_end',[]], 62*504c13e8SAndreas Gohr ]; 63*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 64*504c13e8SAndreas Gohr } 65*504c13e8SAndreas Gohr 66*504c13e8SAndreas Gohr function testExternalIPv6() { 67*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 68*504c13e8SAndreas Gohr $this->P->parse("Foo http://[3ffe:2a00:100:7031::1]/foo Bar"); 69*504c13e8SAndreas Gohr $calls = [ 70*504c13e8SAndreas Gohr ['document_start',[]], 71*504c13e8SAndreas Gohr ['p_open',[]], 72*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 73*504c13e8SAndreas Gohr ['externallink',['http://[3ffe:2a00:100:7031::1]/foo', null]], 74*504c13e8SAndreas Gohr ['cdata',[' Bar']], 75*504c13e8SAndreas Gohr ['p_close',[]], 76*504c13e8SAndreas Gohr ['document_end',[]], 77*504c13e8SAndreas Gohr ]; 78*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 79*504c13e8SAndreas Gohr } 80*504c13e8SAndreas Gohr 81*504c13e8SAndreas Gohr function testExternalMulti(){ 82*504c13e8SAndreas Gohr $this->teardown(); 83*504c13e8SAndreas Gohr 84*504c13e8SAndreas Gohr $links = [ 85*504c13e8SAndreas Gohr 'http://www.google.com', 86*504c13e8SAndreas Gohr 'HTTP://WWW.GOOGLE.COM', 87*504c13e8SAndreas Gohr 'http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html', 88*504c13e8SAndreas Gohr 'http://[1080:0:0:0:8:800:200C:417A]/index.html', 89*504c13e8SAndreas Gohr 'http://[3ffe:2a00:100:7031::1]', 90*504c13e8SAndreas Gohr 'http://[1080::8:800:200C:417A]/foo', 91*504c13e8SAndreas Gohr 'http://[::192.9.5.5]/ipng', 92*504c13e8SAndreas Gohr 'http://[::FFFF:129.144.52.38]:80/index.html', 93*504c13e8SAndreas Gohr 'http://[2010:836B:4179::836B:4179]', 94*504c13e8SAndreas Gohr ]; 95*504c13e8SAndreas Gohr $titles = [false,null,'foo bar']; 96*504c13e8SAndreas Gohr foreach($links as $link){ 97*504c13e8SAndreas Gohr foreach($titles as $title){ 98*504c13e8SAndreas Gohr if($title === false){ 99*504c13e8SAndreas Gohr $source = $link; 100*504c13e8SAndreas Gohr $name = null; 101*504c13e8SAndreas Gohr }elseif($title === null){ 102*504c13e8SAndreas Gohr $source = "[[$link]]"; 103*504c13e8SAndreas Gohr $name = null; 104*504c13e8SAndreas Gohr }else{ 105*504c13e8SAndreas Gohr $source = "[[$link|$title]]"; 106*504c13e8SAndreas Gohr $name = $title; 107*504c13e8SAndreas Gohr } 108*504c13e8SAndreas Gohr $this->setup(); 109*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 110*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 111*504c13e8SAndreas Gohr $this->P->parse("Foo $source Bar"); 112*504c13e8SAndreas Gohr $calls = [ 113*504c13e8SAndreas Gohr ['document_start',[]], 114*504c13e8SAndreas Gohr ['p_open',[]], 115*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 116*504c13e8SAndreas Gohr ['externallink',[$link, $name]], 117*504c13e8SAndreas Gohr ['cdata',[' Bar']], 118*504c13e8SAndreas Gohr ['p_close',[]], 119*504c13e8SAndreas Gohr ['document_end',[]], 120*504c13e8SAndreas Gohr ]; 121*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls, $source); 122*504c13e8SAndreas Gohr $this->teardown(); 123*504c13e8SAndreas Gohr } 124*504c13e8SAndreas Gohr } 125*504c13e8SAndreas Gohr 126*504c13e8SAndreas Gohr $this->setup(); 127*504c13e8SAndreas Gohr } 128*504c13e8SAndreas Gohr 129*504c13e8SAndreas Gohr function testExternalLinkJavascript() { 130*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 131*504c13e8SAndreas Gohr $this->P->parse("Foo javascript:alert('XSS'); Bar"); 132*504c13e8SAndreas Gohr $calls = [ 133*504c13e8SAndreas Gohr ['document_start',[]], 134*504c13e8SAndreas Gohr ['p_open',[]], 135*504c13e8SAndreas Gohr ['cdata',["\nFoo javascript:alert('XSS'); Bar"]], 136*504c13e8SAndreas Gohr ['p_close',[]], 137*504c13e8SAndreas Gohr ['document_end',[]], 138*504c13e8SAndreas Gohr ]; 139*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 140*504c13e8SAndreas Gohr } 141*504c13e8SAndreas Gohr 142*504c13e8SAndreas Gohr function testExternalWWWLink() { 143*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 144*504c13e8SAndreas Gohr $this->P->parse("Foo www.google.com Bar"); 145*504c13e8SAndreas Gohr $calls = [ 146*504c13e8SAndreas Gohr ['document_start',[]], 147*504c13e8SAndreas Gohr ['p_open',[]], 148*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 149*504c13e8SAndreas Gohr ['externallink',['http://www.google.com', 'www.google.com']], 150*504c13e8SAndreas Gohr ['cdata',[' Bar']], 151*504c13e8SAndreas Gohr ['p_close',[]], 152*504c13e8SAndreas Gohr ['document_end',[]], 153*504c13e8SAndreas Gohr ]; 154*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 155*504c13e8SAndreas Gohr } 156*504c13e8SAndreas Gohr 157*504c13e8SAndreas Gohr function testExternalWWWLinkStartOfLine() { 158*504c13e8SAndreas Gohr // Regression test for issue #2399 159*504c13e8SAndreas Gohr $calls = [ 160*504c13e8SAndreas Gohr ['document_start',[]], 161*504c13e8SAndreas Gohr ['p_open',[]], 162*504c13e8SAndreas Gohr ['externallink',['http://www.google.com', 'www.google.com']], 163*504c13e8SAndreas Gohr ['cdata',[' Bar']], 164*504c13e8SAndreas Gohr ['p_close',[]], 165*504c13e8SAndreas Gohr ['document_end',[]], 166*504c13e8SAndreas Gohr ]; 167*504c13e8SAndreas Gohr $instructions = p_get_instructions("www.google.com Bar"); 168*504c13e8SAndreas Gohr $this->assertCalls($calls, $instructions); 169*504c13e8SAndreas Gohr } 170*504c13e8SAndreas Gohr 171*504c13e8SAndreas Gohr function testExternalWWWLinkInRoundBrackets() { 172*504c13e8SAndreas Gohr $this->P->addMode('externallink',new ExternalLink()); 173*504c13e8SAndreas Gohr $this->P->parse("Foo (www.google.com) Bar"); 174*504c13e8SAndreas Gohr $calls = [ 175*504c13e8SAndreas Gohr ['document_start',[]], 176*504c13e8SAndreas Gohr ['p_open',[]], 177*504c13e8SAndreas Gohr ['cdata',["\n".'Foo (']], 178*504c13e8SAndreas Gohr ['externallink',['http://www.google.com', 'www.google.com']], 179*504c13e8SAndreas Gohr ['cdata',[') Bar']], 180*504c13e8SAndreas Gohr ['p_close',[]], 181*504c13e8SAndreas Gohr ['document_end',[]], 182*504c13e8SAndreas Gohr ]; 183*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 184*504c13e8SAndreas Gohr } 185*504c13e8SAndreas Gohr 186*504c13e8SAndreas Gohr function testExternalWWWLinkInPath() { 187*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 188*504c13e8SAndreas Gohr // See issue #936. Should NOT generate a link! 189*504c13e8SAndreas Gohr $this->P->parse("Foo /home/subdir/www/www.something.de/somedir/ Bar"); 190*504c13e8SAndreas Gohr $calls = [ 191*504c13e8SAndreas Gohr ['document_start',[]], 192*504c13e8SAndreas Gohr ['p_open',[]], 193*504c13e8SAndreas Gohr ['cdata',["\n".'Foo /home/subdir/www/www.something.de/somedir/ Bar']], 194*504c13e8SAndreas Gohr ['p_close',[]], 195*504c13e8SAndreas Gohr ['document_end',[]], 196*504c13e8SAndreas Gohr ]; 197*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 198*504c13e8SAndreas Gohr } 199*504c13e8SAndreas Gohr 200*504c13e8SAndreas Gohr function testExternalWWWLinkFollowingPath() { 201*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 202*504c13e8SAndreas Gohr $this->P->parse("Foo /home/subdir/www/ www.something.de/somedir/ Bar"); 203*504c13e8SAndreas Gohr $calls = [ 204*504c13e8SAndreas Gohr ['document_start',[]], 205*504c13e8SAndreas Gohr ['p_open',[]], 206*504c13e8SAndreas Gohr ['cdata',["\n".'Foo /home/subdir/www/ ']], 207*504c13e8SAndreas Gohr ['externallink',['http://www.something.de/somedir/', 'www.something.de/somedir/']], 208*504c13e8SAndreas Gohr ['cdata',[' Bar']], 209*504c13e8SAndreas Gohr ['p_close',[]], 210*504c13e8SAndreas Gohr ['document_end',[]], 211*504c13e8SAndreas Gohr ]; 212*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 213*504c13e8SAndreas Gohr } 214*504c13e8SAndreas Gohr 215*504c13e8SAndreas Gohr function testExternalFTPLink() { 216*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 217*504c13e8SAndreas Gohr $this->P->parse("Foo ftp.sunsite.com Bar"); 218*504c13e8SAndreas Gohr $calls = [ 219*504c13e8SAndreas Gohr ['document_start',[]], 220*504c13e8SAndreas Gohr ['p_open',[]], 221*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 222*504c13e8SAndreas Gohr ['externallink',['ftp://ftp.sunsite.com', 'ftp.sunsite.com']], 223*504c13e8SAndreas Gohr ['cdata',[' Bar']], 224*504c13e8SAndreas Gohr ['p_close',[]], 225*504c13e8SAndreas Gohr ['document_end',[]], 226*504c13e8SAndreas Gohr ]; 227*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 228*504c13e8SAndreas Gohr } 229*504c13e8SAndreas Gohr 230*504c13e8SAndreas Gohr function testExternalFTPLinkInPath() { 231*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 232*504c13e8SAndreas Gohr // See issue #936. Should NOT generate a link! 233*504c13e8SAndreas Gohr $this->P->parse("Foo /home/subdir/www/ftp.something.de/somedir/ Bar"); 234*504c13e8SAndreas Gohr $calls = [ 235*504c13e8SAndreas Gohr ['document_start',[]], 236*504c13e8SAndreas Gohr ['p_open',[]], 237*504c13e8SAndreas Gohr ['cdata',["\n".'Foo /home/subdir/www/ftp.something.de/somedir/ Bar']], 238*504c13e8SAndreas Gohr ['p_close',[]], 239*504c13e8SAndreas Gohr ['document_end',[]], 240*504c13e8SAndreas Gohr ]; 241*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 242*504c13e8SAndreas Gohr } 243*504c13e8SAndreas Gohr 244*504c13e8SAndreas Gohr function testExternalFTPLinkFollowingPath() { 245*504c13e8SAndreas Gohr $this->P->addMode('externallink',new Externallink()); 246*504c13e8SAndreas Gohr $this->P->parse("Foo /home/subdir/www/ ftp.something.de/somedir/ Bar"); 247*504c13e8SAndreas Gohr $calls = [ 248*504c13e8SAndreas Gohr ['document_start',[]], 249*504c13e8SAndreas Gohr ['p_open',[]], 250*504c13e8SAndreas Gohr ['cdata',["\n".'Foo /home/subdir/www/ ']], 251*504c13e8SAndreas Gohr ['externallink',['ftp://ftp.something.de/somedir/', 'ftp.something.de/somedir/']], 252*504c13e8SAndreas Gohr ['cdata',[' Bar']], 253*504c13e8SAndreas Gohr ['p_close',[]], 254*504c13e8SAndreas Gohr ['document_end',[]], 255*504c13e8SAndreas Gohr ]; 256*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 257*504c13e8SAndreas Gohr } 258*504c13e8SAndreas Gohr 259*504c13e8SAndreas Gohr function testEmail() { 260*504c13e8SAndreas Gohr $this->P->addMode('emaillink',new Emaillink()); 261*504c13e8SAndreas Gohr $this->P->parse("Foo <bugs@php.net> Bar"); 262*504c13e8SAndreas Gohr $calls = [ 263*504c13e8SAndreas Gohr ['document_start',[]], 264*504c13e8SAndreas Gohr ['p_open',[]], 265*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 266*504c13e8SAndreas Gohr ['emaillink',['bugs@php.net', null]], 267*504c13e8SAndreas Gohr ['cdata',[' Bar']], 268*504c13e8SAndreas Gohr ['p_close',[]], 269*504c13e8SAndreas Gohr ['document_end',[]], 270*504c13e8SAndreas Gohr ]; 271*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 272*504c13e8SAndreas Gohr } 273*504c13e8SAndreas Gohr 274*504c13e8SAndreas Gohr function testEmailRFC2822() { 275*504c13e8SAndreas Gohr $this->P->addMode('emaillink',new Emaillink()); 276*504c13e8SAndreas Gohr $this->P->parse("Foo <~fix+bug's.for/ev{e}r@php.net> Bar"); 277*504c13e8SAndreas Gohr $calls = [ 278*504c13e8SAndreas Gohr ['document_start',[]], 279*504c13e8SAndreas Gohr ['p_open',[]], 280*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 281*504c13e8SAndreas Gohr ['emaillink',["~fix+bug's.for/ev{e}r@php.net", null]], 282*504c13e8SAndreas Gohr ['cdata',[' Bar']], 283*504c13e8SAndreas Gohr ['p_close',[]], 284*504c13e8SAndreas Gohr ['document_end',[]], 285*504c13e8SAndreas Gohr ]; 286*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 287*504c13e8SAndreas Gohr } 288*504c13e8SAndreas Gohr 289*504c13e8SAndreas Gohr function testEmailCase() { 290*504c13e8SAndreas Gohr $this->P->addMode('emaillink',new Emaillink()); 291*504c13e8SAndreas Gohr $this->P->parse("Foo <bugs@pHp.net> Bar"); 292*504c13e8SAndreas Gohr $calls = [ 293*504c13e8SAndreas Gohr ['document_start',[]], 294*504c13e8SAndreas Gohr ['p_open',[]], 295*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 296*504c13e8SAndreas Gohr ['emaillink',['bugs@pHp.net', null]], 297*504c13e8SAndreas Gohr ['cdata',[' Bar']], 298*504c13e8SAndreas Gohr ['p_close',[]], 299*504c13e8SAndreas Gohr ['document_end',[]], 300*504c13e8SAndreas Gohr ]; 301*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 302*504c13e8SAndreas Gohr } 303*504c13e8SAndreas Gohr 304*504c13e8SAndreas Gohr 305*504c13e8SAndreas Gohr function testInternalLinkOneChar() { 306*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 307*504c13e8SAndreas Gohr $this->P->parse("Foo [[l]] Bar"); 308*504c13e8SAndreas Gohr $calls = [ 309*504c13e8SAndreas Gohr ['document_start',[]], 310*504c13e8SAndreas Gohr ['p_open',[]], 311*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 312*504c13e8SAndreas Gohr ['internallink',['l',null]], 313*504c13e8SAndreas Gohr ['cdata',[' Bar']], 314*504c13e8SAndreas Gohr ['p_close',[]], 315*504c13e8SAndreas Gohr ['document_end',[]], 316*504c13e8SAndreas Gohr ]; 317*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 318*504c13e8SAndreas Gohr } 319*504c13e8SAndreas Gohr 320*504c13e8SAndreas Gohr function testInternalLinkNoChar() { 321*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 322*504c13e8SAndreas Gohr $this->P->parse("Foo [[]] Bar"); 323*504c13e8SAndreas Gohr $calls = [ 324*504c13e8SAndreas Gohr ['document_start',[]], 325*504c13e8SAndreas Gohr ['p_open',[]], 326*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 327*504c13e8SAndreas Gohr ['internallink',['',null]], 328*504c13e8SAndreas Gohr ['cdata',[' Bar']], 329*504c13e8SAndreas Gohr ['p_close',[]], 330*504c13e8SAndreas Gohr ['document_end',[]], 331*504c13e8SAndreas Gohr ]; 332*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 333*504c13e8SAndreas Gohr } 334*504c13e8SAndreas Gohr 335*504c13e8SAndreas Gohr function testInternalLinkNamespaceNoTitle() { 336*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 337*504c13e8SAndreas Gohr $this->P->parse("Foo [[foo:bar]] Bar"); 338*504c13e8SAndreas Gohr $calls = [ 339*504c13e8SAndreas Gohr ['document_start',[]], 340*504c13e8SAndreas Gohr ['p_open',[]], 341*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 342*504c13e8SAndreas Gohr ['internallink',['foo:bar',null]], 343*504c13e8SAndreas Gohr ['cdata',[' Bar']], 344*504c13e8SAndreas Gohr ['p_close',[]], 345*504c13e8SAndreas Gohr ['document_end',[]], 346*504c13e8SAndreas Gohr ]; 347*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 348*504c13e8SAndreas Gohr } 349*504c13e8SAndreas Gohr 350*504c13e8SAndreas Gohr function testInternalLinkNamespace() { 351*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 352*504c13e8SAndreas Gohr $this->P->parse("Foo [[x:1:y:foo_bar:z|Test]] Bar"); 353*504c13e8SAndreas Gohr $calls = [ 354*504c13e8SAndreas Gohr ['document_start',[]], 355*504c13e8SAndreas Gohr ['p_open',[]], 356*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 357*504c13e8SAndreas Gohr ['internallink',['x:1:y:foo_bar:z','Test']], 358*504c13e8SAndreas Gohr ['cdata',[' Bar']], 359*504c13e8SAndreas Gohr ['p_close',[]], 360*504c13e8SAndreas Gohr ['document_end',[]], 361*504c13e8SAndreas Gohr ]; 362*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 363*504c13e8SAndreas Gohr } 364*504c13e8SAndreas Gohr 365*504c13e8SAndreas Gohr function testInternalLinkSectionRef() { 366*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 367*504c13e8SAndreas Gohr $this->P->parse("Foo [[wiki:syntax#internal|Syntax]] Bar"); 368*504c13e8SAndreas Gohr $calls = [ 369*504c13e8SAndreas Gohr ['document_start',[]], 370*504c13e8SAndreas Gohr ['p_open',[]], 371*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 372*504c13e8SAndreas Gohr ['internallink',['wiki:syntax#internal','Syntax']], 373*504c13e8SAndreas Gohr ['cdata',[' Bar']], 374*504c13e8SAndreas Gohr ['p_close',[]], 375*504c13e8SAndreas Gohr ['document_end',[]], 376*504c13e8SAndreas Gohr ]; 377*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 378*504c13e8SAndreas Gohr } 379*504c13e8SAndreas Gohr 380*504c13e8SAndreas Gohr function testInternalLinkCodeFollows() { 381*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 382*504c13e8SAndreas Gohr $this->P->parse("Foo [[wiki:internal:link|Test]] Bar <code>command [arg1 [arg2 [arg3]]]</code>"); 383*504c13e8SAndreas Gohr $calls = [ 384*504c13e8SAndreas Gohr ['document_start',[]], 385*504c13e8SAndreas Gohr ['p_open',[]], 386*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 387*504c13e8SAndreas Gohr ['internallink',['wiki:internal:link','Test']], 388*504c13e8SAndreas Gohr ['cdata',[' Bar <code>command [arg1 [arg2 [arg3]]]</code>']], 389*504c13e8SAndreas Gohr ['p_close',[]], 390*504c13e8SAndreas Gohr ['document_end',[]], 391*504c13e8SAndreas Gohr ]; 392*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 393*504c13e8SAndreas Gohr } 394*504c13e8SAndreas Gohr 395*504c13e8SAndreas Gohr function testInternalLinkCodeFollows2() { 396*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 397*504c13e8SAndreas Gohr $this->P->parse("Foo [[wiki:internal:link|[Square brackets in title] Test]] Bar <code>command [arg1 [arg2 [arg3]]]</code>"); 398*504c13e8SAndreas Gohr $calls = [ 399*504c13e8SAndreas Gohr ['document_start',[]], 400*504c13e8SAndreas Gohr ['p_open',[]], 401*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 402*504c13e8SAndreas Gohr ['internallink',['wiki:internal:link','[Square brackets in title] Test']], 403*504c13e8SAndreas Gohr ['cdata',[' Bar <code>command [arg1 [arg2 [arg3]]]</code>']], 404*504c13e8SAndreas Gohr ['p_close',[]], 405*504c13e8SAndreas Gohr ['document_end',[]], 406*504c13e8SAndreas Gohr ]; 407*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 408*504c13e8SAndreas Gohr } 409*504c13e8SAndreas Gohr 410*504c13e8SAndreas Gohr function testExternalInInternalLink() { 411*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 412*504c13e8SAndreas Gohr $this->P->parse("Foo [[http://www.google.com|Google]] Bar"); 413*504c13e8SAndreas Gohr $calls = [ 414*504c13e8SAndreas Gohr ['document_start',[]], 415*504c13e8SAndreas Gohr ['p_open',[]], 416*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 417*504c13e8SAndreas Gohr ['externallink',['http://www.google.com','Google']], 418*504c13e8SAndreas Gohr ['cdata',[' Bar']], 419*504c13e8SAndreas Gohr ['p_close',[]], 420*504c13e8SAndreas Gohr ['document_end',[]], 421*504c13e8SAndreas Gohr ]; 422*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 423*504c13e8SAndreas Gohr } 424*504c13e8SAndreas Gohr 425*504c13e8SAndreas Gohr function testExternalInInternalLink2() { 426*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 427*504c13e8SAndreas Gohr $this->P->parse("Foo [[http://www.google.com?test[]=squarebracketsinurl|Google]] Bar"); 428*504c13e8SAndreas Gohr $calls = [ 429*504c13e8SAndreas Gohr ['document_start',[]], 430*504c13e8SAndreas Gohr ['p_open',[]], 431*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 432*504c13e8SAndreas Gohr ['externallink',['http://www.google.com?test[]=squarebracketsinurl','Google']], 433*504c13e8SAndreas Gohr ['cdata',[' Bar']], 434*504c13e8SAndreas Gohr ['p_close',[]], 435*504c13e8SAndreas Gohr ['document_end',[]], 436*504c13e8SAndreas Gohr ]; 437*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 438*504c13e8SAndreas Gohr } 439*504c13e8SAndreas Gohr 440*504c13e8SAndreas Gohr function testExternalInInternalLink2CodeFollows() { 441*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 442*504c13e8SAndreas Gohr $this->P->parse("Foo [[http://www.google.com?test[]=squarebracketsinurl|Google]] Bar <code>command [arg1 [arg2 [arg3]]]</code>"); 443*504c13e8SAndreas Gohr $calls = [ 444*504c13e8SAndreas Gohr ['document_start',[]], 445*504c13e8SAndreas Gohr ['p_open',[]], 446*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 447*504c13e8SAndreas Gohr ['externallink',['http://www.google.com?test[]=squarebracketsinurl','Google']], 448*504c13e8SAndreas Gohr ['cdata',[' Bar <code>command [arg1 [arg2 [arg3]]]</code>']], 449*504c13e8SAndreas Gohr ['p_close',[]], 450*504c13e8SAndreas Gohr ['document_end',[]], 451*504c13e8SAndreas Gohr ]; 452*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 453*504c13e8SAndreas Gohr } 454*504c13e8SAndreas Gohr 455*504c13e8SAndreas Gohr function testTwoInternalLinks() { 456*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 457*504c13e8SAndreas Gohr $this->P->parse("Foo [[foo:bar|one]] and [[bar:foo|two]] Bar"); 458*504c13e8SAndreas Gohr $calls = [ 459*504c13e8SAndreas Gohr ['document_start',[]], 460*504c13e8SAndreas Gohr ['p_open',[]], 461*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 462*504c13e8SAndreas Gohr ['internallink',['foo:bar','one']], 463*504c13e8SAndreas Gohr ['cdata',[' and ']], 464*504c13e8SAndreas Gohr ['internallink',['bar:foo','two']], 465*504c13e8SAndreas Gohr ['cdata',[' Bar']], 466*504c13e8SAndreas Gohr ['p_close',[]], 467*504c13e8SAndreas Gohr ['document_end',[]], 468*504c13e8SAndreas Gohr ]; 469*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 470*504c13e8SAndreas Gohr } 471*504c13e8SAndreas Gohr 472*504c13e8SAndreas Gohr 473*504c13e8SAndreas Gohr function testInterwikiLink() { 474*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 475*504c13e8SAndreas Gohr $this->P->parse("Foo [[iw>somepage|Some Page]] Bar"); 476*504c13e8SAndreas Gohr $calls = [ 477*504c13e8SAndreas Gohr ['document_start',[]], 478*504c13e8SAndreas Gohr ['p_open',[]], 479*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 480*504c13e8SAndreas Gohr ['interwikilink',['iw>somepage','Some Page','iw','somepage']], 481*504c13e8SAndreas Gohr ['cdata',[' Bar']], 482*504c13e8SAndreas Gohr ['p_close',[]], 483*504c13e8SAndreas Gohr ['document_end',[]], 484*504c13e8SAndreas Gohr ]; 485*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 486*504c13e8SAndreas Gohr } 487*504c13e8SAndreas Gohr 488*504c13e8SAndreas Gohr function testInterwikiLinkCase() { 489*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 490*504c13e8SAndreas Gohr $this->P->parse("Foo [[IW>somepage|Some Page]] Bar"); 491*504c13e8SAndreas Gohr $calls = [ 492*504c13e8SAndreas Gohr ['document_start',[]], 493*504c13e8SAndreas Gohr ['p_open',[]], 494*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 495*504c13e8SAndreas Gohr ['interwikilink',['IW>somepage','Some Page','iw','somepage']], 496*504c13e8SAndreas Gohr ['cdata',[' Bar']], 497*504c13e8SAndreas Gohr ['p_close',[]], 498*504c13e8SAndreas Gohr ['document_end',[]], 499*504c13e8SAndreas Gohr ]; 500*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 501*504c13e8SAndreas Gohr } 502*504c13e8SAndreas Gohr 503*504c13e8SAndreas Gohr function testInterwikiPedia() { 504*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 505*504c13e8SAndreas Gohr $this->P->parse("Foo [[wp>Callback_(computer_science)|callbacks]] Bar"); 506*504c13e8SAndreas Gohr $calls = [ 507*504c13e8SAndreas Gohr ['document_start',[]], 508*504c13e8SAndreas Gohr ['p_open',[]], 509*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 510*504c13e8SAndreas Gohr ['interwikilink',['wp>Callback_(computer_science)','callbacks','wp','Callback_(computer_science)']], 511*504c13e8SAndreas Gohr ['cdata',[' Bar']], 512*504c13e8SAndreas Gohr ['p_close',[]], 513*504c13e8SAndreas Gohr ['document_end',[]], 514*504c13e8SAndreas Gohr ]; 515*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 516*504c13e8SAndreas Gohr } 517*504c13e8SAndreas Gohr 518*504c13e8SAndreas Gohr function testCamelCase() { 519*504c13e8SAndreas Gohr $this->P->addMode('camelcaselink',new Camelcaselink()); 520*504c13e8SAndreas Gohr $this->P->parse("Foo FooBar Bar"); 521*504c13e8SAndreas Gohr $calls = [ 522*504c13e8SAndreas Gohr ['document_start',[]], 523*504c13e8SAndreas Gohr ['p_open',[]], 524*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 525*504c13e8SAndreas Gohr ['camelcaselink',['FooBar']], 526*504c13e8SAndreas Gohr ['cdata',[' Bar']], 527*504c13e8SAndreas Gohr ['p_close',[]], 528*504c13e8SAndreas Gohr ['document_end',[]], 529*504c13e8SAndreas Gohr ]; 530*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 531*504c13e8SAndreas Gohr } 532*504c13e8SAndreas Gohr 533*504c13e8SAndreas Gohr function testFileLink() { 534*504c13e8SAndreas Gohr $this->P->addMode('filelink',new FileLink()); 535*504c13e8SAndreas Gohr $this->P->parse('Foo file://temp/file.txt Bar'); 536*504c13e8SAndreas Gohr $calls = [ 537*504c13e8SAndreas Gohr ['document_start',[]], 538*504c13e8SAndreas Gohr ['p_open',[]], 539*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 540*504c13e8SAndreas Gohr ['filelink',['file://temp/file.txt ',null]], 541*504c13e8SAndreas Gohr ['cdata',['Bar']], 542*504c13e8SAndreas Gohr ['p_close',[]], 543*504c13e8SAndreas Gohr ['document_end',[]], 544*504c13e8SAndreas Gohr ]; 545*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 546*504c13e8SAndreas Gohr } 547*504c13e8SAndreas Gohr 548*504c13e8SAndreas Gohr function testFileLinkInternal() { 549*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 550*504c13e8SAndreas Gohr $this->P->parse('Foo [[file://temp/file.txt|Some File]] Bar'); 551*504c13e8SAndreas Gohr $calls = [ 552*504c13e8SAndreas Gohr ['document_start',[]], 553*504c13e8SAndreas Gohr ['p_open',[]], 554*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 555*504c13e8SAndreas Gohr ['externallink',['file://temp/file.txt','Some File']], 556*504c13e8SAndreas Gohr ['cdata',[' Bar']], 557*504c13e8SAndreas Gohr ['p_close',[]], 558*504c13e8SAndreas Gohr ['document_end',[]], 559*504c13e8SAndreas Gohr ]; 560*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 561*504c13e8SAndreas Gohr } 562*504c13e8SAndreas Gohr 563*504c13e8SAndreas Gohr function testWindowsShareLink() { 564*504c13e8SAndreas Gohr $this->P->addMode('windowssharelink',new Windowssharelink()); 565*504c13e8SAndreas Gohr $this->P->parse('Foo \\\server\share Bar'); 566*504c13e8SAndreas Gohr $calls = [ 567*504c13e8SAndreas Gohr ['document_start',[]], 568*504c13e8SAndreas Gohr ['p_open',[]], 569*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 570*504c13e8SAndreas Gohr ['windowssharelink',['\\\server\share',null]], 571*504c13e8SAndreas Gohr ['cdata',[' Bar']], 572*504c13e8SAndreas Gohr ['p_close',[]], 573*504c13e8SAndreas Gohr ['document_end',[]], 574*504c13e8SAndreas Gohr ]; 575*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 576*504c13e8SAndreas Gohr } 577*504c13e8SAndreas Gohr 578*504c13e8SAndreas Gohr function testWindowsShareLinkHyphen() { 579*504c13e8SAndreas Gohr $this->P->addMode('windowssharelink',new Windowssharelink()); 580*504c13e8SAndreas Gohr $this->P->parse('Foo \\\server\share-hyphen Bar'); 581*504c13e8SAndreas Gohr $calls = [ 582*504c13e8SAndreas Gohr ['document_start',[]], 583*504c13e8SAndreas Gohr ['p_open',[]], 584*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 585*504c13e8SAndreas Gohr ['windowssharelink',['\\\server\share-hyphen',null]], 586*504c13e8SAndreas Gohr ['cdata',[' Bar']], 587*504c13e8SAndreas Gohr ['p_close',[]], 588*504c13e8SAndreas Gohr ['document_end',[]], 589*504c13e8SAndreas Gohr ]; 590*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 591*504c13e8SAndreas Gohr } 592*504c13e8SAndreas Gohr 593*504c13e8SAndreas Gohr function testWindowsShareLinkInternal() { 594*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 595*504c13e8SAndreas Gohr $this->P->parse('Foo [[\\\server\share|My Documents]] Bar'); 596*504c13e8SAndreas Gohr $calls = [ 597*504c13e8SAndreas Gohr ['document_start',[]], 598*504c13e8SAndreas Gohr ['p_open',[]], 599*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 600*504c13e8SAndreas Gohr ['windowssharelink',['\\\server\share','My Documents']], 601*504c13e8SAndreas Gohr ['cdata',[' Bar']], 602*504c13e8SAndreas Gohr ['p_close',[]], 603*504c13e8SAndreas Gohr ['document_end',[]], 604*504c13e8SAndreas Gohr ]; 605*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 606*504c13e8SAndreas Gohr } 607*504c13e8SAndreas Gohr 608*504c13e8SAndreas Gohr function testMediaInternal() { 609*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 610*504c13e8SAndreas Gohr $this->P->parse('Foo {{img.gif}} Bar'); 611*504c13e8SAndreas Gohr $calls = [ 612*504c13e8SAndreas Gohr ['document_start',[]], 613*504c13e8SAndreas Gohr ['p_open',[]], 614*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 615*504c13e8SAndreas Gohr ['internalmedia',['img.gif',null,null,null,null,'cache','details']], 616*504c13e8SAndreas Gohr ['cdata',[' Bar']], 617*504c13e8SAndreas Gohr ['p_close',[]], 618*504c13e8SAndreas Gohr ['document_end',[]], 619*504c13e8SAndreas Gohr ]; 620*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 621*504c13e8SAndreas Gohr } 622*504c13e8SAndreas Gohr 623*504c13e8SAndreas Gohr function testMediaInternalLinkOnly() { 624*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 625*504c13e8SAndreas Gohr $this->P->parse('Foo {{img.gif?linkonly}} Bar'); 626*504c13e8SAndreas Gohr $calls = [ 627*504c13e8SAndreas Gohr ['document_start',[]], 628*504c13e8SAndreas Gohr ['p_open',[]], 629*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 630*504c13e8SAndreas Gohr ['internalmedia',['img.gif',null,null,null,null,'cache','linkonly']], 631*504c13e8SAndreas Gohr ['cdata',[' Bar']], 632*504c13e8SAndreas Gohr ['p_close',[]], 633*504c13e8SAndreas Gohr ['document_end',[]], 634*504c13e8SAndreas Gohr ]; 635*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 636*504c13e8SAndreas Gohr } 637*504c13e8SAndreas Gohr 638*504c13e8SAndreas Gohr function testMediaNotImage() { 639*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 640*504c13e8SAndreas Gohr $this->P->parse('Foo {{foo.txt?10x10|Some File}} Bar'); 641*504c13e8SAndreas Gohr $calls = [ 642*504c13e8SAndreas Gohr ['document_start',[]], 643*504c13e8SAndreas Gohr ['p_open',[]], 644*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 645*504c13e8SAndreas Gohr ['internalmedia',['foo.txt','Some File',null,10,10,'cache','details']], 646*504c13e8SAndreas Gohr ['cdata',[' Bar']], 647*504c13e8SAndreas Gohr ['p_close',[]], 648*504c13e8SAndreas Gohr ['document_end',[]], 649*504c13e8SAndreas Gohr ]; 650*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 651*504c13e8SAndreas Gohr } 652*504c13e8SAndreas Gohr 653*504c13e8SAndreas Gohr function testMediaInternalLAlign() { 654*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 655*504c13e8SAndreas Gohr $this->P->parse('Foo {{img.gif }} Bar'); 656*504c13e8SAndreas Gohr $calls = [ 657*504c13e8SAndreas Gohr ['document_start',[]], 658*504c13e8SAndreas Gohr ['p_open',[]], 659*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 660*504c13e8SAndreas Gohr ['internalmedia',['img.gif',null,'left',null,null,'cache','details']], 661*504c13e8SAndreas Gohr ['cdata',[' Bar']], 662*504c13e8SAndreas Gohr ['p_close',[]], 663*504c13e8SAndreas Gohr ['document_end',[]], 664*504c13e8SAndreas Gohr ]; 665*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 666*504c13e8SAndreas Gohr } 667*504c13e8SAndreas Gohr 668*504c13e8SAndreas Gohr function testMediaInternalRAlign() { 669*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 670*504c13e8SAndreas Gohr $this->P->parse('Foo {{ img.gif}} Bar'); 671*504c13e8SAndreas Gohr $calls = [ 672*504c13e8SAndreas Gohr ['document_start',[]], 673*504c13e8SAndreas Gohr ['p_open',[]], 674*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 675*504c13e8SAndreas Gohr ['internalmedia',['img.gif',null,'right',null,null,'cache','details']], 676*504c13e8SAndreas Gohr ['cdata',[' Bar']], 677*504c13e8SAndreas Gohr ['p_close',[]], 678*504c13e8SAndreas Gohr ['document_end',[]], 679*504c13e8SAndreas Gohr ]; 680*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 681*504c13e8SAndreas Gohr } 682*504c13e8SAndreas Gohr 683*504c13e8SAndreas Gohr function testMediaInternalCenter() { 684*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 685*504c13e8SAndreas Gohr $this->P->parse('Foo {{ img.gif }} Bar'); 686*504c13e8SAndreas Gohr $calls = [ 687*504c13e8SAndreas Gohr ['document_start',[]], 688*504c13e8SAndreas Gohr ['p_open',[]], 689*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 690*504c13e8SAndreas Gohr ['internalmedia',['img.gif',null,'center',null,null,'cache','details']], 691*504c13e8SAndreas Gohr ['cdata',[' Bar']], 692*504c13e8SAndreas Gohr ['p_close',[]], 693*504c13e8SAndreas Gohr ['document_end',[]], 694*504c13e8SAndreas Gohr ]; 695*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 696*504c13e8SAndreas Gohr } 697*504c13e8SAndreas Gohr 698*504c13e8SAndreas Gohr function testMediaInternalParams() { 699*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 700*504c13e8SAndreas Gohr $this->P->parse('Foo {{img.gif?50x100nocache}} Bar'); 701*504c13e8SAndreas Gohr $calls = [ 702*504c13e8SAndreas Gohr ['document_start',[]], 703*504c13e8SAndreas Gohr ['p_open',[]], 704*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 705*504c13e8SAndreas Gohr ['internalmedia',['img.gif',null,null,'50','100','nocache','details']], 706*504c13e8SAndreas Gohr ['cdata',[' Bar']], 707*504c13e8SAndreas Gohr ['p_close',[]], 708*504c13e8SAndreas Gohr ['document_end',[]], 709*504c13e8SAndreas Gohr ]; 710*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 711*504c13e8SAndreas Gohr } 712*504c13e8SAndreas Gohr 713*504c13e8SAndreas Gohr function testMediaInternalTitle() { 714*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 715*504c13e8SAndreas Gohr $this->P->parse('Foo {{img.gif?50x100|Some Image}} Bar'); 716*504c13e8SAndreas Gohr $calls = [ 717*504c13e8SAndreas Gohr ['document_start',[]], 718*504c13e8SAndreas Gohr ['p_open',[]], 719*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 720*504c13e8SAndreas Gohr ['internalmedia',['img.gif','Some Image',null,'50','100','cache','details']], 721*504c13e8SAndreas Gohr ['cdata',[' Bar']], 722*504c13e8SAndreas Gohr ['p_close',[]], 723*504c13e8SAndreas Gohr ['document_end',[]], 724*504c13e8SAndreas Gohr ]; 725*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 726*504c13e8SAndreas Gohr } 727*504c13e8SAndreas Gohr 728*504c13e8SAndreas Gohr function testMediaExternal() { 729*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 730*504c13e8SAndreas Gohr $this->P->parse('Foo {{http://www.google.com/img.gif}} Bar'); 731*504c13e8SAndreas Gohr $calls = [ 732*504c13e8SAndreas Gohr ['document_start',[]], 733*504c13e8SAndreas Gohr ['p_open',[]], 734*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 735*504c13e8SAndreas Gohr ['externalmedia',['http://www.google.com/img.gif',null,null,null,null,'cache','details']], 736*504c13e8SAndreas Gohr ['cdata',[' Bar']], 737*504c13e8SAndreas Gohr ['p_close',[]], 738*504c13e8SAndreas Gohr ['document_end',[]], 739*504c13e8SAndreas Gohr ]; 740*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 741*504c13e8SAndreas Gohr } 742*504c13e8SAndreas Gohr 743*504c13e8SAndreas Gohr function testMediaExternalParams() { 744*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 745*504c13e8SAndreas Gohr $this->P->parse('Foo {{http://www.google.com/img.gif?50x100nocache}} Bar'); 746*504c13e8SAndreas Gohr $calls = [ 747*504c13e8SAndreas Gohr ['document_start',[]], 748*504c13e8SAndreas Gohr ['p_open',[]], 749*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 750*504c13e8SAndreas Gohr ['externalmedia',['http://www.google.com/img.gif',null,null,'50','100','nocache','details']], 751*504c13e8SAndreas Gohr ['cdata',[' Bar']], 752*504c13e8SAndreas Gohr ['p_close',[]], 753*504c13e8SAndreas Gohr ['document_end',[]], 754*504c13e8SAndreas Gohr ]; 755*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 756*504c13e8SAndreas Gohr } 757*504c13e8SAndreas Gohr 758*504c13e8SAndreas Gohr function testMediaExternalTitle() { 759*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 760*504c13e8SAndreas Gohr $this->P->parse('Foo {{http://www.google.com/img.gif?50x100|Some Image}} Bar'); 761*504c13e8SAndreas Gohr $calls = [ 762*504c13e8SAndreas Gohr ['document_start',[]], 763*504c13e8SAndreas Gohr ['p_open',[]], 764*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 765*504c13e8SAndreas Gohr ['externalmedia', 766*504c13e8SAndreas Gohr ['http://www.google.com/img.gif','Some Image',null,'50','100','cache','details']], 767*504c13e8SAndreas Gohr ['cdata',[' Bar']], 768*504c13e8SAndreas Gohr ['p_close',[]], 769*504c13e8SAndreas Gohr ['document_end',[]], 770*504c13e8SAndreas Gohr ]; 771*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 772*504c13e8SAndreas Gohr } 773*504c13e8SAndreas Gohr 774*504c13e8SAndreas Gohr function testMediaInInternalLink() { 775*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 776*504c13e8SAndreas Gohr $this->P->parse("Foo [[x:1:y:foo_bar:z|{{img.gif?10x20nocache|Some Image}}]] Bar"); 777*504c13e8SAndreas Gohr 778*504c13e8SAndreas Gohr $image = [ 779*504c13e8SAndreas Gohr 'type'=>'internalmedia', 780*504c13e8SAndreas Gohr 'src'=>'img.gif', 781*504c13e8SAndreas Gohr 'title'=>'Some Image', 782*504c13e8SAndreas Gohr 'align'=>null, 783*504c13e8SAndreas Gohr 'width'=>10, 784*504c13e8SAndreas Gohr 'height'=>20, 785*504c13e8SAndreas Gohr 'cache'=>'nocache', 786*504c13e8SAndreas Gohr 'linking'=>'details', 787*504c13e8SAndreas Gohr ]; 788*504c13e8SAndreas Gohr 789*504c13e8SAndreas Gohr $calls = [ 790*504c13e8SAndreas Gohr ['document_start',[]], 791*504c13e8SAndreas Gohr ['p_open',[]], 792*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 793*504c13e8SAndreas Gohr ['internallink',['x:1:y:foo_bar:z',$image]], 794*504c13e8SAndreas Gohr ['cdata',[' Bar']], 795*504c13e8SAndreas Gohr ['p_close',[]], 796*504c13e8SAndreas Gohr ['document_end',[]], 797*504c13e8SAndreas Gohr ]; 798*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 799*504c13e8SAndreas Gohr } 800*504c13e8SAndreas Gohr 801*504c13e8SAndreas Gohr function testMediaNoImageInInternalLink() { 802*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 803*504c13e8SAndreas Gohr $this->P->parse("Foo [[x:1:y:foo_bar:z|{{foo.txt?10x20nocache|Some Image}}]] Bar"); 804*504c13e8SAndreas Gohr 805*504c13e8SAndreas Gohr $image = [ 806*504c13e8SAndreas Gohr 'type'=>'internalmedia', 807*504c13e8SAndreas Gohr 'src'=>'foo.txt', 808*504c13e8SAndreas Gohr 'title'=>'Some Image', 809*504c13e8SAndreas Gohr 'align'=>null, 810*504c13e8SAndreas Gohr 'width'=>10, 811*504c13e8SAndreas Gohr 'height'=>20, 812*504c13e8SAndreas Gohr 'cache'=>'nocache', 813*504c13e8SAndreas Gohr 'linking'=>'details', 814*504c13e8SAndreas Gohr ]; 815*504c13e8SAndreas Gohr 816*504c13e8SAndreas Gohr $calls = [ 817*504c13e8SAndreas Gohr ['document_start',[]], 818*504c13e8SAndreas Gohr ['p_open',[]], 819*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 820*504c13e8SAndreas Gohr ['internallink',['x:1:y:foo_bar:z',$image]], 821*504c13e8SAndreas Gohr ['cdata',[' Bar']], 822*504c13e8SAndreas Gohr ['p_close',[]], 823*504c13e8SAndreas Gohr ['document_end',[]], 824*504c13e8SAndreas Gohr ]; 825*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 826*504c13e8SAndreas Gohr } 827*504c13e8SAndreas Gohr 828*504c13e8SAndreas Gohr function testMediaInEmailLink() { 829*504c13e8SAndreas Gohr $this->P->addMode('internallink',new Internallink()); 830*504c13e8SAndreas Gohr $this->P->parse("Foo [[foo@example.com|{{img.gif?10x20nocache|Some Image}}]] Bar"); 831*504c13e8SAndreas Gohr 832*504c13e8SAndreas Gohr $image = [ 833*504c13e8SAndreas Gohr 'type'=>'internalmedia', 834*504c13e8SAndreas Gohr 'src'=>'img.gif', 835*504c13e8SAndreas Gohr 'title'=>'Some Image', 836*504c13e8SAndreas Gohr 'align'=>null, 837*504c13e8SAndreas Gohr 'width'=>10, 838*504c13e8SAndreas Gohr 'height'=>20, 839*504c13e8SAndreas Gohr 'cache'=>'nocache', 840*504c13e8SAndreas Gohr 'linking'=>'details', 841*504c13e8SAndreas Gohr ]; 842*504c13e8SAndreas Gohr 843*504c13e8SAndreas Gohr $calls = [ 844*504c13e8SAndreas Gohr ['document_start',[]], 845*504c13e8SAndreas Gohr ['p_open',[]], 846*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 847*504c13e8SAndreas Gohr ['emaillink',['foo@example.com',$image]], 848*504c13e8SAndreas Gohr ['cdata',[' Bar']], 849*504c13e8SAndreas Gohr ['p_close',[]], 850*504c13e8SAndreas Gohr ['document_end',[]], 851*504c13e8SAndreas Gohr ]; 852*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 853*504c13e8SAndreas Gohr } 854*504c13e8SAndreas Gohr 855*504c13e8SAndreas Gohr function testNestedMedia() { 856*504c13e8SAndreas Gohr $this->P->addMode('media',new Media()); 857*504c13e8SAndreas Gohr $this->P->parse('Foo {{img.gif|{{foo.gif|{{bar.gif|Bar}}}}}} Bar'); 858*504c13e8SAndreas Gohr $calls = [ 859*504c13e8SAndreas Gohr ['document_start',[]], 860*504c13e8SAndreas Gohr ['p_open',[]], 861*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 862*504c13e8SAndreas Gohr ['internalmedia', 863*504c13e8SAndreas Gohr ['img.gif','{{foo.gif|{{bar.gif|Bar',null,null,null,'cache','details']], 864*504c13e8SAndreas Gohr ['cdata',['}}}} Bar']], 865*504c13e8SAndreas Gohr ['p_close',[]], 866*504c13e8SAndreas Gohr ['document_end',[]], 867*504c13e8SAndreas Gohr ]; 868*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 869*504c13e8SAndreas Gohr } 870*504c13e8SAndreas Gohr 871*504c13e8SAndreas Gohr} 872