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