summaryrefslogtreecommitdiff
path: root/inc/parser/tests/parser_unformatted.test.php
blob: e9c1fce706629b2c96a6b371e3513a50be78655a (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
<?php
require_once 'parser.test.php';

class TestOfDoku_Parser_Unformatted extends TestOfDoku_Parser {
    
    function TestOfDoku_Parser_Unformatted() {
        $this->UnitTestCase('TestOfDoku_Parser_Unformatted');
    }
    
    function testNowiki() {
        $this->P->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
        $this->P->parse("Foo <nowiki>testing</nowiki> Bar");
        $calls = array (
            array('document_start',array()),
            array('p_open',array()),
            array('cdata',array("\n".'Foo ')),
            array('unformatted',array('testing')),
            array('cdata',array(' Bar'."\n")),
            array('p_close',array()),
            array('document_end',array()),
        );
        $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
        
    }
    
    function testDoublePercent() {
        $this->P->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
        $this->P->parse("Foo %%testing%% Bar");
        $calls = array (
            array('document_start',array()),
            array('p_open',array()),
            array('cdata',array("\n".'Foo ')),
            array('unformatted',array('testing')),
            array('cdata',array(' Bar'."\n")),
            array('p_close',array()),
            array('document_end',array()),
        );
        $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
    }
}

/**
* Conditional test runner
*/
if (!defined('TEST_RUNNING')) {
    define('TEST_RUNNING', true);
    $test = &new TestOfDoku_Parser_Unformatted();
    $test->run(new HtmlReporter());
}