From 55043b4339cf540d239e38df1fdba9641ab88d16 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 30 Oct 2024 19:23:19 +0100 Subject: [PATCH] [Tests] Aligned RepositoryUserAuthenticationSubscriberTest with Symfony 6 --- .../RepositoryUserAuthenticationSubscriberTest.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/RepositoryUserAuthenticationSubscriberTest.php b/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/RepositoryUserAuthenticationSubscriberTest.php index cbcc38092b..4aa9d3223a 100644 --- a/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/RepositoryUserAuthenticationSubscriberTest.php +++ b/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/RepositoryUserAuthenticationSubscriberTest.php @@ -13,13 +13,13 @@ use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Core\MVC\Symfony\Security\Authentication\EventSubscriber\RepositoryUserAuthenticationSubscriber; use Ibexa\Core\MVC\Symfony\Security\User; +use Ibexa\Core\MVC\Symfony\Security\UserInterface as IbexaUserInterface; use Ibexa\Core\Repository\User\Exception\UnsupportedPasswordHashType; use Ibexa\Core\Repository\Values\User\User as APIUser; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials; @@ -148,7 +148,7 @@ private function getSubscriber( } private function getCheckPassportEvent( - ?UserInterface $user = null, + ?User $user = null, ?Passport $passport = null, ): CheckPassportEvent { $authenticator = $this->createMock(AuthenticatorInterface::class); @@ -158,12 +158,15 @@ private function getCheckPassportEvent( $userProvider = $this->createMock(User\APIUserProviderInterface::class); $userProvider ->expects(self::once()) - ->method('loadUserByUsername') + ->method('loadUserByIdentifier') ->willReturn($user); $passport = new Passport( - new UserBadge($user->getUsername(), [$userProvider, 'loadUserByUsername']), - new PasswordCredentials($user->getPassword() ?? '') + new UserBadge( + $user->getUserIdentifier(), + static fn (string $userIdentifier): IbexaUserInterface => $userProvider->loadUserByIdentifier($userIdentifier) + ), + new PasswordCredentials($user->getPassword()) ); }