- Timestamp:
- 04/04/2026 11:17:45 PM (5 months ago)
- File:
-
- 1 copied
-
trunk/tests/phpunit/tests/unicode/wpCheckInvalidUtf8.php (copied) (copied from trunk/tests/phpunit/tests/unicode/wpScrubUtf8.php ) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/unicode/wpCheckInvalidUtf8.php
r60796 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_check_invalid_utf8 7 10 */ 11 class Tests_Unicode_WpCheckInvalidUtf8 extends WP_UnitTestCase { 8 12 9 class Tests_WpScrubUtf8 extends WP_UnitTestCase {10 13 /** 11 14 * Verifies that WordPress can properly detect valid and invalid UTF-8. … … 41 44 $scrubbed, 42 45 wp_check_invalid_utf8( $bytes, true ), 43 'Failed to properly scrub the invalid spans of UTF-8 from the input string.'44 );45 }46 }47 48 /**49 * Verifies that WordPress can properly detect valid UTF-8 while replacing invalid byte sequences.50 *51 * @ticket 6383752 *53 * @dataProvider data_utf8_test_data54 *55 * @param string $bytes Bytes as a PHP string.56 * @param string|null $scrubbed Expected checked value, if string isn’t valid UTF-8.57 */58 public function test_properly_scrubs_utf8( string $bytes, ?string $scrubbed = null ) {59 if ( null === $scrubbed ) {60 $this->assertSame(61 $bytes,62 wp_scrub_utf8( $bytes ),63 'Should have returned the unchanged string for valid UTF-8 input.'64 );65 } else {66 $this->assertSame(67 bin2hex( $scrubbed ),68 bin2hex( wp_scrub_utf8( $bytes ) ),69 'Failed to properly scrub the invalid spans of UTF-8 from the input string.'70 );71 }72 }73 74 /**75 * Verifies that WordPress’ fallback code can properly detect valid UTF-876 * while replacing invalid byte sequences.77 *78 * @ticket 6383779 *80 * @dataProvider data_utf8_test_data81 *82 * @param string $bytes Bytes as a PHP string.83 * @param string|null $scrubbed Expected checked value, if string isn’t valid UTF-8.84 */85 public function test_fallback_properly_checks_utf8( string $bytes, ?string $scrubbed = null ) {86 if ( null === $scrubbed ) {87 $this->assertSame(88 $bytes,89 _wp_scrub_utf8_fallback( $bytes ),90 'Should have returned the unchanged string for valid UTF-8 input.'91 );92 } else {93 $this->assertSame(94 bin2hex( $scrubbed ),95 bin2hex( _wp_scrub_utf8_fallback( $bytes ) ),96 46 'Failed to properly scrub the invalid spans of UTF-8 from the input string.' 97 47 );
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)