1<?php 2 3namespace dokuwiki\plugin\wrap\test; 4 5use DokuWikiTest; 6 7/** 8 * Tests to ensure wrap syntax is correctly processed 9 * 10 * @group plugin_wrap 11 * @group plugins 12 */ 13class SyntaxTest extends DokuWikiTest { 14 15 protected $pluginsEnabled = ['wrap']; 16 17 public function testNestedHeading() { 18 $instructions = p_get_instructions("<WRAP>\n==== Heading ====\n\nSome text\n</WRAP>"); 19 $expected = 20 [ 21 [ 22 'document_start', 23 [], 24 0 25 ], 26 [ 27 'plugin', 28 [ 29 'wrap_divwrap', 30 [ 31 DOKU_LEXER_ENTER, 32 '<wrap' 33 ], 34 DOKU_LEXER_ENTER, 35 '<WRAP>' 36 ], 37 1 38 ], 39 [ 40 'header', 41 [ 42 'Heading', 43 3, 44 8 45 ], 46 8 47 ], 48 [ 49 'plugin', 50 [ 51 'wrap_closesection', 52 [], 53 DOKU_LEXER_SPECIAL, 54 false 55 ], 56 8 57 ], 58 [ 59 'p_open', 60 [], 61 8 62 ], 63 [ 64 'cdata', 65 [ 66 'Some text' 67 ], 68 27 69 ], 70 [ 71 'p_close', 72 [], 73 37 74 ], 75 [ 76 'plugin', 77 [ 78 'wrap_divwrap', 79 [ 80 DOKU_LEXER_EXIT, 81 '' 82 ], 83 DOKU_LEXER_EXIT, 84 '</WRAP>' 85 ], 86 37 87 ], 88 [ 89 'document_end', 90 [], 91 37 92 ] 93 ]; 94 $this->assertEquals($expected, $instructions); 95 } 96 97 public function testBlockNesting() { 98 $instructions = p_get_instructions("<WRAP>\nFoo\n\n</div> </block> Bar\n</WRAP>"); 99 $expected = 100 [ 101 [ 102 'document_start', 103 [], 104 0 105 ], 106 [ 107 'plugin', 108 [ 109 'wrap_divwrap', 110 [ 111 DOKU_LEXER_ENTER, 112 '<wrap' 113 ], 114 DOKU_LEXER_ENTER, 115 '<WRAP>' 116 ], 117 1 118 ], 119 [ 120 'p_open', 121 [ 122 ], 123 1 124 ], 125 [ 126 'cdata', 127 [ 128 'Foo' 129 ], 130 8 131 ], 132 [ 133 'p_close', 134 [], 135 11 136 ], 137 [ 138 'p_open', 139 [ 140 ], 141 11 142 ], 143 [ 144 'cdata', 145 [ 146 '</div> </block> Bar' 147 ], 148 13 149 ], 150 [ 151 'p_close', 152 [], 153 33 154 ], 155 [ 156 'plugin', 157 [ 158 'wrap_divwrap', 159 [ 160 DOKU_LEXER_EXIT, 161 '' 162 ], 163 DOKU_LEXER_EXIT, 164 '</WRAP>' 165 ], 166 33 167 ], 168 [ 169 'document_end', 170 [], 171 33 172 ] 173 ]; 174 $this->assertEquals($expected, $instructions); 175 } 176 177 public function testInlineNesting() { 178 $instructions = p_get_instructions("<wrap>Foo </span> </inline> Bar</wrap>"); 179 $expected = 180 [ 181 [ 182 'document_start', 183 [], 184 0 185 ], 186 [ 187 'p_open', 188 [ 189 ], 190 0 191 ], 192 [ 193 'plugin', 194 [ 195 'wrap_spanwrap', 196 [ 197 DOKU_LEXER_ENTER, 198 '<wrap' 199 ], 200 DOKU_LEXER_ENTER, 201 '<wrap>' 202 ], 203 1 204 ], 205 [ 206 'cdata', 207 [ 208 'Foo </span> </inline> Bar' 209 ], 210 7 211 ], 212 [ 213 'plugin', 214 [ 215 'wrap_spanwrap', 216 [ 217 DOKU_LEXER_EXIT, 218 '' 219 ], 220 DOKU_LEXER_EXIT, 221 '</wrap>' 222 ], 223 32 224 ], 225 [ 226 'cdata', 227 [ 228 '' 229 ], 230 39 231 ], 232 [ 233 'p_close', 234 [], 235 39 236 ], 237 [ 238 'document_end', 239 [], 240 39 241 ] 242 ]; 243 $this->assertEquals($expected, $instructions); 244 } 245 246} 247