[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 use dokuwiki\Parsing\Handler\Lists; 4 5 /** 6 * Class renderer_xhtml_test 7 */ 8 class renderer_xhtml_test extends DokuWikiTest { 9 /** @var Doku_Renderer_xhtml */ 10 protected $R; 11 12 /** 13 * Called for each test 14 * 15 * @throws Exception 16 */ 17 function setUp() : void { 18 parent::setUp(); 19 $this->R = new Doku_Renderer_xhtml(); 20 } 21 22 function tearDown() : void { 23 unset($this->R); 24 } 25 26 function test_tableopen_0arg() { 27 $this->R->table_open(); 28 29 $expected = '<div class="table"><table class="inline">'."\n"; 30 $this->assertEquals($expected, $this->R->doc); 31 } 32 33 function test_tableopen_1arg() { 34 $this->R->table_open(4); 35 36 $expected = '<div class="table"><table class="inline">'."\n"; 37 $this->assertEquals($expected, $this->R->doc); 38 } 39 40 function test_tableopen_2arg() { 41 $this->R->table_open(4, 4); 42 43 $expected = '<div class="table"><table class="inline">'."\n"; 44 $this->assertEquals($expected, $this->R->doc); 45 } 46 47 function test_tableopen_3arg() { 48 $this->R->table_open(4, 4, 100); 49 50 $expected = '<div class="table sectionedit1"><table class="inline">'."\n"; 51 $this->assertEquals($expected, $this->R->doc); 52 } 53 54 function test_tableopen_4arg_str() { 55 $this->R->table_open(4, 4, 100, 'feature'); 56 57 $expected = '<div class="table feature sectionedit1"><table class="inline">'."\n"; 58 $this->assertEquals($expected, $this->R->doc); 59 } 60 61 function test_tableopen_4arg_arr() { 62 $this->R->table_open(4, 4, 100, array('feature', 'test')); 63 64 $expected = '<div class="table feature test sectionedit1"><table class="inline">'."\n"; 65 $this->assertEquals($expected, $this->R->doc); 66 } 67 68 function test_table() { 69 $this->R->table_open(null, null, null, 'feature'); 70 $this->R->tablethead_open(); 71 72 $this->R->tablerow_open('item'); 73 $this->R->tableheader_open(); 74 $this->R->cdata('header1'); 75 $this->R->tableheader_close(); 76 $this->R->tableheader_open(1, null, 1, 'second'); 77 $this->R->cdata('header2'); 78 $this->R->tableheader_close(); 79 $this->R->tablerow_close(); 80 81 $this->R->tablethead_close(); 82 $this->R->tabletbody_open(); 83 84 $this->R->tablerow_open('values'); 85 $this->R->tablecell_open(1, null, 1, 'first value'); 86 $this->R->cdata('cell1,1'); 87 $this->R->tablecell_close(); 88 $this->R->tablecell_open(1, null, 1, 'second'); 89 $this->R->cdata('cell1,2'); 90 $this->R->tablecell_close(); 91 $this->R->tablerow_close(); 92 93 $this->R->tablerow_open(); 94 $this->R->tablecell_open(); 95 $this->R->cdata('cell2.1'); 96 $this->R->tablecell_close(); 97 $this->R->tablecell_open(); 98 $this->R->cdata('cell2,2'); 99 $this->R->tablecell_close(); 100 $this->R->tablerow_close(); 101 102 $this->R->tabletbody_close(); 103 $this->R->table_close(); 104 105 $expected = '<div class="table feature"><table class="inline"> 106 <thead> 107 <tr class="row0 item"> 108 <th class="col0">header1</th><th class="col1 second">header2</th> 109 </tr> 110 </thead> 111 <tbody> 112 <tr class="row1 values"> 113 <td class="col0 first value">cell1,1</td><td class="col1 second">cell1,2</td> 114 </tr> 115 <tr class="row2"> 116 <td class="col0">cell2.1</td><td class="col1">cell2,2</td> 117 </tr> 118 </tbody> 119 </table></div> 120 '; 121 $this->assertEquals($expected, $this->R->doc); 122 } 123 124 function test_olist() { 125 $this->R->document_start(); 126 $this->R->listo_open(); 127 128 $this->R->listitem_open(1, Lists::NODE); 129 $this->R->listcontent_open(); 130 $this->R->cdata('item1'); 131 $this->R->listcontent_close(); 132 133 $this->R->listo_open(); 134 135 $this->R->listitem_open(2); 136 $this->R->listcontent_open(); 137 $this->R->cdata('item1b'); 138 $this->R->listcontent_close(); 139 $this->R->listitem_close(); 140 141 $this->R->listo_close(); 142 $this->R->listitem_close(); 143 144 $this->R->listitem_open(1); 145 $this->R->listcontent_open(); 146 $this->R->cdata('item2'); 147 $this->R->listcontent_close(); 148 $this->R->listitem_close(); 149 150 $this->R->listitem_open(1, Lists::NODE); 151 $this->R->listcontent_open(); 152 $this->R->cdata('item3'); 153 $this->R->listcontent_close(); 154 155 $this->R->listo_open('special'); 156 157 $this->R->listitem_open(2); 158 $this->R->listcontent_open(); 159 $this->R->cdata('item3b'); 160 $this->R->listcontent_close(); 161 $this->R->listitem_close(); 162 163 $this->R->listo_close(); 164 $this->R->listitem_close(); 165 166 $this->R->listo_close(); 167 $this->R->document_end(); 168 169 $expected = '<ol> 170 <li class="level1 node"><div class="li">item1</div> 171 <ol> 172 <li class="level2"><div class="li">item1b</div> 173 </li> 174 </ol> 175 </li> 176 <li class="level1"><div class="li">item2</div> 177 </li> 178 <li class="level1 node"><div class="li">item3</div> 179 <ol class="special"> 180 <li class="level2"><div class="li">item3b</div> 181 </li> 182 </ol> 183 </li> 184 </ol> 185 '; 186 $this->assertEquals($expected, $this->R->doc); 187 } 188 189 function test_ulist() { 190 $this->R->document_start(); 191 $this->R->listu_open(); 192 193 $this->R->listitem_open(1, Lists::NODE); 194 $this->R->listcontent_open(); 195 $this->R->cdata('item1'); 196 $this->R->listcontent_close(); 197 198 $this->R->listu_open(); 199 200 $this->R->listitem_open(2); 201 $this->R->listcontent_open(); 202 $this->R->cdata('item1b'); 203 $this->R->listcontent_close(); 204 $this->R->listitem_close(); 205 206 $this->R->listu_close(); 207 $this->R->listitem_close(); 208 209 $this->R->listitem_open(1); 210 $this->R->listcontent_open(); 211 $this->R->cdata('item2'); 212 $this->R->listcontent_close(); 213 $this->R->listitem_close(); 214 215 $this->R->listitem_open(1, Lists::NODE); 216 $this->R->listcontent_open(); 217 $this->R->cdata('item3'); 218 $this->R->listcontent_close(); 219 220 $this->R->listu_open('special'); 221 222 $this->R->listitem_open(2); 223 $this->R->listcontent_open(); 224 $this->R->cdata('item3b'); 225 $this->R->listcontent_close(); 226 $this->R->listitem_close(); 227 228 $this->R->listu_close(); 229 $this->R->listitem_close(); 230 231 $this->R->listu_close(); 232 $this->R->document_end(); 233 234 $expected = '<ul> 235 <li class="level1 node"><div class="li">item1</div> 236 <ul> 237 <li class="level2"><div class="li">item1b</div> 238 </li> 239 </ul> 240 </li> 241 <li class="level1"><div class="li">item2</div> 242 </li> 243 <li class="level1 node"><div class="li">item3</div> 244 <ul class="special"> 245 <li class="level2"><div class="li">item3b</div> 246 </li> 247 </ul> 248 </li> 249 </ul> 250 '; 251 $this->assertEquals($expected, $this->R->doc); 252 } 253 254 public function test_blankHeader() { 255 $this->R->header('0', 1, 1); 256 $expected = '<h1 class="sectionedit1" id="section0">0</h1>'; 257 $this->assertEquals($expected, trim($this->R->doc)); 258 } 259 260 public function test_blankTitleLink() { 261 global $conf; 262 $id = 'blanktest'; 263 264 $conf['useheading'] = 1; 265 saveWikiText($id,'====== 0 ======', 'test'); 266 $this->assertTrue(page_exists($id)); 267 268 $header = p_get_first_heading($id, METADATA_RENDER_UNLIMITED); 269 $this->assertSame('0', $header); 270 271 $this->R->internallink($id); 272 $expected = '<a href="/./doku.php?id='.$id.'" class="wikilink1" title="'.$id.'" data-wiki-id="blanktest">0</a>'; 273 $this->assertEquals($expected, trim($this->R->doc)); 274 } 275 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body