diff --git a/lib/Activity/Provider/Base.php b/lib/Activity/Provider/Base.php index f1cc6c499e5..0bb75b57c1b 100644 --- a/lib/Activity/Provider/Base.php +++ b/lib/Activity/Provider/Base.php @@ -43,9 +43,6 @@ abstract class Base implements IProvider { protected IUserManager $userManager; protected Manager $manager; - /** @var string[] */ - protected array $displayNames = []; - public function __construct(IFactory $languageFactory, IURLGenerator $url, Config $config, @@ -134,22 +131,10 @@ protected function getFormerRoom(IL10N $l, int $roomId): array { } protected function getUser(string $uid): array { - if (!isset($this->displayNames[$uid])) { - $this->displayNames[$uid] = $this->getDisplayName($uid); - } - return [ 'type' => 'user', 'id' => $uid, - 'name' => $this->displayNames[$uid], + 'name' => $this->userManager->getDisplayName($uid) ?? $uid, ]; } - - protected function getDisplayName(string $uid): string { - $user = $this->userManager->get($uid); - if ($user instanceof IUser) { - return $user->getDisplayName(); - } - return $uid; - } } diff --git a/lib/Chat/AutoComplete/SearchPlugin.php b/lib/Chat/AutoComplete/SearchPlugin.php index 9cabe3e853b..1ca840db782 100644 --- a/lib/Chat/AutoComplete/SearchPlugin.php +++ b/lib/Chat/AutoComplete/SearchPlugin.php @@ -33,7 +33,6 @@ use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\IL10N; -use OCP\IUser; use OCP\IUserManager; class SearchPlugin implements ISearchPlugin { @@ -139,18 +138,18 @@ protected function searchUsers(string $search, array $userIds, ISearchResult $se continue; } - $user = $this->userManager->get($userId); - if (!$user instanceof IUser) { + $userDisplayName = $this->userManager->getDisplayName($userId); + if ($userDisplayName === null) { continue; } - if (strtolower($user->getDisplayName()) === $search) { - $exactMatches[] = $this->createResult('user', $user->getUID(), $user->getDisplayName()); + if (strtolower($userDisplayName) === $search) { + $exactMatches[] = $this->createResult('user', $userId, $userDisplayName); continue; } - if (stripos($user->getDisplayName(), $search) !== false) { - $matches[] = $this->createResult('user', $user->getUID(), $user->getDisplayName()); + if (stripos($userDisplayName, $search) !== false) { + $matches[] = $this->createResult('user', $userId, $userDisplayName); continue; } } @@ -207,12 +206,7 @@ protected function searchGuests(string $search, array $attendees, ISearchResult protected function createResult(string $type, string $uid, string $name): array { if ($type === 'user' && $name === '') { - $user = $this->userManager->get($uid); - if ($user instanceof IUser) { - $name = $user->getDisplayName(); - } else { - $name = $uid; - } + $name = $this->userManager->getDisplayName($uid) ?? $uid; } return [ diff --git a/lib/Chat/Notifier.php b/lib/Chat/Notifier.php index 5874d05bf0f..3f048c05668 100644 --- a/lib/Chat/Notifier.php +++ b/lib/Chat/Notifier.php @@ -467,11 +467,11 @@ protected function shouldMentionedUserBeNotified(string $userId, IComment $comme // so they can see the room in their room list and // the notification can be parsed and links to an existing room, // where they are a participant of. - $user = $this->userManager->get($userId); + $userDisplayName = $this->userManager->getDisplayName($userId); $this->participantService->addUsers($room, [[ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $userId, - 'displayName' => $user ? $user->getDisplayName() : $userId, + 'displayName' => $userDisplayName ?? $userId, ]]); return true; } diff --git a/lib/Chat/Parser/UserMention.php b/lib/Chat/Parser/UserMention.php index 531dbd037da..4c4ba060e0b 100644 --- a/lib/Chat/Parser/UserMention.php +++ b/lib/Chat/Parser/UserMention.php @@ -31,7 +31,6 @@ use OCA\Talk\Room; use OCP\Comments\ICommentsManager; use OCP\IL10N; -use OCP\IUser; use OCP\IUserManager; /** @@ -91,8 +90,8 @@ public function parseMessage(Message $chatMessage): void { } if ($mention['type'] === 'user') { - $user = $this->userManager->get($mention['id']); - if (!$user instanceof IUser) { + $userDisplayName = $this->userManager->getDisplayName($mention['id']); + if ($userDisplayName === null) { continue; } } diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php index f55b62bc73a..5be4ae1485b 100644 --- a/lib/Controller/CallController.php +++ b/lib/Controller/CallController.php @@ -36,7 +36,6 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IRequest; -use OCP\IUser; use OCP\IUserManager; class CallController extends AEnvironmentAwareController { @@ -78,9 +77,9 @@ public function getPeersForCall(): DataResponse { if ($participant->getAttendee()->getDisplayName()) { $displayName = $participant->getAttendee()->getDisplayName(); } else { - $user = $this->userManager->get($participant->getAttendee()->getActorId()); - if ($user instanceof IUser) { - $displayName = $user->getDisplayName(); + $userDisplayName = $this->userManager->getDisplayName($participant->getAttendee()->getActorId()); + if ($userDisplayName !== null) { + $displayName = $userDisplayName; } } } else { diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 49e2e7a89fb..9f3e0fc85fd 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -1011,11 +1011,11 @@ public function getParticipants(bool $includeStatus = false): DataResponse { $result['displayName'] = $participant->getAttendee()->getDisplayName(); if (!$result['displayName']) { - $user = $this->userManager->get($userId); - if (!$user instanceof IUser) { + $userDisplayName = $this->userManager->getDisplayName($userId); + if ($userDisplayName === null) { continue; } - $result['displayName'] = $user->getDisplayName(); + $result['displayName'] = $userDisplayName; } if (isset($statuses[$userId])) { diff --git a/lib/Manager.php b/lib/Manager.php index f72fc5c5b1b..1e2798ee04d 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -1002,8 +1002,8 @@ public function resolveRoomDisplayName(Room $room, string $userId): string { } if ($otherParticipant === '' && $room->getName() !== '') { - $user = $this->userManager->get($room->getName()); - $otherParticipant = $user instanceof IUser ? $user->getDisplayName() : $this->l->t('Deleted user (%s)', $room->getName()); + $userDisplayName = $this->userManager->getDisplayName($room->getName()); + $otherParticipant = $userDisplayName ?? $this->l->t('Deleted user (%s)', $room->getName()); } return $otherParticipant; @@ -1054,8 +1054,7 @@ protected function getRoomNameByParticipants(Room $room): string { $displayNames = []; foreach ($users as $participantId) { - $user = $this->userManager->get($participantId); - $displayNames[] = $user instanceof IUser ? $user->getDisplayName() : $participantId; + $displayNames[] = $this->userManager->getDisplayName($participantId) ?? $participantId; } $roomName = implode(', ', $displayNames); diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 68af3211324..77dbcfaf537 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -332,13 +332,13 @@ protected function parseChatMessage(INotification $notification, Room $room, Par $isGuest = false; if ($subjectParameters['userType'] === 'users') { $userId = $subjectParameters['userId']; - $user = $this->userManager->get($userId); + $userDisplayName = $this->userManager->getDisplayName($userId); - if ($user instanceof IUser) { + if ($userDisplayName !== null) { $richSubjectUser = [ 'type' => 'user', 'id' => $userId, - 'name' => $user->getDisplayName(), + 'name' => $userDisplayName, ]; } } else { @@ -559,8 +559,8 @@ protected function parseInvitation(INotification $notification, Room $room, IL10 $parameters = $notification->getSubjectParameters(); $uid = $parameters['actorId'] ?? $parameters[0]; - $user = $this->userManager->get($uid); - if (!$user instanceof IUser) { + $userDisplayName = $this->userManager->getDisplayName($uid); + if ($userDisplayName === null) { throw new AlreadyProcessedException(); } @@ -574,13 +574,13 @@ protected function parseInvitation(INotification $notification, Room $room, IL10 } $notification - ->setParsedSubject(str_replace('{user}', $user->getDisplayName(), $subject)) + ->setParsedSubject(str_replace('{user}', $userDisplayName, $subject)) ->setRichSubject( $subject, [ 'user' => [ 'type' => 'user', 'id' => $uid, - 'name' => $user->getDisplayName(), + 'name' => $userDisplayName, ], 'call' => [ 'type' => 'call', @@ -599,13 +599,13 @@ protected function parseInvitation(INotification $notification, Room $room, IL10 } $notification - ->setParsedSubject(str_replace(['{user}', '{call}'], [$user->getDisplayName(), $roomName], $subject)) + ->setParsedSubject(str_replace(['{user}', '{call}'], [$userDisplayName, $roomName], $subject)) ->setRichSubject( $subject, [ 'user' => [ 'type' => 'user', 'id' => $uid, - 'name' => $user->getDisplayName(), + 'name' => $userDisplayName, ], 'call' => [ 'type' => 'call', @@ -639,8 +639,8 @@ protected function parseCall(INotification $notification, Room $room, IL10N $l): if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $parameters = $notification->getSubjectParameters(); $calleeId = $parameters['callee']; - $user = $this->userManager->get($calleeId); - if ($user instanceof IUser) { + $userDisplayName = $this->userManager->getDisplayName($calleeId); + if ($userDisplayName !== null) { if ($this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room)) { $notification = $this->addActionButton($notification, $l->t('Answer call')); $subject = $l->t('{user} would like to talk with you'); @@ -650,13 +650,13 @@ protected function parseCall(INotification $notification, Room $room, IL10N $l): } $notification - ->setParsedSubject(str_replace('{user}', $user->getDisplayName(), $subject)) + ->setParsedSubject(str_replace('{user}', $userDisplayName, $subject)) ->setRichSubject( $subject, [ 'user' => [ 'type' => 'user', 'id' => $calleeId, - 'name' => $user->getDisplayName(), + 'name' => $userDisplayName, ], 'call' => [ 'type' => 'call', diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index 852e33d7f84..9742c280579 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -680,12 +680,12 @@ public function ensureOneToOneRoomIsFilled(Room $room): void { $missingUsers = array_diff($users, $participants); foreach ($missingUsers as $userId) { - $user = $this->userManager->get($userId); - if ($user instanceof IUser) { + $userDisplayName = $this->userManager->getDisplayName($userId); + if ($userDisplayName !== null) { $this->addUsers($room, [[ 'actorType' => Attendee::ACTOR_USERS, - 'actorId' => $user->getUID(), - 'displayName' => $user->getDisplayName(), + 'actorId' => $userId, + 'displayName' => $userDisplayName, 'participantType' => Participant::OWNER, ]]); } diff --git a/tests/php/Activity/Provider/BaseTest.php b/tests/php/Activity/Provider/BaseTest.php index 7a598279ad5..9fc2bc7dcd1 100644 --- a/tests/php/Activity/Provider/BaseTest.php +++ b/tests/php/Activity/Provider/BaseTest.php @@ -254,44 +254,7 @@ public function testGetRoom($type, $id, $name, $expectedName, $expectedType) { ], self::invokePrivate($provider, 'getRoom', [$room, 'user'])); } - public function dataGetUser() { - return [ - ['test', [], false, 'Test'], - ['foo', ['admin' => 'Admin'], false, 'Bar'], - ['admin', ['admin' => 'Administrator'], true, 'Administrator'], - ]; - } - - /** - * @dataProvider dataGetUser - * - * @param string $uid - * @param array $cache - * @param bool $cacheHit - * @param string $name - */ - public function testGetUser($uid, $cache, $cacheHit, $name) { - $provider = $this->getProvider(['getDisplayName']); - - self::invokePrivate($provider, 'displayNames', [$cache]); - - if (!$cacheHit) { - $provider->expects($this->once()) - ->method('getDisplayName') - ->with($uid) - ->willReturn($name); - } else { - $provider->expects($this->never()) - ->method('getDisplayName'); - } - - $result = self::invokePrivate($provider, 'getUser', [$uid]); - $this->assertSame('user', $result['type']); - $this->assertSame($uid, $result['id']); - $this->assertSame($name, $result['name']); - } - - public function dataGetDisplayName() { + public function dataGetUser(): array { return [ ['test', true, 'Test'], ['foo', false, 'foo'], @@ -299,31 +262,31 @@ public function dataGetDisplayName() { } /** - * @dataProvider dataGetDisplayName + * @dataProvider dataGetUser * * @param string $uid * @param bool $validUser * @param string $name */ - public function testGetDisplayName($uid, $validUser, $name) { + public function testGetUser(string $uid, bool $validUser, string $name): void { $provider = $this->getProvider(); if ($validUser) { - $user = $this->createMock(IUser::class); - $user->expects($this->once()) - ->method('getDisplayName') - ->willReturn($name); $this->userManager->expects($this->once()) - ->method('get') + ->method('getDisplayName') ->with($uid) - ->willReturn($user); + ->willReturn($name); } else { $this->userManager->expects($this->once()) - ->method('get') + ->method('getDisplayName') ->with($uid) ->willReturn(null); } - $this->assertSame($name, self::invokePrivate($provider, 'getDisplayName', [$uid])); + $this->assertSame([ + 'type' => 'user', + 'id' => $uid, + 'name' => $name, + ], self::invokePrivate($provider, 'getUser', [$uid])); } } diff --git a/tests/php/Chat/AutoComplete/SearchPluginTest.php b/tests/php/Chat/AutoComplete/SearchPluginTest.php index a88a0c60559..d60d1ee8caa 100644 --- a/tests/php/Chat/AutoComplete/SearchPluginTest.php +++ b/tests/php/Chat/AutoComplete/SearchPluginTest.php @@ -167,13 +167,13 @@ public function dataSearchUsers() { return [ ['test', [], [], [], []], ['test', ['current', 'foo', 'test', 'test1'], [ - ['uid' => 'current', 'name' => 'test'], - ['uid' => 'test', 'name' => 'Te st'], - ['uid' => 'test1', 'name' => 'Te st 1'], + ['current', 'test'], + ['test', 'Te st'], + ['test1', 'Te st 1'], ], [['test1' => '']], [['test' => '']]], ['test', ['foo', 'bar'], [ - ['uid' => 'foo', 'name' => 'Test'], - ['uid' => 'bar', 'name' => 'test One'], + ['foo', 'Test'], + ['bar', 'test One'], ], [['bar' => 'test One']], [['foo' => 'Test']]], ['', ['foo', 'bar'], [ ], [['foo' => ''], ['bar' => '']], []], @@ -191,13 +191,9 @@ public function dataSearchUsers() { public function testSearchUsers($search, array $userIds, array $userNames, array $expected, array $expectedExact) { $result = $this->createMock(ISearchResult::class); - $userMap = array_map(function ($userData) { - return [$userData['uid'], $this->createUserMock($userData)]; - }, $userNames); - $this->userManager->expects($this->any()) - ->method('get') - ->willReturnMap($userMap); + ->method('getDisplayName') + ->willReturnMap($userNames); $result->expects($this->once()) ->method('addResultSet') @@ -286,12 +282,12 @@ public function dataCreateResult() { public function testCreateResult($type, $uid, $name, $managerName, array $expected) { if ($managerName !== null) { $this->userManager->expects($this->any()) - ->method('get') + ->method('getDisplayName') ->with($uid) - ->willReturn($this->createUserMock(['uid' => $uid, 'name' => $managerName])); + ->willReturn($managerName); } else { $this->userManager->expects($this->any()) - ->method('get') + ->method('getDisplayName') ->with($uid) ->willReturn(null); } diff --git a/tests/php/Chat/Parser/UserMentionTest.php b/tests/php/Chat/Parser/UserMentionTest.php index e72afeed228..9893a947b1a 100644 --- a/tests/php/Chat/Parser/UserMentionTest.php +++ b/tests/php/Chat/Parser/UserMentionTest.php @@ -34,7 +34,6 @@ use OCP\Comments\IComment; use OCP\Comments\ICommentsManager; use OCP\IL10N; -use OCP\IUser; use OCP\IUserManager; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -97,7 +96,7 @@ public function testGetRichMessageWithoutEnrichableReferences() { $this->assertEquals([], $chatMessage->getMessageParameters()); } - public function testGetRichMessageWithSingleMention() { + public function testGetRichMessageWithSingleMention(): void { $mentions = [ ['type' => 'user', 'id' => 'testUser'], ]; @@ -109,9 +108,9 @@ public function testGetRichMessageWithSingleMention() { ->willReturn('testUser display name'); $this->userManager->expects($this->once()) - ->method('get') + ->method('getDisplayName') ->with('testUser') - ->willReturn($this->createMock(IUser::class)); + ->willReturn('testUser display name'); /** @var Room|MockObject $room */ $room = $this->createMock(Room::class); @@ -148,9 +147,9 @@ public function testGetRichMessageWithDuplicatedMention() { ->willReturn('testUser display name'); $this->userManager->expects($this->once()) - ->method('get') + ->method('getDisplayName') ->with('testUser') - ->willReturn($this->createMock(IUser::class)); + ->willReturn('testUser display name'); /** @var Room|MockObject $room */ $room = $this->createMock(Room::class); @@ -210,12 +209,15 @@ public function testGetRichMessageWithMentionsFullyIncludedInOtherMentions(strin }); $this->userManager->expects($this->exactly(2)) - ->method('get') + ->method('getDisplayName') ->withConsecutive( [$longerId], [$baseId] ) - ->willReturn($this->createMock(IUser::class)); + ->willReturnOnConsecutiveCalls( + $longerId . ' display name', + $baseId . ' display name' + ); /** @var Room|MockObject $room */ $room = $this->createMock(Room::class); @@ -271,13 +273,17 @@ public function testGetRichMessageWithSeveralMentions() { ); $this->userManager->expects($this->exactly(3)) - ->method('get') + ->method('getDisplayName') ->withConsecutive( ['testUser1'], ['testUser2'], ['testUser3'] ) - ->willReturn($this->createMock(IUser::class)); + ->willReturnOnConsecutiveCalls( + 'testUser1 display name', + 'testUser2 display name', + 'testUser3 display name' + ); /** @var Room|MockObject $room */ $room = $this->createMock(Room::class); @@ -325,10 +331,10 @@ public function testGetRichMessageWithNonExistingUserMention() { ->willReturn('testUser display name'); $this->userManager->expects($this->exactly(2)) - ->method('get') + ->method('getDisplayName') ->willReturnMap([ ['me', null], - ['testUser', $this->createMock(IUser::class)], + ['testUser', 'testUser display name'], ]); /** @var Room|MockObject $room */ @@ -365,9 +371,9 @@ public function testGetRichMessageWhenDisplayNameCanNotBeResolved() { ->willThrowException(new \OutOfBoundsException()); $this->userManager->expects($this->once()) - ->method('get') + ->method('getDisplayName') ->with('testUser') - ->willReturn($this->createMock(IUser::class)); + ->willReturn('existing user but does not resolve later'); /** @var Room|MockObject $room */ $room = $this->createMock(Room::class); diff --git a/tests/php/Notification/NotifierTest.php b/tests/php/Notification/NotifierTest.php index 2192b3de988..2cf02639cc6 100644 --- a/tests/php/Notification/NotifierTest.php +++ b/tests/php/Notification/NotifierTest.php @@ -19,7 +19,7 @@ * */ -namespace OCA\Talk\Tests\php\Notifications; +namespace OCA\Talk\Tests\php\Notification; use OCA\FederatedFileSharing\AddressHandler; use OCA\Talk\Chat\CommentsManager; @@ -113,7 +113,7 @@ public function setUp(): void { ); } - public function dataPrepareOne2One() { + public function dataPrepareOne2One(): array { return [ ['admin', 'Admin', 'Admin invited you to a private conversation'], ['test', 'Test user', 'Test user invited you to a private conversation'], @@ -126,7 +126,7 @@ public function dataPrepareOne2One() { * @param string $displayName * @param string $parsedSubject */ - public function testPrepareOne2One($uid, $displayName, $parsedSubject) { + public function testPrepareOne2One(string $uid, string $displayName, string $parsedSubject): void { /** @var INotification|MockObject $n */ $n = $this->createMock(INotification::class); $l = $this->createMock(IL10N::class); @@ -158,20 +158,15 @@ public function testPrepareOne2One($uid, $displayName, $parsedSubject) { ->willReturn($l); $recipient = $this->createMock(IUser::class); - $u = $this->createMock(IUser::class); - $u->expects($this->exactly(2)) + $this->userManager->expects($this->once()) + ->method('get') + ->with('recipient') + ->willReturn($recipient); + + $this->userManager->expects($this->once()) ->method('getDisplayName') + ->with($uid) ->willReturn($displayName); - $this->userManager->expects($this->exactly(2)) - ->method('get') - ->withConsecutive( - ['recipient'], - [$uid] - ) - ->willReturnOnConsecutiveCalls( - $recipient, - $u - ); $n->expects($this->once()) ->method('setIcon') @@ -264,16 +259,15 @@ public function testPreparingMultipleTimesOnlyGetsTheRoomOnce($uid, $displayName ->willReturn($l); $recipient = $this->createMock(IUser::class); - $u = $this->createMock(IUser::class); - $u->expects($this->exactly($numNotifications * 2)) - ->method('getDisplayName') - ->willReturn($displayName); $this->userManager->expects($this->any()) ->method('get') - ->willReturnMap([ - ['recipient', $recipient], - [$uid, $u], - ]); + ->with('recipient') + ->willReturn($recipient); + + $this->userManager->expects($this->any()) + ->method('getDisplayName') + ->with($uid) + ->willReturn($displayName); $n = $this->getNotificationMock($parsedSubject, $uid, $displayName); $this->notifier->prepare($n, 'de'); @@ -315,7 +309,6 @@ public function getNotificationMock(string $parsedSubject, string $uid, string $ ]) ->willReturnSelf(); - $n->expects($this->exactly(2)) ->method('getUser') ->willReturn('recipient'); @@ -381,20 +374,15 @@ public function testPrepareGroup($type, $uid, $displayName, $name, $parsedSubjec ->willReturn($l); $recipient = $this->createMock(IUser::class); - $u = $this->createMock(IUser::class); - $u->expects($this->exactly(2)) + $this->userManager->expects($this->once()) + ->method('get') + ->with('recipient') + ->willReturn($recipient); + + $this->userManager->expects($this->once()) ->method('getDisplayName') + ->with($uid) ->willReturn($displayName); - $this->userManager->expects($this->exactly(2)) - ->method('get') - ->withConsecutive( - ['recipient'], - [$uid] - ) - ->willReturnOnConsecutiveCalls( - $recipient, - $u - ); $n->expects($this->once()) ->method('setIcon') @@ -902,27 +890,24 @@ public function testPrepareChatMessage(string $subject, int $roomType, array $su ->willReturn($l); $recipient = $this->createMock(IUser::class); - $userManagerGet['with'][] = ['recipient']; - $userManagerGet['willReturn'][] = $recipient; + $this->userManager->expects($this->once()) + ->method('get') + ->with('recipient') + ->willReturn($recipient); - $user = $this->createMock(IUser::class); + $userManagerGet = [ + 'with' => [], + 'willReturn' => [], + ]; if ($subjectParameters['userType'] === 'users' && !$deletedUser) { - $user->expects($this->once()) - ->method('getDisplayName') - ->willReturn($displayName); $userManagerGet['with'][] = [$subjectParameters['userId']]; - $userManagerGet['willReturn'][] = $user; + $userManagerGet['willReturn'][] = $displayName; } elseif ($subjectParameters['userType'] === 'users' && $deletedUser) { - $user->expects($this->never()) - ->method('getDisplayName'); $userManagerGet['with'][] = [$subjectParameters['userId']]; $userManagerGet['willReturn'][] = null; - } else { - $user->expects($this->never()) - ->method('getDisplayName'); } $this->userManager->expects($this->exactly(count($userManagerGet['with']))) - ->method('get') + ->method('getDisplayName') ->withConsecutive(...$userManagerGet['with']) ->willReturnOnConsecutiveCalls(...$userManagerGet['willReturn']);