Changeset 42343 for trunk/tests/phpunit/tests/formatting/Smilies.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/Smilies.php
r42228 r42343 13 13 */ 14 14 public function get_smilies_input_output() { 15 $includes_path = includes_url( "images/smilies/");16 17 return array 18 array 15 $includes_path = includes_url( 'images/smilies/' ); 16 17 return array( 18 array( 19 19 '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 :?:', 20 "Lorem ipsum dolor sit amet mauris \xf0\x9f\x98\x89 Praesent gravida sodales. \xf0\x9f\x98\x86 Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, \xf0\x9f\x98\xae mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, <img src=\"${includes_path}mrgreen.png\" alt=\":mrgreen:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" /> 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 \xe2\x9d\x93" 21 ), 22 array 20 "Lorem ipsum dolor sit amet mauris \xf0\x9f\x98\x89 Praesent gravida sodales. \xf0\x9f\x98\x86 Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, \xf0\x9f\x98\xae mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, <img src=\"${includes_path}mrgreen.png\" alt=\":mrgreen:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" /> 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 \xe2\x9d\x93", 21 ), 22 array( 23 23 '<strong>Welcome to the jungle!</strong> We got fun n games! :) We got everything you want 8-) <em>Honey we know the names :)</em>', 24 "<strong>Welcome to the jungle!</strong> We got fun n games! \xf0\x9f\x99\x82 We got everything you want \xf0\x9f\x98\x8e <em>Honey we know the names \xf0\x9f\x99\x82</em>" 25 ), 26 array 24 "<strong>Welcome to the jungle!</strong> We got fun n games! \xf0\x9f\x99\x82 We got everything you want \xf0\x9f\x98\x8e <em>Honey we know the names \xf0\x9f\x99\x82</em>", 25 ), 26 array( 27 27 "<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", 28 "<strong;)>a little bit of this\na little bit:other: of that \xf0\x9f\x98\x80\n\xf0\x9f\x98\x80 a little bit of good\nyeah with a little bit of bad8O" 29 ), 30 array 28 "<strong;)>a little bit of this\na little bit:other: of that \xf0\x9f\x98\x80\n\xf0\x9f\x98\x80 a little bit of good\nyeah with a little bit of bad8O", 29 ), 30 array( 31 31 '<strong style="here comes the sun :-D">and I say it\'s allright:D:D', 32 '<strong style="here comes the sun :-D">and I say it\'s allright:D:D' 33 ), 34 array 32 '<strong style="here comes the sun :-D">and I say it\'s allright:D:D', 33 ), 34 array( 35 35 '<!-- Woo-hoo, I\'m a comment, baby! :x > -->', 36 '<!-- Woo-hoo, I\'m a comment, baby! :x > -->' 37 ), 38 array 36 '<!-- Woo-hoo, I\'m a comment, baby! :x > -->', 37 ), 38 array( 39 39 ':?:P:?::-x:mrgreen:::', 40 ':?:P:?::-x:mrgreen:::' 40 ':?:P:?::-x:mrgreen:::', 41 41 ), 42 42 ); … … 55 55 smilies_init(); 56 56 57 $this->assertEquals( $converted_txt, convert_smilies( $in_txt) );58 59 // standard smilies, use_smilies: OFF 60 update_option( 'use_smilies', 0 ); 61 62 $this->assertEquals( $in_txt, convert_smilies( $in_txt) );57 $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); 58 59 // standard smilies, use_smilies: OFF 60 update_option( 'use_smilies', 0 ); 61 62 $this->assertEquals( $in_txt, convert_smilies( $in_txt ) ); 63 63 } 64 64 … … 69 69 */ 70 70 public function get_custom_smilies_input_output() { 71 $includes_path = includes_url( "images/smilies/");72 73 return array 74 array 71 $includes_path = includes_url( 'images/smilies/' ); 72 73 return array( 74 array( 75 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. :monkey:', 76 '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" style="height: 1em; max-height: 1em;" />' 77 ), 78 array 76 '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" style="height: 1em; max-height: 1em;" />', 77 ), 78 array( 79 79 '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:', 80 'Star Wars Jedi Knight <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 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" style="height: 1em; max-height: 1em;" />' 81 ), 82 array 80 'Star Wars Jedi Knight <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 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" style="height: 1em; max-height: 1em;" />', 81 ), 82 array( 83 83 ':arrow: monkey: Lorem ipsum dolor sit amet enim. Etiam ullam :PP <br />corper. Suspendisse a pellentesque dui, non felis.<a> :arrow: :arrow</a>', 84 '<img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> monkey: Lorem ipsum dolor sit amet enim. Etiam ullam <img src="' . $includes_path . 'icon_tongue.gif" alt=":PP" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <br />corper. Suspendisse a pellentesque dui, non felis.<a> <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> :arrow</a>' 84 '<img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> monkey: Lorem ipsum dolor sit amet enim. Etiam ullam <img src="' . $includes_path . 'icon_tongue.gif" alt=":PP" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <br />corper. Suspendisse a pellentesque dui, non felis.<a> <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> :arrow</a>', 85 85 ), 86 86 ); … … 92 92 * Validate Custom Smilies are converted to images when use_smilies = 1 93 93 */ 94 function test_convert_custom_smilies 94 function test_convert_custom_smilies( $in_txt, $converted_txt ) { 95 95 global $wpsmiliestrans; 96 96 … … 98 98 update_option( 'use_smilies', 1 ); 99 99 100 if ( ! isset( $wpsmiliestrans ) ) {100 if ( ! isset( $wpsmiliestrans ) ) { 101 101 smilies_init(); 102 102 } … … 105 105 106 106 $wpsmiliestrans = array( 107 ':PP' => 'icon_tongue.gif',108 ':arrow:' => 'icon_arrow.gif',107 ':PP' => 'icon_tongue.gif', 108 ':arrow:' => 'icon_arrow.gif', 109 109 ':monkey:' => 'icon_shock_the_monkey.gif', 110 ':nervou:' => 'icon_nervou.gif' 111 ); 112 113 smilies_init(); 114 115 $this->assertEquals( $converted_txt, convert_smilies( $in_txt) );116 117 // standard smilies, use_smilies: OFF 118 update_option( 'use_smilies', 0 ); 119 120 $this->assertEquals( $in_txt, convert_smilies( $in_txt) );110 ':nervou:' => 'icon_nervou.gif', 111 ); 112 113 smilies_init(); 114 115 $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); 116 117 // standard smilies, use_smilies: OFF 118 update_option( 'use_smilies', 0 ); 119 120 $this->assertEquals( $in_txt, convert_smilies( $in_txt ) ); 121 121 122 122 $wpsmiliestrans = $trans_orig; // reset original translations array … … 126 126 /** 127 127 * DataProvider of HTML elements/tags that smilie matches should be ignored in 128 *129 128 */ 130 129 public function get_smilies_ignore_tags() { 131 return array 130 return array( 132 131 array( 'pre' ), 133 132 array( 'code' ), 134 133 array( 'script' ), 135 134 array( 'style' ), 136 array( 'textarea' ),135 array( 'textarea' ), 137 136 ); 138 137 } … … 146 145 */ 147 146 public function test_ignore_smilies_in_tags( $element ) { 148 $includes_path = includes_url( "images/smilies/");149 150 $in_str = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . '>My Content Here :?: </' . $element . '>';147 $includes_path = includes_url( 'images/smilies/' ); 148 149 $in_str = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . '>My Content Here :?: </' . $element . '>'; 151 150 $exp_str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element>My Content Here :?: </$element>"; 152 151 … … 155 154 smilies_init(); 156 155 157 $this->assertEquals( $exp_str, convert_smilies( $in_str) );156 $this->assertEquals( $exp_str, convert_smilies( $in_str ) ); 158 157 159 158 // standard smilies, use_smilies: OFF … … 163 162 /** 164 163 * DataProvider of Smilie Combinations 165 *166 164 */ 167 165 public function get_smilies_combinations() { 168 $includes_path = includes_url( "images/smilies/");169 170 return array 171 array 166 $includes_path = includes_url( 'images/smilies/' ); 167 168 return array( 169 array( 172 170 '8-O :-(', 173 "\xf0\x9f\x98\xaf \xf0\x9f\x99\x81" 174 ), 175 array 171 "\xf0\x9f\x98\xaf \xf0\x9f\x99\x81", 172 ), 173 array( 176 174 '8-) 8-O', 177 "\xf0\x9f\x98\x8e \xf0\x9f\x98\xaf" 178 ), 179 array 175 "\xf0\x9f\x98\x8e \xf0\x9f\x98\xaf", 176 ), 177 array( 180 178 '8-) 8O', 181 "\xf0\x9f\x98\x8e \xf0\x9f\x98\xaf" 182 ), 183 array 179 "\xf0\x9f\x98\x8e \xf0\x9f\x98\xaf", 180 ), 181 array( 184 182 '8-) :-(', 185 "\xf0\x9f\x98\x8e \xf0\x9f\x99\x81" 186 ), 187 array 183 "\xf0\x9f\x98\x8e \xf0\x9f\x99\x81", 184 ), 185 array( 188 186 '8-) :twisted:', 189 "\xf0\x9f\x98\x8e \xf0\x9f\x98\x88" 190 ), 191 array 187 "\xf0\x9f\x98\x8e \xf0\x9f\x98\x88", 188 ), 189 array( 192 190 '8O :twisted: :( :? :roll: :mrgreen:', 193 "\xf0\x9f\x98\xaf \xf0\x9f\x98\x88 \xf0\x9f\x99\x81 \xf0\x9f\x98\x95 \xf0\x9f\x99\x84 <img src=\"{$includes_path}mrgreen.png\" alt=\":mrgreen:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" />" 191 "\xf0\x9f\x98\xaf \xf0\x9f\x98\x88 \xf0\x9f\x99\x81 \xf0\x9f\x98\x95 \xf0\x9f\x99\x84 <img src=\"{$includes_path}mrgreen.png\" alt=\":mrgreen:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" />", 194 192 ), 195 193 ); … … 208 206 smilies_init(); 209 207 210 $this->assertEquals( $converted_txt, convert_smilies( $in_txt) );208 $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); 211 209 212 210 // custom smilies, use_smilies: OFF 213 211 update_option( 'use_smilies', 0 ); 214 212 215 $this->assertEquals( $in_txt, convert_smilies( $in_txt) );213 $this->assertEquals( $in_txt, convert_smilies( $in_txt ) ); 216 214 } 217 215 218 216 /** 219 217 * DataProvider of Single Smilies input and converted output 220 *221 218 */ 222 219 public function get_single_smilies_input_output() { 223 $includes_path = includes_url( "images/smilies/");224 225 return array 226 array 220 $includes_path = includes_url( 'images/smilies/' ); 221 222 return array( 223 array( 227 224 '8-O :-(', 228 '8-O :-(' 229 ), 230 array 225 '8-O :-(', 226 ), 227 array( 231 228 '8O :) additional text here :)', 232 '8O <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> additional text here <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />' 233 ), 234 array 229 '8O <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> additional text here <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />', 230 ), 231 array( 235 232 ':) :) :) :)', 236 '<img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />' 233 '<img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />', 237 234 ), 238 235 ); … … 252 249 update_option( 'use_smilies', 1 ); 253 250 254 if ( ! isset( $wpsmiliestrans ) ) {251 if ( ! isset( $wpsmiliestrans ) ) { 255 252 smilies_init(); 256 253 } … … 258 255 $orig_trans = $wpsmiliestrans; // save original tranlations array 259 256 260 $wpsmiliestrans = array 261 ':)' => 'simple-smile.png' 262 ); 263 264 smilies_init(); 265 266 $this->assertEquals( $converted_txt, convert_smilies( $in_txt) );267 268 // standard smilies, use_smilies: OFF 269 update_option( 'use_smilies', 0 ); 270 271 $this->assertEquals( $in_txt, convert_smilies( $in_txt) );257 $wpsmiliestrans = array( 258 ':)' => 'simple-smile.png', 259 ); 260 261 smilies_init(); 262 263 $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); 264 265 // standard smilies, use_smilies: OFF 266 update_option( 'use_smilies', 0 ); 267 268 $this->assertEquals( $in_txt, convert_smilies( $in_txt ) ); 272 269 273 270 $wpsmiliestrans = $orig_trans; // reset original translations array … … 280 277 array( 281 278 'test :) smile', 282 "test \xf0\x9f\x99\x82 smile" 279 "test \xf0\x9f\x99\x82 smile", 283 280 ), 284 281 array( 285 282 'test :) smile', 286 "test \xf0\x9f\x99\x82 smile" 283 "test \xf0\x9f\x99\x82 smile", 287 284 ), 288 285 array( 289 286 "test {$nbsp}:){$nbsp}smile", 290 "test {$nbsp}\xf0\x9f\x99\x82{$nbsp}smile" 291 ) 287 "test {$nbsp}\xf0\x9f\x99\x82{$nbsp}smile", 288 ), 292 289 ); 293 290 } … … 340 337 remove_filter( 'smilies', array( $this, '_filter_add_smilies' ) ); 341 338 342 $txt = 'You played with my <3';339 $txt = 'You played with my <3'; 343 340 $expected_txt = 'You played with my \xe2\x9d\xa4'; 344 341
Note: See TracChangeset
for help on using the changeset viewer.