1<?php 2 3namespace dokuwiki\test\Parsing\ParserMode; 4 5use dokuwiki\Parsing\ParserMode\Internallink; 6use dokuwiki\Parsing\ParserMode\Windowssharelink; 7 8/** 9 * Tests for the {@see Windowssharelink} parser mode: `\\server\share` UNC paths, 10 * both as bare text and as the target of an internal `[[ ]]` link. 11 * 12 * @group parser_links 13 */ 14class WindowssharelinkTest extends ParserTestBase 15{ 16 function testBare() { 17 $this->P->addMode('windowssharelink', new Windowssharelink()); 18 $this->P->parse('Foo \\\server\share Bar'); 19 $calls = [ 20 ['document_start', []], 21 ['p_open', []], 22 ['cdata', ["\n" . 'Foo ']], 23 ['windowssharelink', ['\\\server\share', null]], 24 ['cdata', [' Bar']], 25 ['p_close', []], 26 ['document_end', []], 27 ]; 28 $this->assertCalls($calls, $this->H->calls); 29 } 30 31 function testBareWithHyphen() { 32 $this->P->addMode('windowssharelink', new Windowssharelink()); 33 $this->P->parse('Foo \\\server\share-hyphen Bar'); 34 $calls = [ 35 ['document_start', []], 36 ['p_open', []], 37 ['cdata', ["\n" . 'Foo ']], 38 ['windowssharelink', ['\\\server\share-hyphen', null]], 39 ['cdata', [' Bar']], 40 ['p_close', []], 41 ['document_end', []], 42 ]; 43 $this->assertCalls($calls, $this->H->calls); 44 } 45 46 function testInsideInternalLink() { 47 $this->P->addMode('internallink', new Internallink()); 48 $this->P->parse('Foo [[\\\server\share|My Documents]] Bar'); 49 $calls = [ 50 ['document_start', []], 51 ['p_open', []], 52 ['cdata', ["\n" . 'Foo ']], 53 ['windowssharelink', ['\\\server\share', 'My Documents']], 54 ['cdata', [' Bar']], 55 ['p_close', []], 56 ['document_end', []], 57 ]; 58 $this->assertCalls($calls, $this->H->calls); 59 } 60} 61