Skip to content

Commit

Permalink
Fix message matching in RepeatTest::testNegativeRepeatedtimes
Browse files Browse the repository at this point in the history
PHP 8.4 has changed the format of __FUNCTION__ for closures, at least.
  • Loading branch information
redbeardcreator committed Dec 9, 2024
1 parent ebaacaa commit bdfef5f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/Functional/RepeatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ public function test(): void
public function testNegativeRepeatedTimes(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
'Functional\{closure}() expects parameter 1 to be positive integer, negative integer given'

// See https://3v4l.org/Ms79G for message formats
// See https://regex101.com/r/hTvW3o/1 for regex setup
$this->expectExceptionMessageMatches(
'/(Functional\\\\{closure}' // PHP < 8.4
. '|{closure:Functional\\\\repeat\(\):[0-9]+})' // PHP 8.4+
. '\(\) expects parameter 1 to be positive integer, negative integer given/'
);

repeat([$this->repeated, 'foo'])(-1);
Expand Down

0 comments on commit bdfef5f

Please sign in to comment.