Skip to content

Commit 5404426

Browse files
committed
Disable tests on older PHP versions with mb_strlen() bug.
1 parent 47c4c51 commit 5404426

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/phpunit/tests/compat/wpCodePointCount.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public function test_rejects_negative_byte_lengths() {
6060
public function test_counts_within_appropriate_offsets( string $text, int $byte_offset, int $byte_length ) {
6161
$substring = substr( $text, $byte_offset, $byte_length );
6262

63+
if (
64+
! mb_check_encoding( $substring, 'UTF-8' ) &&
65+
// Miscounting bug fixed by removal of “fast path” php/php-src@cca4ca6d3dda8c2e1c5c1b053550f94b3d6fb6bf
66+
version_compare( PHP_VERSION, '8.3.0', '<' )
67+
) {
68+
$this->markTestSkipped( 'Prior to PHP 8.3.0, mb_strlen() misreported lengths of invalid inputs.' );
69+
}
70+
6371
$this->assertSame(
6472
mb_strlen( $substring, 'UTF-8' ),
6573
_wp_utf8_codepoint_count( $text, $byte_offset, $byte_length ),

0 commit comments

Comments
 (0)