Changeset 28717 for trunk/tests/phpunit/tests/formatting/Smilies.php
- Timestamp:
- 06/10/2014 02:02:23 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/Smilies.php
r28625 r28717 17 17 array ( 18 18 'Lorem ipsum dolor sit amet mauris ;-) Praesent gravida sodales. :lol: Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, :eek: mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, :mrgreen: tincidunt nec, sagittis non, fringilla enim. Nam consectetuer nec, ullamcorper pede eu dui odio consequat vel, vehicula tortor quis pede turpis cursus quis, egestas ipsum ultricies ut, eleifend velit. Mauris vestibulum iaculis. Sed in nunc. Vivamus elit porttitor egestas. Mauris purus :?:', 19 'Lorem ipsum dolor sit amet mauris <img src="' . $includes_path . 'icon_wink.gif" alt=";-)" class="wp-smiley" /> Praesent gravida sodales. <img src="' . $includes_path . 'icon_lol.gif" alt=":lol:" class="wp-smiley" /> Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, <img src="' . $includes_path . 'icon_surprised.gif" alt=":eek:" class="wp-smiley" /> mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, <img src="' . $includes_path . 'icon_mrgreen.gif" alt=":mrgreen:" class="wp-smiley" /> tincidunt nec, sagittis non, fringilla enim. Nam consectetuer nec, ullamcorper pede eu dui odio consequat vel, vehicula tortor quis pede turpis cursus quis, egestas ipsum ultricies ut, eleifend velit. Mauris vestibulum iaculis. Sed in nunc. Vivamus elit porttitor egestas. Mauris purus <img src="' . $includes_path . 'icon_question.gif" alt=":?:" class="wp-smiley" />'19 'Lorem ipsum dolor sit amet mauris <img src="' . $includes_path . 'icon_wink.gif" alt=";-)" class="wp-smiley" /> Praesent gravida sodales. <img src="' . $includes_path . 'icon_lol.gif" alt=":lol:" class="wp-smiley" /> Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, <img src="' . $includes_path . 'icon_surprised.gif" alt=":eek:" class="wp-smiley" /> mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, <img src="' . $includes_path . 'icon_mrgreen.gif" alt=":mrgreen:" class="wp-smiley" /> tincidunt nec, sagittis non, fringilla enim. Nam consectetuer nec, ullamcorper pede eu dui odio consequat vel, vehicula tortor quis pede turpis cursus quis, egestas ipsum ultricies ut, eleifend velit. Mauris vestibulum iaculis. Sed in nunc. Vivamus elit porttitor egestas. Mauris purus <img src="' . $includes_path . 'icon_question.gif" alt=":?:" class="wp-smiley" />' 20 20 ), 21 21 array ( 22 22 '<strong>Welcome to the jungle!</strong> We got fun n games! :) We got everything you want 8-) <em>Honey we know the names :)</em>', 23 '<strong>Welcome to the jungle!</strong> We got fun n games! <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> We got everything you want <img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <em>Honey we know the names <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /></em>'23 '<strong>Welcome to the jungle!</strong> We got fun n games! <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> We got everything you want <img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <em>Honey we know the names <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /></em>' 24 24 ), 25 25 array ( 26 26 "<strong;)>a little bit of this\na little bit:other: of that :D\n:D a little bit of good\nyeah with a little bit of bad8O", 27 "<strong;)>a little bit of this\na little bit:other: of that <img src=\"{$includes_path}icon_biggrin.gif\" alt=\":D\" class=\"wp-smiley\" /> <img src=\"{$includes_path}icon_biggrin.gif\" alt=\":D\" class=\"wp-smiley\" />a little bit of good\nyeah with a little bit of bad8O"27 "<strong;)>a little bit of this\na little bit:other: of that <img src=\"{$includes_path}icon_biggrin.gif\" alt=\":D\" class=\"wp-smiley\" />\n<img src=\"{$includes_path}icon_biggrin.gif\" alt=\":D\" class=\"wp-smiley\" /> a little bit of good\nyeah with a little bit of bad8O" 28 28 ), 29 29 array ( … … 49 49 */ 50 50 function test_convert_standard_smilies( $in_txt, $converted_txt ) { 51 global $wpsmiliestrans;52 53 51 // standard smilies, use_smilies: ON 54 52 update_option( 'use_smilies', 1 ); … … 62 60 63 61 $this->assertEquals( $in_txt, convert_smilies($in_txt) ); 64 65 unset( $wpsmiliestrans );66 62 } 67 63 … … 77 73 array ( 78 74 'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. :monkey:', 79 'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. <img src="' . $includes_path . 'icon_shock_the_monkey.gif" alt=":monkey:" class="wp-smiley" /> 75 'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. <img src="' . $includes_path . 'icon_shock_the_monkey.gif" alt=":monkey:" class="wp-smiley" />' 80 76 ), 81 77 array ( 82 78 'Star Wars Jedi Knight :arrow: Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. :nervou:', 83 'Star Wars Jedi Knight <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" /> Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. <img src="' . $includes_path . 'icon_nervou.gif" alt=":nervou:" class="wp-smiley" />'79 'Star Wars Jedi Knight <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" /> Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. <img src="' . $includes_path . 'icon_nervou.gif" alt=":nervou:" class="wp-smiley" />' 84 80 ), 85 81 array ( 86 82 ':arrow: monkey: Lorem ipsum dolor sit amet enim. Etiam ullam :PP <br />corper. Suspendisse a pellentesque dui, non felis.<a> :arrow: :arrow</a>', 87 ' <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" /> monkey: Lorem ipsum dolor sit amet enim. Etiam ullam <img src="' . $includes_path . 'icon_tongue.gif" alt=":PP" class="wp-smiley" /> <br />corper. Suspendisse a pellentesque dui, non felis.<a> <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" />:arrow</a>'83 '<img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" /> monkey: Lorem ipsum dolor sit amet enim. Etiam ullam <img src="' . $includes_path . 'icon_tongue.gif" alt=":PP" class="wp-smiley" /> <br />corper. Suspendisse a pellentesque dui, non felis.<a> <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" /> :arrow</a>' 88 84 ), 89 85 ); … … 97 93 function test_convert_custom_smilies ( $in_txt, $converted_txt ) { 98 94 global $wpsmiliestrans; 95 96 // custom smilies, use_smilies: ON 97 update_option( 'use_smilies', 1 ); 98 99 if ( !isset( $wpsmiliestrans ) ) { 100 smilies_init(); 101 } 102 99 103 $trans_orig = $wpsmiliestrans; // save original translations array 100 104 101 // custom smilies, use_smilies: ON102 update_option( 'use_smilies', 1 );103 105 $wpsmiliestrans = array( 104 106 ':PP' => 'icon_tongue.gif', … … 143 145 */ 144 146 public function test_ignore_smilies_in_tags( $element ) { 145 global $wpsmiliestrans;146 $trans_orig = $wpsmiliestrans; // save original translations array147 148 147 $includes_path = includes_url("images/smilies/"); 149 148 150 149 $in_str = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . '>My Content Here :?: </' . $element . '>'; 151 $exp_str = 'Do we ingore smilies <img src="' . $includes_path . 'icon_wink.gif" alt=";-)" class="wp-smiley" /> 150 $exp_str = 'Do we ingore smilies <img src="' . $includes_path . 'icon_wink.gif" alt=";-)" class="wp-smiley" /> in ' . $element . ' tags <' . $element . '>My Content Here :?: </' . $element . '>'; 152 151 153 152 // standard smilies, use_smilies: ON … … 159 158 // standard smilies, use_smilies: OFF 160 159 update_option( 'use_smilies', 0 ); 161 162 $wpsmiliestrans = $trans_orig; // reset original translations array163 160 } 164 161 … … 173 170 array ( 174 171 '8-O :-(', 175 ' <img src="' . $includes_path . 'icon_eek.gif" alt="8-O" class="wp-smiley" /> <img src="' . $includes_path . 'icon_sad.gif" alt=":-(" class="wp-smiley" />'172 '<img src="' . $includes_path . 'icon_eek.gif" alt="8-O" class="wp-smiley" /> <img src="' . $includes_path . 'icon_sad.gif" alt=":-(" class="wp-smiley" />' 176 173 ), 177 174 array ( 178 175 '8-) 8-O', 179 ' <img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_eek.gif" alt="8-O" class="wp-smiley" />'176 '<img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_eek.gif" alt="8-O" class="wp-smiley" />' 180 177 ), 181 178 array ( 182 179 '8-) 8O', 183 ' <img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_eek.gif" alt="8O" class="wp-smiley" />'180 '<img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_eek.gif" alt="8O" class="wp-smiley" />' 184 181 ), 185 182 array ( 186 183 '8-) :-(', 187 ' <img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_sad.gif" alt=":-(" class="wp-smiley" />'184 '<img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_sad.gif" alt=":-(" class="wp-smiley" />' 188 185 ), 189 186 array ( 190 187 '8-) :twisted:', 191 ' <img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_twisted.gif" alt=":twisted:" class="wp-smiley" />'188 '<img src="' . $includes_path . 'icon_cool.gif" alt="8-)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_twisted.gif" alt=":twisted:" class="wp-smiley" />' 192 189 ), 193 190 array ( 194 191 '8O :twisted: :( :? :(', 195 ' <img src="' . $includes_path . 'icon_eek.gif" alt="8O" class="wp-smiley" /> <img src="' . $includes_path . 'icon_twisted.gif" alt=":twisted:" class="wp-smiley" /> <img src="' . $includes_path . 'icon_sad.gif" alt=":(" class="wp-smiley" /> <img src="' . $includes_path . 'icon_confused.gif" alt=":?" class="wp-smiley" /> <img src="' . $includes_path . 'icon_sad.gif" alt=":(" class="wp-smiley" />'192 '<img src="' . $includes_path . 'icon_eek.gif" alt="8O" class="wp-smiley" /> <img src="' . $includes_path . 'icon_twisted.gif" alt=":twisted:" class="wp-smiley" /> <img src="' . $includes_path . 'icon_sad.gif" alt=":(" class="wp-smiley" /> <img src="' . $includes_path . 'icon_confused.gif" alt=":?" class="wp-smiley" /> <img src="' . $includes_path . 'icon_sad.gif" alt=":(" class="wp-smiley" />' 196 193 ), 197 194 ); … … 206 203 */ 207 204 public function test_smilies_combinations( $in_txt, $converted_txt ) { 208 global $wpsmiliestrans;209 210 205 // custom smilies, use_smilies: ON 211 206 update_option( 'use_smilies', 1 ); … … 234 229 array ( 235 230 '8O :) additional text here :)', 236 '8O <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> additional text here <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" />'231 '8O <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> additional text here <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" />' 237 232 ), 238 233 array ( 239 234 ':) :) :) :)', 240 ' <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" />'235 '<img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" /> <img src="' . $includes_path . 'icon_smile.gif" alt=":)" class="wp-smiley" />' 241 236 ), 242 237 ); … … 252 247 public function test_single_smilies_in_wpsmiliestrans( $in_txt, $converted_txt ) { 253 248 global $wpsmiliestrans; 249 250 // standard smilies, use_smilies: ON 251 update_option( 'use_smilies', 1 ); 252 253 if ( !isset( $wpsmiliestrans ) ) { 254 smilies_init(); 255 } 256 254 257 $orig_trans = $wpsmiliestrans; // save original tranlations array 255 256 // standard smilies, use_smilies: ON257 update_option( 'use_smilies', 1 );258 258 259 259 $wpsmiliestrans = array ( … … 272 272 $wpsmiliestrans = $orig_trans; // reset original translations array 273 273 } 274 275 /** 276 * Check that $wp_smiliessearch pattern will match smilies 277 * between spaces, but never capture those spaces. 278 * 279 * Further check that spaces aren't randomly deleted 280 * or added when replacing the text with an image. 281 * 282 * @ticket 22692 283 */ 284 function test_spaces_around_smilies() { 285 $nbsp = "\xC2\xA0"; 286 287 // standard smilies, use_smilies: ON 288 update_option( 'use_smilies', 1 ); 289 smilies_init(); 290 291 $input = array(); 292 $output = array(); 293 294 $input[] = 'My test :) smile'; 295 $output[] = array('test <img ', 'alt=":)"', ' /> smile'); 296 297 $input[] = 'My test ;) smile'; 298 $output[] = array('test <img ', 'alt=";)"', ' /> smile'); 299 300 $input[] = 'My test :) smile'; 301 $output[] = array('test <img ', 'alt=":)"', ' /> smile'); 302 303 $input[] = 'My test ;) smile'; 304 $output[] = array('test <img ', 'alt=";)"', ' /> smile'); 305 306 $input[] = "My test {$nbsp}:){$nbsp}smile"; 307 $output[] = array("test {$nbsp}<img ", 'alt=":)"', " />{$nbsp}smile"); 308 309 $input[] = "My test {$nbsp};){$nbsp}smile"; 310 $output[] = array("test {$nbsp}<img ", 'alt=";)"', " />{$nbsp}smile"); 311 312 foreach($input as $key => $in) { 313 $result = convert_smilies( $in ); 314 foreach($output[$key] as $out) { 315 316 // Each output element must appear in the results. 317 $this->assertContains( $out, $result ); 318 319 } 320 } 321 322 // standard smilies, use_smilies: OFF 323 update_option( 'use_smilies', 0 ); 324 } 274 325 }
Note: See TracChangeset
for help on using the changeset viewer.