Changeset 55563 for trunk/tests/phpunit/tests/formatting/convertSmilies.php
- Timestamp:
- 03/19/2023 12:51:14 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/convertSmilies.php
r55562 r55563 10 10 11 11 /** 12 * Basic validation test to confirm that smilies are converted to image 13 * when use_smilies = 1 and not when use_smilies = 0. 14 * 12 15 * @dataProvider data_convert_standard_smilies 13 * 14 * Basic Validation Test to confirm that smilies are converted to image 15 * when use_smilies = 1 and not when use_smilies = 0 16 */ 17 public function test_convert_standard_smilies( $in_txt, $converted_txt ) { 16 */ 17 public function test_convert_standard_smilies( $input, $converted ) { 18 18 // Standard smilies, use_smilies: ON. 19 19 update_option( 'use_smilies', 1 ); … … 21 21 smilies_init(); 22 22 23 $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); 24 25 // Standard smilies, use_smilies: OFF. 26 update_option( 'use_smilies', 0 ); 27 28 $this->assertSame( $in_txt, convert_smilies( $in_txt ) ); 29 } 30 31 /** 32 * Basic Test Content DataProvider 33 * 34 * array ( input_txt, converted_output_txt) 23 $this->assertSame( $converted, convert_smilies( $input ) ); 24 25 // Standard smilies, use_smilies: OFF. 26 update_option( 'use_smilies', 0 ); 27 28 $this->assertSame( $input, convert_smilies( $input ) ); 29 } 30 31 /** 32 * Data provider. 33 * 34 * @return array { 35 * @type array { 36 * @type string $input Input content. 37 * @type string $converted Converted output. 38 * } 39 * } 35 40 */ 36 41 public function data_convert_standard_smilies() { … … 66 71 67 72 /** 73 * Tests that custom smilies are converted to images when use_smilies = 1. 74 * 68 75 * @dataProvider data_convert_custom_smilies 69 * 70 * Validate Custom Smilies are converted to images when use_smilies = 1 71 */ 72 public function test_convert_custom_smilies( $in_txt, $converted_txt ) { 76 */ 77 public function test_convert_custom_smilies( $input, $converted ) { 73 78 global $wpsmiliestrans; 74 79 … … 91 96 smilies_init(); 92 97 93 $this->assertSame( $converted _txt, convert_smilies( $in_txt ) );94 95 // Standard smilies, use_smilies: OFF. 96 update_option( 'use_smilies', 0 ); 97 98 $this->assertSame( $in _txt, convert_smilies( $in_txt ) );98 $this->assertSame( $converted, convert_smilies( $input ) ); 99 100 // Standard smilies, use_smilies: OFF. 101 update_option( 'use_smilies', 0 ); 102 103 $this->assertSame( $input, convert_smilies( $input ) ); 99 104 100 105 $wpsmiliestrans = $trans_orig; // Reset original translations array. … … 102 107 103 108 /** 104 * Custom Smilies Test Content DataProvider 105 * 106 * array ( input_txt, converted_output_txt) 109 * Data provider. 110 * 111 * @return array { 112 * @type array { 113 * @type string $input Input content. 114 * @type string $converted Converted output. 115 * } 116 * } 107 117 */ 108 118 public function data_convert_custom_smilies() { … … 126 136 127 137 /** 128 * Validate Conversion of Smilies is ignored in pre-determined tags129 * pre, code, script, style 138 * Tests that conversion of smilies is ignored in pre-determined tags: 139 * pre, code, script, style. 130 140 * 131 141 * @ticket 16448 … … 135 145 $includes_path = includes_url( 'images/smilies/' ); 136 146 137 $in _str = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . ' class="foo">My Content Here :?: </' . $element . '>';138 $exp _str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element class=\"foo\">My Content Here :?: </$element>";147 $input = 'Do we ignore smilies ;-) in ' . $element . ' tags <' . $element . ' class="foo">My Content Here :?: </' . $element . '>'; 148 $expected = "Do we ignore smilies \xf0\x9f\x98\x89 in $element tags <$element class=\"foo\">My Content Here :?: </$element>"; 139 149 140 150 // Standard smilies, use_smilies: ON. … … 142 152 smilies_init(); 143 153 144 $this->assertSame( $exp_str, convert_smilies( $in_str ) ); 145 146 // Standard smilies, use_smilies: OFF. 147 update_option( 'use_smilies', 0 ); 148 } 149 150 /** 151 * DataProvider of HTML elements/tags that smilie matches should be ignored in 154 $this->assertSame( $expected, convert_smilies( $input ) ); 155 156 // Standard smilies, use_smilies: OFF. 157 update_option( 'use_smilies', 0 ); 158 } 159 160 /** 161 * Data provider. 162 * 163 * @return array { 164 * @type array { 165 * @type string $element HTML tag name. 166 * } 167 * } 152 168 */ 153 169 public function data_ignore_smilies_in_tags() { … … 162 178 163 179 /** 164 * Validate Combinations of Smilies separated bysingle space165 * are converted correctly 180 * Tests that combinations of smilies separated by a single space 181 * are converted correctly. 166 182 * 167 183 * @ticket 20124 168 184 * @dataProvider data_smilies_combinations 169 185 */ 170 public function test_smilies_combinations( $in _txt, $converted_txt) {186 public function test_smilies_combinations( $input, $converted ) { 171 187 // Custom smilies, use_smilies: ON. 172 188 update_option( 'use_smilies', 1 ); 173 189 smilies_init(); 174 190 175 $this->assertSame( $converted _txt, convert_smilies( $in_txt ) );191 $this->assertSame( $converted, convert_smilies( $input ) ); 176 192 177 193 // Custom smilies, use_smilies: OFF. 178 194 update_option( 'use_smilies', 0 ); 179 195 180 $this->assertSame( $in_txt, convert_smilies( $in_txt ) ); 181 } 182 183 /** 184 * DataProvider of Smilie Combinations 196 $this->assertSame( $input, convert_smilies( $input ) ); 197 } 198 199 /** 200 * Data provider. 201 * 202 * @return array { 203 * @type array { 204 * @type string $input Input content. 205 * @type string $converted Converted output. 206 * } 207 * } 185 208 */ 186 209 public function data_smilies_combinations() { … … 216 239 217 240 /** 218 * Validate Smilies are converted for single smilie in219 * the $wpsmiliestrans global array 241 * Tests that smilies are converted for single smilie in 242 * the $wpsmiliestrans global array. 220 243 * 221 244 * @ticket 25303 222 245 * @dataProvider data_single_smilies_in_wpsmiliestrans 223 246 */ 224 public function test_single_smilies_in_wpsmiliestrans( $in _txt, $converted_txt) {247 public function test_single_smilies_in_wpsmiliestrans( $input, $converted ) { 225 248 global $wpsmiliestrans; 226 249 … … 240 263 smilies_init(); 241 264 242 $this->assertSame( $converted _txt, convert_smilies( $in_txt ) );243 244 // Standard smilies, use_smilies: OFF. 245 update_option( 'use_smilies', 0 ); 246 247 $this->assertSame( $in _txt, convert_smilies( $in_txt ) );265 $this->assertSame( $converted, convert_smilies( $input ) ); 266 267 // Standard smilies, use_smilies: OFF. 268 update_option( 'use_smilies', 0 ); 269 270 $this->assertSame( $input, convert_smilies( $input ) ); 248 271 249 272 $wpsmiliestrans = $orig_trans; // Reset original translations array. … … 251 274 252 275 /** 253 * DataProvider of Single Smilies input and converted output 276 * Data provider. 277 * 278 * @return array { 279 * @type array { 280 * @type string $input Input content. 281 * @type string $converted Converted output. 282 * } 283 * } 254 284 */ 255 285 public function data_single_smilies_in_wpsmiliestrans() { … … 273 303 274 304 /** 275 * Checkthat $wp_smiliessearch pattern will match smilies305 * Tests that $wp_smiliessearch pattern will match smilies 276 306 * between spaces, but never capture those spaces. 277 307 * 278 * Further checkthat spaces aren't randomly deleted308 * Further tests that spaces aren't randomly deleted 279 309 * or added when replacing the text with an image. 280 310 * … … 282 312 * @dataProvider data_spaces_around_smilies 283 313 */ 284 public function test_spaces_around_smilies( $in _txt, $converted_txt) {314 public function test_spaces_around_smilies( $input, $converted ) { 285 315 // Standard smilies, use_smilies: ON. 286 316 update_option( 'use_smilies', 1 ); … … 288 318 smilies_init(); 289 319 290 $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); 291 292 // Standard smilies, use_smilies: OFF. 293 update_option( 'use_smilies', 0 ); 294 } 295 320 $this->assertSame( $converted, convert_smilies( $input ) ); 321 322 // Standard smilies, use_smilies: OFF. 323 update_option( 'use_smilies', 0 ); 324 } 325 326 /** 327 * Data provider. 328 * 329 * @return array { 330 * @type array { 331 * @type string $input Input content. 332 * @type string $converted Converted output. 333 * } 334 * } 335 */ 296 336 public function data_spaces_around_smilies() { 297 337 $nbsp = "\xC2\xA0";
Note: See TracChangeset
for help on using the changeset viewer.