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