Changeset 62207 for trunk/tests/phpunit/tests/unicode/wpScrubUtf8.php
- Timestamp:
- 04/04/2026 11:17:45 PM (5 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/unicode/wpScrubUtf8.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/unicode/wpScrubUtf8.php
r60793 r62207 1 1 <?php 2 2 3 /** 3 4 * Unit tests covering WordPress’ UTF-8 handling. … … 5 6 * @package WordPress 6 7 * @group unicode 8 * 9 * @covers ::wp_scrub_utf8 7 10 */ 8 9 class Tests_WpScrubUtf8 extends WP_UnitTestCase { 10 /** 11 * Verifies that WordPress can properly detect valid and invalid UTF-8. 12 * 13 * @ticket 63837 14 * 15 * @dataProvider data_utf8_test_data 16 * 17 * @param string $bytes Bytes as a PHP string. 18 * @param string|null $scrubbed Expected checked value, if string isn’t valid UTF-8. 19 */ 20 public function test_properly_checks_utf8( string $bytes, ?string $scrubbed = null ) { 21 if ( null === $scrubbed ) { 22 $this->assertSame( 23 $bytes, 24 wp_check_invalid_utf8( $bytes ), 25 'Should have returned the unchanged string for valid UTF-8 input when not stripping invalid bytes.' 26 ); 27 28 $this->assertSame( 29 $bytes, 30 wp_check_invalid_utf8( $bytes, true ), 31 'Should have returned the unchanged string for valid UTF-8 input when stripping invalid bytes.' 32 ); 33 } else { 34 $this->assertSame( 35 '', 36 wp_check_invalid_utf8( $bytes ), 37 'Should have rejected invalid input, returning an empty string when not stripping invalid bytes.' 38 ); 39 40 $this->assertSame( 41 $scrubbed, 42 wp_check_invalid_utf8( $bytes, true ), 43 'Failed to properly scrub the invalid spans of UTF-8 from the input string.' 44 ); 45 } 46 } 11 class Tests_Unicode_WpScrubUtf8 extends WP_UnitTestCase { 47 12 48 13 /** … … 83 48 * @param string|null $scrubbed Expected checked value, if string isn’t valid UTF-8. 84 49 */ 85 public function test_fallback_properly_ checks_utf8( string $bytes, ?string $scrubbed = null ) {50 public function test_fallback_properly_scrubs_utf8( string $bytes, ?string $scrubbed = null ) { 86 51 if ( null === $scrubbed ) { 87 52 $this->assertSame(
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)