xref: /dokuwiki/_test/tests/Parsing/ParserMode/FileTest.php (revision 504c13e8df88563c11b3720b317991bc38835a35)
1*504c13e8SAndreas Gohr<?php
2*504c13e8SAndreas Gohr
3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\ParserMode;
4*504c13e8SAndreas Gohr
5*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\File;
6*504c13e8SAndreas Gohr
7*504c13e8SAndreas Gohrclass FileTest extends ParserTestBase
8*504c13e8SAndreas Gohr{
9*504c13e8SAndreas Gohr
10*504c13e8SAndreas Gohr    function setUp() : void {
11*504c13e8SAndreas Gohr        parent::setUp();
12*504c13e8SAndreas Gohr        $this->P->addMode('file',new File());
13*504c13e8SAndreas Gohr    }
14*504c13e8SAndreas Gohr
15*504c13e8SAndreas Gohr    function testFile() {
16*504c13e8SAndreas Gohr        $this->P->parse('Foo <file>Test</file> Bar');
17*504c13e8SAndreas Gohr        $calls = [
18*504c13e8SAndreas Gohr            ['document_start',[]],
19*504c13e8SAndreas Gohr            ['p_open',[]],
20*504c13e8SAndreas Gohr            ['cdata',["\n".'Foo ']],
21*504c13e8SAndreas Gohr            ['p_close',[]],
22*504c13e8SAndreas Gohr            ['file',['Test',null,null]],
23*504c13e8SAndreas Gohr            ['p_open',[]],
24*504c13e8SAndreas Gohr            ['cdata',[' Bar']],
25*504c13e8SAndreas Gohr            ['p_close',[]],
26*504c13e8SAndreas Gohr            ['document_end',[]],
27*504c13e8SAndreas Gohr        ];
28*504c13e8SAndreas Gohr        $this->assertCalls($calls, $this->H->calls);
29*504c13e8SAndreas Gohr    }
30*504c13e8SAndreas Gohr
31*504c13e8SAndreas Gohr    function testFileHighlightDownload() {
32*504c13e8SAndreas Gohr        $this->P->parse('Foo <file txt test.txt>Test</file> Bar');
33*504c13e8SAndreas Gohr        $calls = [
34*504c13e8SAndreas Gohr            ['document_start',[]],
35*504c13e8SAndreas Gohr            ['p_open',[]],
36*504c13e8SAndreas Gohr            ['cdata',["\n".'Foo ']],
37*504c13e8SAndreas Gohr            ['p_close',[]],
38*504c13e8SAndreas Gohr            ['file',['Test','txt','test.txt']],
39*504c13e8SAndreas Gohr            ['p_open',[]],
40*504c13e8SAndreas Gohr            ['cdata',[' Bar']],
41*504c13e8SAndreas Gohr            ['p_close',[]],
42*504c13e8SAndreas Gohr            ['document_end',[]],
43*504c13e8SAndreas Gohr        ];
44*504c13e8SAndreas Gohr        $this->assertCalls($calls, $this->H->calls);
45*504c13e8SAndreas Gohr    }
46*504c13e8SAndreas Gohr
47*504c13e8SAndreas Gohr    function testFileToken() {
48*504c13e8SAndreas Gohr        $this->P->parse('Foo <file2>Test</file2> Bar');
49*504c13e8SAndreas Gohr        $calls = [
50*504c13e8SAndreas Gohr            ['document_start',[]],
51*504c13e8SAndreas Gohr            ['p_open',[]],
52*504c13e8SAndreas Gohr            ['cdata',["\n".'Foo <file2>Test</file2> Bar']],
53*504c13e8SAndreas Gohr            ['p_close',[]],
54*504c13e8SAndreas Gohr            ['document_end',[]],
55*504c13e8SAndreas Gohr        ];
56*504c13e8SAndreas Gohr        $this->assertCalls($calls, $this->H->calls);
57*504c13e8SAndreas Gohr    }
58*504c13e8SAndreas Gohr
59*504c13e8SAndreas Gohr}
60