xref: /dokuwiki/_test/tests/inc/parser/parser_file.test.php (revision e32b1b0ffe5e0c48ff8faed9c74099599659774c)
1f2bbf30bSGuy Brand<?php
236dc94bbSAndreas Gohr
3be906b56SAndreas Gohruse dokuwiki\Parsing\ParserMode\File;
436dc94bbSAndreas Gohr
5f2bbf30bSGuy Brandrequire_once 'parser.inc.php';
6f2bbf30bSGuy Brand
7f2bbf30bSGuy Brandclass TestOfDoku_Parser_File extends TestOfDoku_Parser {
8f2bbf30bSGuy Brand
9*1c33cec3SAndreas Gohr    function setUp() : void {
10f2bbf30bSGuy Brand        parent::setUp();
1136dc94bbSAndreas Gohr        $this->P->addMode('file',new File());
12f2bbf30bSGuy Brand    }
13f2bbf30bSGuy Brand
14f2bbf30bSGuy Brand    function testFile() {
15f2bbf30bSGuy Brand        $this->P->parse('Foo <file>Test</file> Bar');
16f2bbf30bSGuy Brand        $calls = array (
17f2bbf30bSGuy Brand            array('document_start',array()),
18f2bbf30bSGuy Brand            array('p_open',array()),
19f2bbf30bSGuy Brand            array('cdata',array("\n".'Foo ')),
20f2bbf30bSGuy Brand            array('p_close',array()),
21f2bbf30bSGuy Brand            array('file',array('Test',null,null)),
22f2bbf30bSGuy Brand            array('p_open',array()),
23f2bbf30bSGuy Brand            array('cdata',array(' Bar')),
24f2bbf30bSGuy Brand            array('p_close',array()),
25f2bbf30bSGuy Brand            array('document_end',array()),
26f2bbf30bSGuy Brand        );
27f2bbf30bSGuy Brand        $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
28f2bbf30bSGuy Brand    }
29f2bbf30bSGuy Brand
30fdd9bab6SChristopher Smith    function testFileHighlightDownload() {
31fdd9bab6SChristopher Smith        $this->P->parse('Foo <file txt test.txt>Test</file> Bar');
32fdd9bab6SChristopher Smith        $calls = array (
33fdd9bab6SChristopher Smith            array('document_start',array()),
34fdd9bab6SChristopher Smith            array('p_open',array()),
35fdd9bab6SChristopher Smith            array('cdata',array("\n".'Foo ')),
36fdd9bab6SChristopher Smith            array('p_close',array()),
37fdd9bab6SChristopher Smith            array('file',array('Test','txt','test.txt')),
38fdd9bab6SChristopher Smith            array('p_open',array()),
39fdd9bab6SChristopher Smith            array('cdata',array(' Bar')),
40fdd9bab6SChristopher Smith            array('p_close',array()),
41fdd9bab6SChristopher Smith            array('document_end',array()),
42fdd9bab6SChristopher Smith        );
43fdd9bab6SChristopher Smith        $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
44fdd9bab6SChristopher Smith    }
45fdd9bab6SChristopher Smith
46fdd9bab6SChristopher Smith    function testFileToken() {
47fdd9bab6SChristopher Smith        $this->P->parse('Foo <file2>Test</file2> Bar');
48fdd9bab6SChristopher Smith        $calls = array (
49fdd9bab6SChristopher Smith            array('document_start',array()),
50fdd9bab6SChristopher Smith            array('p_open',array()),
51fdd9bab6SChristopher Smith            array('cdata',array("\n".'Foo <file2>Test</file2> Bar')),
52fdd9bab6SChristopher Smith            array('p_close',array()),
53fdd9bab6SChristopher Smith            array('document_end',array()),
54fdd9bab6SChristopher Smith        );
55fdd9bab6SChristopher Smith        $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
56fdd9bab6SChristopher Smith    }
57fdd9bab6SChristopher Smith
58f2bbf30bSGuy Brand}
59