Changeset 55563
- Timestamp:
- 03/19/2023 12:51:14 PM (18 months ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r55495 r55563 5338 5338 5339 5339 /** 5340 * Adds a Target attribute to all links in passed content.5340 * Adds a target attribute to all links in passed content. 5341 5341 * 5342 5342 * This function by default only applies to `<a>` tags, however this can be 5343 * modified by the 3rd param.5344 * 5345 * *NOTE:* Any current target attribute dwill be stripped and replaced.5343 * modified by the `$tags` parameter. 5344 * 5345 * *NOTE:* Any current target attribute will be stripped and replaced. 5346 5346 * 5347 5347 * @since 2.7.0 … … 5350 5350 * 5351 5351 * @param string $content String to search for links in. 5352 * @param string $target The Target to add to the links.5352 * @param string $target The target to add to the links. 5353 5353 * @param string[] $tags An array of tags to apply to. 5354 5354 * @return string The processed content. -
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"; -
trunk/tests/phpunit/tests/formatting/getUrlInContent.php
r55562 r55563 9 9 10 10 /** 11 * Validate the get_url_in_content function11 * Tests the get_url_in_content() function. 12 12 * 13 13 * @dataProvider data_get_url_in_content 14 14 */ 15 public function test_get_url_in_content( $in _str, $exp_str) {16 $this->assertSame( $exp _str, get_url_in_content( $in_str) );15 public function test_get_url_in_content( $input, $expected ) { 16 $this->assertSame( $expected, get_url_in_content( $input ) ); 17 17 } 18 18 19 19 /** 20 * URL Content Data Provider20 * Data provider. 21 21 * 22 * array ( input_txt, converted_output_txt ) 22 * @return array { 23 * @type array { 24 * @type string $input Input content. 25 * @type string $expected Expected output. 26 * } 27 * } 23 28 */ 24 29 public function data_get_url_in_content() { -
trunk/tests/phpunit/tests/formatting/linksAddTarget.php
r55562 r55563 8 8 9 9 /** 10 * Validate the normalize_whitespace function10 * Tests the links_add_target() function. 11 11 * 12 12 * @dataProvider data_links_add_target 13 13 */ 14 public function test_links_add_target( $content, $target, $tags, $exp _str) {15 if ( true ===is_null( $target ) ) {16 $this->assertSame( $exp _str, links_add_target( $content ) );17 } elseif ( true ===is_null( $tags ) ) {18 $this->assertSame( $exp _str, links_add_target( $content, $target ) );14 public function test_links_add_target( $content, $target, $tags, $expected ) { 15 if ( is_null( $target ) ) { 16 $this->assertSame( $expected, links_add_target( $content ) ); 17 } elseif ( is_null( $tags ) ) { 18 $this->assertSame( $expected, links_add_target( $content, $target ) ); 19 19 } else { 20 $this->assertSame( $exp _str, links_add_target( $content, $target, $tags ) );20 $this->assertSame( $expected, links_add_target( $content, $target, $tags ) ); 21 21 } 22 22 } 23 23 24 24 /** 25 * Test Content DataProvider25 * Data provider. 26 26 * 27 * array ( input_txt, converted_output_txt) 27 * @return array { 28 * @type array { 29 * @type string $content String to search for links in. 30 * @type string $target The target to add to the links. 31 * @type string $tags An array of tags to apply to. 32 * @type string $expected Expected output. 33 * } 34 * } 28 35 */ 29 36 public function data_links_add_target() { -
trunk/tests/phpunit/tests/formatting/normalizeWhitespace.php
r55562 r55563 8 8 9 9 /** 10 * Validate the normalize_whitespace function10 * Tests the the normalize_whitespace() function. 11 11 * 12 12 * @dataProvider data_normalize_whitespace 13 13 */ 14 public function test_normalize_whitespace( $in _str, $exp_str) {15 $this->assertSame( $exp _str, normalize_whitespace( $in_str) );14 public function test_normalize_whitespace( $input, $expected ) { 15 $this->assertSame( $expected, normalize_whitespace( $input ) ); 16 16 } 17 17 18 18 /** 19 * WhitespaceTest Content DataProvider19 * Data provider. 20 20 * 21 * array( input_txt, converted_output_txt) 21 * @return array { 22 * @type array { 23 * @type string $input Input content. 24 * @type string $expected Expected output. 25 * } 26 * } 22 27 */ 23 28 public function data_normalize_whitespace() { -
trunk/tests/phpunit/tests/formatting/urlencodeDeep.php
r55562 r55563 10 10 11 11 /** 12 * Data Provider 12 * Tests the urlencode_deep() function pair by pair. 13 * 14 * @dataProvider data_urlencode_deep 15 * 16 * @param string $input 17 * @param string $expected 18 */ 19 public function test_urlencode_deep_should_encode_individual_value( $input, $expected ) { 20 $this->assertSame( $expected, urlencode_deep( $input ) ); 21 } 22 23 /** 24 * Data provider. 13 25 */ 14 26 public function data_urlencode_deep() { … … 23 35 24 36 /** 25 * Validate the urlencode_deep function pair by pair 26 * 27 * @dataProvider data_urlencode_deep 28 * 29 * @param string $actual 30 * @param string $expected 31 */ 32 public function test_urlencode_deep_should_encode_individual_value( $actual, $expected ) { 33 $this->assertSame( $expected, urlencode_deep( $actual ) ); 34 } 35 36 /** 37 * Test the whole array as input 37 * Tests the whole array as input. 38 38 */ 39 39 public function test_urlencode_deep_should_encode_all_values_in_array() { -
trunk/tests/phpunit/tests/formatting/wpParseStr.php
r54728 r55563 25 25 26 26 /** 27 * Data Provider.27 * Data provider. 28 28 * 29 29 * @return array -
trunk/tests/phpunit/tests/kses.php
r55562 r55563 948 948 949 949 /** 950 * Data Provider for test_safecss_filter_attr().950 * Data provider for test_safecss_filter_attr(). 951 951 * 952 952 * @return array { … … 1581 1581 1582 1582 /** 1583 * Data Provider for test_safecss_filter_attr_filtered().1583 * Data provider for test_safecss_filter_attr_filtered(). 1584 1584 * 1585 1585 * @return array { -
trunk/tests/phpunit/tests/pluggable/wpRand.php
r54702 r55563 21 21 0, 22 22 wp_rand( $min, $max ), 23 'The value was not greater than or equal 0'23 'The value was not greater than or equal to 0' 24 24 ); 25 25
Note: See TracChangeset
for help on using the changeset viewer.