summaryrefslogtreecommitdiff
path: root/_test/tests/inc/parser/parser_file.test.php
blob: 39bda8a5828b08de844cda45f8c4cde359a0f674 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require_once 'parser.inc.php';

class TestOfDoku_Parser_File extends TestOfDoku_Parser {

    function setUp() {
        parent::setUp();
        $this->P->addMode('file',new Doku_Parser_Mode_File());
    }

    function testFile() {
        $this->P->parse('Foo <file>Test</file> Bar');
        $calls = array (
            array('document_start',array()),
            array('p_open',array()),
            array('cdata',array("\n".'Foo ')),
            array('p_close',array()),
            array('file',array('Test',null,null)),
            array('p_open',array()),
            array('cdata',array(' Bar')),
            array('p_close',array()),
            array('document_end',array()),
        );
        $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
    }

    function testFileHighlightDownload() {
        $this->P->parse('Foo <file txt test.txt>Test</file> Bar');
        $calls = array (
            array('document_start',array()),
            array('p_open',array()),
            array('cdata',array("\n".'Foo ')),
            array('p_close',array()),
            array('file',array('Test','txt','test.txt')),
            array('p_open',array()),
            array('cdata',array(' Bar')),
            array('p_close',array()),
            array('document_end',array()),
        );
        $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
    }

    function testFileToken() {
        $this->P->parse('Foo <file2>Test</file2> Bar');
        $calls = array (
            array('document_start',array()),
            array('p_open',array()),
            array('cdata',array("\n".'Foo <file2>Test</file2> Bar')),
            array('p_close',array()),
            array('document_end',array()),
        );
        $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
    }

}