1<?php 2/** 3 * Tests to ensure creole syntax is correctly processed 4 * and creates expected XHTML output 5 * 6 * @group plugin_creole 7 * @group plugins 8 */ 9class plugin_creole_test extends DokuWikiTest { 10 protected $pluginsEnabled = array('creole'); 11 12 function setUp(){ 13 global $conf; 14 15 parent::setUp(); 16 17 $conf ['plugin']['creole']['precedence'] = 'Creole'; 18 $conf ['plugin']['creole']['linebreak'] = 'Whitespace'; 19 } 20 21 /** 22 * Test monospace XHTML generation. 23 * Recommended output: "This is <tt>monospace</tt> text." 24 * See http://www.wikicreole.org/wiki/CreoleAdditions, section "Monospace" 25 */ 26 public function test_monospace() { 27 $info = array(); 28 $expected = "\n<p>\nThis is <tt>monospace</tt> text. \n</p>\n"; 29 30 $instructions = p_get_instructions('This is ##monospace## text.'); 31 $xhtml = p_render('xhtml', $instructions, $info); 32 33 $this->assertEquals($expected, $xhtml); 34 } 35 36 /** 37 * Test superscript XHTML generation. 38 * Recommended output: "This is <sup>superscripted</sup> text." 39 * See http://www.wikicreole.org/wiki/CreoleAdditions, section "Superscript" 40 */ 41 public function test_superscript() { 42 $info = array(); 43 $expected = "\n<p>\nThis is <sup>superscripted</sup> text. \n</p>\n"; 44 45 $instructions = p_get_instructions('This is ^^superscripted^^ text.'); 46 $xhtml = p_render('xhtml', $instructions, $info); 47 48 $this->assertEquals($expected, $xhtml); 49 } 50 51 /** 52 * Test subscript XHTML generation. 53 * Recommended output: "This is <sub>subscripted</sub> text." 54 * See http://www.wikicreole.org/wiki/CreoleAdditions, section "Superscript" 55 */ 56 public function test_subscript() { 57 $info = array(); 58 $expected = "\n<p>\nThis is <sub>subscripted</sub> text. \n</p>\n"; 59 60 $instructions = p_get_instructions('This is ,,subscripted,, text.'); 61 $xhtml = p_render('xhtml', $instructions, $info); 62 63 $this->assertEquals($expected, $xhtml); 64 } 65 66 /** 67 * Test according to examples in: 68 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 69 * 70 * Test heading 1, no trailing equal signs 71 */ 72 public function test_heading1_no_trailing_equal() { 73 $info = array(); 74 $expected = "\n<h1 class=\"sectionedit1\" id=\"top-level_heading_1\">Top-level heading (1)</h1>\n<div class=\"level1\">\n\n</div>\n"; 75 76 $instructions = p_get_instructions('= Top-level heading (1)'); 77 $xhtml = p_render('xhtml', $instructions, $info); 78 79 $this->assertEquals($expected, $xhtml); 80 } 81 82 /** 83 * Test according to examples in: 84 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 85 * 86 * Test heading 2, no trailing equal signs 87 */ 88 public function test_heading2_no_trailing_equal() { 89 $info = array(); 90 $expected = "\n<h2 class=\"sectionedit1\" id=\"this_a_test_for_creole_01_2\">This a test for creole 0.1 (2)</h2>\n<div class=\"level2\">\n\n</div>\n"; 91 92 $instructions = p_get_instructions('== This a test for creole 0.1 (2)'); 93 $xhtml = p_render('xhtml', $instructions, $info); 94 95 $this->assertEquals($expected, $xhtml); 96 } 97 98 /** 99 * Test according to examples in: 100 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 101 * 102 * Test heading 3, no trailing equal signs 103 */ 104 public function test_heading3_no_trailing_equal() { 105 $info = array(); 106 $expected = "\n<h3 class=\"sectionedit1\" id=\"this_is_a_subheading_3\">This is a Subheading (3)</h3>\n<div class=\"level3\">\n\n</div>\n"; 107 108 $instructions = p_get_instructions('=== This is a Subheading (3)'); 109 $xhtml = p_render('xhtml', $instructions, $info); 110 111 $this->assertEquals($expected, $xhtml); 112 } 113 114 /** 115 * Test according to examples in: 116 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 117 * 118 * Test heading 4, no trailing equal signs 119 */ 120 public function test_heading4_no_trailing_equal() { 121 $info = array(); 122 $expected = "\n<h4 id=\"subsub_4\">Subsub (4)</h4>\n<div class=\"level4\">\n\n</div>\n"; 123 124 $instructions = p_get_instructions('==== Subsub (4)'); 125 $xhtml = p_render('xhtml', $instructions, $info); 126 127 $this->assertEquals($expected, $xhtml); 128 } 129 130 /** 131 * Test according to examples in: 132 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 133 * 134 * Test heading 5, no trailing equal signs 135 */ 136 public function test_heading5_no_trailing_equal() { 137 $info = array(); 138 $expected = "\n<h5 id=\"subsubsub_5\">Subsubsub (5)</h5>\n<div class=\"level5\">\n\n</div>\n"; 139 140 $instructions = p_get_instructions('===== Subsubsub (5)'); 141 $xhtml = p_render('xhtml', $instructions, $info); 142 143 $this->assertEquals($expected, $xhtml); 144 } 145 146 /** 147 * Test according to examples in: 148 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 149 * 150 * Test heading 1 151 */ 152 public function test_heading1() { 153 $info = array(); 154 $expected = "\n<h1 class=\"sectionedit1\" id=\"top-level_heading_1\">Top-level heading (1)</h1>\n<div class=\"level1\">\n\n</div>\n"; 155 156 $instructions = p_get_instructions('= Top-level heading (1) ='); 157 $xhtml = p_render('xhtml', $instructions, $info); 158 159 $this->assertEquals($expected, $xhtml); 160 } 161 162 /** 163 * Test according to examples in: 164 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 165 * 166 * Test heading 2 167 */ 168 public function test_heading2() { 169 $info = array(); 170 $expected = "\n<h2 class=\"sectionedit1\" id=\"this_a_test_for_creole_01_2\">This a test for creole 0.1 (2)</h2>\n<div class=\"level2\">\n\n</div>\n"; 171 172 $instructions = p_get_instructions('== This a test for creole 0.1 (2) =='); 173 $xhtml = p_render('xhtml', $instructions, $info); 174 175 $this->assertEquals($expected, $xhtml); 176 } 177 178 /** 179 * Test according to examples in: 180 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 181 * 182 * Test heading 3 183 */ 184 public function test_heading3() { 185 $info = array(); 186 $expected = "\n<h3 class=\"sectionedit1\" id=\"this_is_a_subheading_3\">This is a Subheading (3)</h3>\n<div class=\"level3\">\n\n</div>\n"; 187 188 $instructions = p_get_instructions('=== This is a Subheading (3) ==='); 189 $xhtml = p_render('xhtml', $instructions, $info); 190 191 $this->assertEquals($expected, $xhtml); 192 } 193 194 /** 195 * Test according to examples in: 196 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 197 * 198 * Test heading 4 199 */ 200 public function test_heading4() { 201 $info = array(); 202 $expected = "\n<h4 id=\"subsub_4\">Subsub (4)</h4>\n<div class=\"level4\">\n\n</div>\n"; 203 204 $instructions = p_get_instructions('==== Subsub (4) ===='); 205 $xhtml = p_render('xhtml', $instructions, $info); 206 207 $this->assertEquals($expected, $xhtml); 208 } 209 210 /** 211 * Test according to examples in: 212 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 213 * 214 * Test heading 5 215 */ 216 public function test_heading5() { 217 $info = array(); 218 $expected = "\n<h5 id=\"subsubsub_5\">Subsubsub (5)</h5>\n<div class=\"level5\">\n\n</div>\n"; 219 220 $instructions = p_get_instructions('===== Subsubsub (5) ====='); 221 $xhtml = p_render('xhtml', $instructions, $info); 222 223 $this->assertEquals($expected, $xhtml); 224 } 225 226 /** 227 * Test according to examples in: 228 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 229 * 230 * Test inline bold and italic style and both styles combined 231 */ 232 public function test_bold_and_italic_inline() { 233 $info = array(); 234 $expected = "\n<p>\nYou can make things <strong>bold</strong> or <em>italic</em> or <strong><em>both</em></strong> or <em><strong>both</strong></em>. \n</p>\n"; 235 236 $instructions = p_get_instructions('You can make things **bold** or //italic// or **//both//** or //**both**//.'); 237 $xhtml = p_render('xhtml', $instructions, $info); 238 239 $this->assertEquals($expected, $xhtml); 240 } 241 242 /** 243 * Test according to examples in: 244 * http://www.wikicreole.org/attach/Creole1.0TestCases/creole1.0test.txt 245 * 246 * Test bold multiline 247 */ 248 public function test_bold_multiline() { 249 $info = array(); 250 $expected = "\n<p>\nCharacter formatting extends across line breaks: <strong>bold, this is still bold. This line deliberately does not end in star-star.</strong>\n</p>\n\n<p>\nNot bold. Character formatting does not cross paragraph boundaries. \n</p>\n"; 251 252 $source = "Character formatting extends across line breaks: **bold,\nthis is still bold. This line deliberately does not end in star-star.\n\nNot bold. Character formatting does not cross paragraph boundaries."; 253 $instructions = p_get_instructions($source); 254 $xhtml = p_render('xhtml', $instructions, $info); 255 256 $this->assertEquals($expected, $xhtml); 257 } 258} 259