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