Ticket #22692: miqro-22692-tests.3.diff
| File miqro-22692-tests.3.diff, 3.7 KB (added by , 13 years ago) |
|---|
-
tests/formatting/ConvertSmilies.php
1 <?php 2 3 /** 4 * @group formatting 5 */ 6 class Tests_Formatting_ConvertSmilies extends WP_UnitTestCase { 7 8 /** 9 * Check that $wp_smiliessearch pattern will match smilies 10 * between spaces, but never capture those spaces. 11 * 12 * Further check that spaces aren't randomly deleted 13 * or added when replacing the text with an image. 14 * 15 * @ticket 22692 / 26842 16 */ 17 function test_spaces_around_smilies() { 18 $nbsp = "\xC2\xA0"; 19 20 $input = array(); 21 $output = array(); 22 23 $input[] = 'My test :) smile'; 24 $output[] = array('test <img ', 'alt=":)"', ' /> smile'); 25 26 $input[] = 'My test ;) smile'; 27 $output[] = array('test <img ', 'alt=";)"', ' /> smile'); 28 29 $input[] = 'My test :) smile'; 30 $output[] = array('test <img ', 'alt=":)"', ' /> smile'); 31 32 $input[] = 'My test ;) smile'; 33 $output[] = array('test <img ', 'alt=";)"', ' /> smile'); 34 35 $input[] = "My test {$nbsp}:){$nbsp}smile"; 36 $output[] = array("test {$nbsp}<img ", 'alt=":)"', " />{$nbsp}smile"); 37 38 $input[] = "My test {$nbsp};){$nbsp}smile"; 39 $output[] = array("test {$nbsp}<img ", 'alt=";)"', " />{$nbsp}smile"); 40 41 foreach($input as $key => $in) { 42 $result = convert_smilies( $in ); 43 foreach($output[$key] as $k => $out) { 44 45 // Each output element must appear in the results. 46 $this->assertContains( $out[$k], $result ); 47 48 } 49 } 50 } 51 } -
tests/formatting/WPTexturize.php
194 194 $this->assertEquals( ' — ', wptexturize( ' -- ' ) ); 195 195 $this->assertEquals( ' — ', wptexturize( ' -- ') ); 196 196 } 197 198 /** 199 * @ticket 22692 200 */ 201 function test_spaces_around_quotes() { 202 $nbsp = "\xC2\xA0"; 203 $pi = "\xCE\xA0"; 204 205 // This should never happen, even if the desired output changes some day. 206 207 $problem_input = "$nbsp\"A"; 208 $problem_output = "$nbsp”A"; 209 210 $this->assertNotEquals( $problem_output, wptexturize( $problem_input ) ); 211 212 // These are desirable outputs for the current design. 213 214 $input = array(); 215 $output = array(); 216 217 $input[] = "stop. $nbsp\"A quote after 2 spaces.\""; 218 $output[] = "stop. $nbsp“A quote after 2 spaces.”"; 219 220 $input[] = "stop.$nbsp$nbsp\"A quote after 2 spaces.\""; 221 $output[] = "stop.$nbsp$nbsp“A quote after 2 spaces.”"; 222 223 $input[] = "stop. $nbsp'A quote after 2 spaces.'"; 224 $output[] = "stop. $nbsp‘A quote after 2 spaces.’"; 225 226 $input[] = "stop.$nbsp$nbsp'A quote after 2 spaces.'"; 227 $output[] = "stop.$nbsp$nbsp‘A quote after 2 spaces.’"; 228 229 $input[] = "stop. \"A quote after 2 spaces.\""; 230 $output[] = "stop. “A quote after 2 spaces.”"; 231 232 $input[] = "stop. \"A quote after 2 spaces.\""; 233 $output[] = "stop. “A quote after 2 spaces.”"; 234 235 $input[] = "stop. 'A quote after 2 spaces.'"; 236 $output[] = "stop. ‘A quote after 2 spaces.’"; 237 238 $input[] = "stop. 'A quote after 2 spaces.'"; 239 $output[] = "stop. ‘A quote after 2 spaces.’"; 240 241 $input[] = "Contraction: $pi's"; 242 $output[] = "Contraction: $pi’s"; 243 244 foreach($input as $key => $in) { 245 $this->assertEquals( $output[$key], wptexturize( $in ) ); 246 } 247 } 197 248 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)