diff --git a/test/FlashMessageMiddlewareTest.php b/test/FlashMessageMiddlewareTest.php index 52b6580..59e0fc4 100644 --- a/test/FlashMessageMiddlewareTest.php +++ b/test/FlashMessageMiddlewareTest.php @@ -83,7 +83,7 @@ public function testProcessUsesConfiguredClassAndSessionKeyAndAttributeKeyToCrea self::assertSame('non-standard-flash-next', $flash->sessionKey); return true; }) - )->will(self::returnSelf()); + )->willReturnSelf(); $response = $this->createMock(ResponseInterface::class); diff --git a/test/FlashMessagesTest.php b/test/FlashMessagesTest.php index 98ad718..2638a7d 100644 --- a/test/FlashMessagesTest.php +++ b/test/FlashMessagesTest.php @@ -194,6 +194,10 @@ public function testProlongFlashAddsCurrentMessagesToNextSession(): void ], ]; + $invocationCounter = new class { + public int $count = 0; + }; + $this->session ->expects(self::once()) ->method('has') @@ -207,7 +211,15 @@ public function testProlongFlashAddsCurrentMessagesToNextSession(): void return true; })) - ->willReturnOnConsecutiveCalls($messages, []); + ->willReturnCallback(static function () use ($messages, $invocationCounter) { + $invocationCounter->count += 1; + + if ($invocationCounter->count === 1) { + return $messages; + } + + return []; + }); $this->session ->expects(self::once()) ->method('unset') @@ -262,6 +274,10 @@ public function testProlongFlashDoesNotReFlashMessagesThatAlreadyHaveMoreHops(): $messagesExpected['test']['hops'] = 2; $messagesExpected['test-2']['hops'] = 1; + $invocationCounter = new class { + public int $count = 0; + }; + $this->session ->expects(self::once()) ->method('has') @@ -274,7 +290,15 @@ public function testProlongFlashDoesNotReFlashMessagesThatAlreadyHaveMoreHops(): self::identicalTo(FlashMessagesInterface::FLASH_NEXT), self::callback(fn ($arg): bool => in_array($arg, [null, []], true)), ) - ->willReturnOnConsecutiveCalls($messages, $messagesExpected); + ->willReturnCallback(static function () use ($messagesExpected, $messages, $invocationCounter) { + $invocationCounter->count += 1; + + if ($invocationCounter->count === 1) { + return $messages; + } + + return $messagesExpected; + }); $this->session ->expects(self::once()) ->method('set')