1<?php 2 3class parserutils_get_renderer_test extends DokuWikiTest { 4 5 private $plugin_controller; 6 7 // test default behaviour / usual settings 8 function test_p_get_renderer_normal() { 9 global $conf; 10 11 $old_conf = $conf; 12 $conf['renderer_xhtml'] = 'xhtml'; 13 14 $this->assertInstanceOf('Doku_Renderer_xhtml', p_get_renderer('xhtml')); 15 16 $conf = $old_conf; 17 } 18 19 // test get a renderer plugin 20 function test_p_get_renderer_plugin() { 21 global $conf; 22 global $plugin_controller; 23 24 $old_conf = $conf; 25 $conf['renderer_xhtml'] = 'get_renderer_test'; 26 $this->plugin_controller = $plugin_controller; 27 $plugin_controller = $this; 28 29 $this->assertInstanceOf('renderer_plugin_test', p_get_renderer('xhtml')); 30 31 $conf = $old_conf; 32 $plugin_controller = $this->plugin_controller; 33 } 34 35 // test fallback succeeds 36 function test_p_get_renderer_fallback() { 37 global $conf; 38 39 $old_conf = $conf; 40 $conf['renderer_xhtml'] = 'badvalue'; 41 42 $this->assertInstanceOf('Doku_Renderer_xhtml', p_get_renderer('xhtml')); 43 44 $conf = $old_conf; 45 } 46 47 // test fallback fails 48 /** 49 * @expectedException PHPUnit_Framework_Error 50 * @expectedExceptionCode E_USER_WARNING 51 */ 52 function test_p_get_renderer_fallback_fail() { 53 global $conf; 54 55 $old_conf = $conf; 56 $conf['renderer_junk'] = 'badvalue'; 57 58 $this->assertNull(p_get_renderer('junk')); 59 60 $conf = $old_conf; 61 } 62 63 // wrapper function for the fake plugin controller, return $this for the fake syntax of this test 64 function load($type,$name,$new=false,$disabled=false){ 65 if ($name == 'get_renderer_test') { 66 return new renderer_plugin_test(); 67 } else { 68 return $this->plugin_controller->load($type, $name, $new, $disabled); 69 } 70 } 71 } 72 73require_once DOKU_INC . 'inc/parser/xhtml.php'; 74 75class renderer_plugin_test extends Doku_Renderer_xhtml { 76 77 function canRender($format) { 78 return ($format=='xhtml'); 79 } 80 81} 82 83// vim:ts=4:sw=4:et: 84