1f2bbf30bSGuy Brand<?php 2f2bbf30bSGuy Brandrequire_once 'parser.inc.php'; 3f2bbf30bSGuy Brand 4f2bbf30bSGuy Brandclass TestOfDoku_Parser_Code extends TestOfDoku_Parser { 5f2bbf30bSGuy Brand 6f2bbf30bSGuy Brand function setUp() { 7f2bbf30bSGuy Brand parent::setUp(); 8f2bbf30bSGuy Brand $this->P->addMode('code',new Doku_Parser_Mode_Code()); 9f2bbf30bSGuy Brand } 10f2bbf30bSGuy Brand 11f2bbf30bSGuy Brand function testCode() { 12f2bbf30bSGuy Brand $this->P->parse('Foo <code>Test</code> 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('code',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 27f2bbf30bSGuy Brand function testCodeBash() { 28f2bbf30bSGuy Brand $this->P->parse('Foo <code bash>Test</code> Bar'); 29f2bbf30bSGuy Brand $calls = array ( 30f2bbf30bSGuy Brand array('document_start',array()), 31f2bbf30bSGuy Brand array('p_open',array()), 32f2bbf30bSGuy Brand array('cdata',array("\n".'Foo ')), 33f2bbf30bSGuy Brand array('p_close',array()), 34f2bbf30bSGuy Brand array('code',array('Test','bash',null)), 35f2bbf30bSGuy Brand array('p_open',array()), 36f2bbf30bSGuy Brand array('cdata',array(' Bar')), 37f2bbf30bSGuy Brand array('p_close',array()), 38f2bbf30bSGuy Brand array('document_end',array()), 39f2bbf30bSGuy Brand ); 40f2bbf30bSGuy Brand $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); 41f2bbf30bSGuy Brand } 42f2bbf30bSGuy Brand 43*fdd9bab6SChristopher Smith function testCodeDownload() { 44*fdd9bab6SChristopher Smith $this->P->parse('Foo <code bash script.sh>Test</code> 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 ')), 49*fdd9bab6SChristopher Smith array('p_close',array()), 50*fdd9bab6SChristopher Smith array('code',array('Test','bash','script.sh')), 51*fdd9bab6SChristopher Smith array('p_open',array()), 52*fdd9bab6SChristopher Smith array('cdata',array(' Bar')), 53*fdd9bab6SChristopher Smith array('p_close',array()), 54*fdd9bab6SChristopher Smith array('document_end',array()), 55*fdd9bab6SChristopher Smith ); 56*fdd9bab6SChristopher Smith $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); 57*fdd9bab6SChristopher Smith } 58*fdd9bab6SChristopher Smith 59f2bbf30bSGuy Brand function testCodeToken() { 60f2bbf30bSGuy Brand $this->P->parse('Foo <code2>Bar</code2><code>Test</code>'); 61f2bbf30bSGuy Brand $calls = array ( 62f2bbf30bSGuy Brand array('document_start',array()), 63f2bbf30bSGuy Brand array('p_open',array()), 64f2bbf30bSGuy Brand array('cdata',array("\n".'Foo <code2>Bar</code2>')), 65f2bbf30bSGuy Brand array('p_close',array()), 66f2bbf30bSGuy Brand array('code',array('Test',null,null)), 67f2bbf30bSGuy Brand array('document_end',array()), 68f2bbf30bSGuy Brand ); 69f2bbf30bSGuy Brand $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); 70f2bbf30bSGuy Brand } 71f2bbf30bSGuy Brand} 72f2bbf30bSGuy Brand 73