Skip to content

Commit

Permalink
Merge pull request #478 from defuse/fix-php8-tests
Browse files Browse the repository at this point in the history
Skip a test of substr for PHP 8 and above because the behavior changed
  • Loading branch information
defuse authored Apr 9, 2021
2 parents 2a693cb + 54f79a1 commit aef1bd4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/unit/CoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ public function testOurSubstrOutOfBorders()
// See: https://secure.php.net/manual/en/function.mb-substr.php#50275

// We want to be like substr, so confirm that behavior.
$this->assertSame(
false,
substr('abc', 5, 2)
);
if (PHP_VERSION_ID < 80000) {
// In PHP 8.0, substr starts returning '' instead of the empty string.
// Core::ourSubstr should behave the OLD way.
$this->assertSame(
false,
substr('abc', 5, 2)
);
}

// Confirm that mb_substr does not have that behavior.
if (function_exists('mb_substr')) {
Expand Down

0 comments on commit aef1bd4

Please sign in to comment.