blob: 0f373227de9934855cba3c78a3de204793fe376c (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
class parserutils_get_renderer_test extends DokuWikiTest {
private $plugin_controller;
// test default behaviour / usual settings
function test_p_get_renderer_normal() {
global $conf;
$old_conf = $conf;
$conf['renderer_xhtml'] = 'xhtml';
$this->assertInstanceOf('Doku_Renderer_xhtml', p_get_renderer('xhtml'));
$conf = $old_conf;
}
// test get a renderer plugin
function test_p_get_renderer_plugin() {
global $conf;
global $plugin_controller;
$old_conf = $conf;
$conf['renderer_xhtml'] = 'get_renderer_test';
$this->plugin_controller = $plugin_controller;
$plugin_controller = $this;
$this->assertInstanceOf('renderer_plugin_test', p_get_renderer('xhtml'));
$conf = $old_conf;
$plugin_controller = $this->plugin_controller;
}
// test fallback succeeds
function test_p_get_renderer_fallback() {
global $conf;
$old_conf = $conf;
$conf['renderer_xhtml'] = 'badvalue';
$this->assertInstanceOf('Doku_Renderer_xhtml', p_get_renderer('xhtml'));
$conf = $old_conf;
}
// test fallback fails
function test_p_get_renderer_fallback_fail() {
global $conf;
$old_conf = $conf;
$conf['renderer_junk'] = 'badvalue';
$this->assertNull(p_get_renderer('junk'));
$conf = $old_conf;
}
// wrapper function for the fake plugin controller, return $this for the fake syntax of this test
function load($type,$name,$new=false,$disabled=false){
if ($name == 'get_renderer_test') {
return new renderer_plugin_test();
} else {
return $this->plugin_controller->load($type, $name, $new, $disabled);
}
}
}
require_once DOKU_INC . 'inc/parser/xhtml.php';
class renderer_plugin_test extends Doku_Renderer_xhtml {
function canRender($format) {
return ($format=='xhtml');
}
}
// vim:ts=4:sw=4:et:
|