diff --git a/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php index 31018aec..2e01c7db 100644 --- a/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php +++ b/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php @@ -197,10 +197,15 @@ public function testFailurePathFromRequestWithInvalidUrl() $this->logger->expects($this->exactly(2)) ->method('debug') - ->withConsecutive( - ['Ignoring query parameter "_my_failure_path": not a valid URL.'], - ['Authentication failure, redirect triggered.', ['failure_path' => '/login']] - ); + ->willReturnCallback(function (...$args) { + static $series = [ + ['Ignoring query parameter "_my_failure_path": not a valid URL.', []], + ['Authentication failure, redirect triggered.', ['failure_path' => '/login']], + ]; + + $expectedArgs = array_shift($series); + $this->assertSame($expectedArgs, $args); + }); $handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, $options, $this->logger); diff --git a/Tests/EventListener/PasswordMigratingListenerTest.php b/Tests/EventListener/PasswordMigratingListenerTest.php index 70725c20..6fc48b7a 100644 --- a/Tests/EventListener/PasswordMigratingListenerTest.php +++ b/Tests/EventListener/PasswordMigratingListenerTest.php @@ -85,7 +85,19 @@ public function testUnsupportedPassport() // A custom Passport, without an UserBadge $passport = $this->createMock(UserPassportInterface::class); $passport->method('getUser')->willReturn($this->user); - $passport->method('hasBadge')->withConsecutive([PasswordUpgradeBadge::class], [UserBadge::class])->willReturnOnConsecutiveCalls(true, false); + $passport->method('hasBadge') + ->willReturnCallback(function (...$args) { + static $series = [ + [[PasswordUpgradeBadge::class], true], + [[UserBadge::class], false], + ]; + + [$expectedArgs, $return] = array_shift($series); + $this->assertSame($expectedArgs, $args); + + return $return; + }) + ; $passport->expects($this->once())->method('getBadge')->with(PasswordUpgradeBadge::class)->willReturn(new PasswordUpgradeBadge('pa$$word')); // We should never "getBadge" for "UserBadge::class" diff --git a/Tests/LoginLink/LoginLinkHandlerTest.php b/Tests/LoginLink/LoginLinkHandlerTest.php index 0d698362..6574a684 100644 --- a/Tests/LoginLink/LoginLinkHandlerTest.php +++ b/Tests/LoginLink/LoginLinkHandlerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Security\Http\Tests\LoginLink; +use PHPUnit\Framework\Constraint\Constraint; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemPoolInterface; @@ -80,9 +81,22 @@ public function testCreateLoginLink($user, array $extraProperties, Request $requ ->method('getContext') ->willReturn($currentRequestContext = new RequestContext()); + $series = [ + $this->equalTo((new RequestContext())->fromRequest($request)->setParameter('_locale', $request->getLocale())), + $currentRequestContext, + ]; + $this->router->expects($this->exactly(2)) ->method('setContext') - ->withConsecutive([$this->equalTo((new RequestContext())->fromRequest($request)->setParameter('_locale', $request->getLocale()))], [$currentRequestContext]); + ->willReturnCallback(function (RequestContext $context) use (&$series) { + $expectedContext = array_shift($series); + + if ($expectedContext instanceof Constraint) { + $expectedContext->evaluate($context); + } else { + $this->assertSame($expectedContext, $context); + } + }); } $loginLink = $this->createLinker([], array_keys($extraProperties))->createLoginLink($user, $request);