Skip to content

Commit

Permalink
Merge pull request #4241 from nextcloud/tests/testUsersIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored Jun 6, 2023
2 parents e9dc7b8 + 851528c commit 80bdef9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Controller/UserApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function index(int $documentId, int $sessionId, string $sessionToken, str
$sessionUserId = $session['userId'];
if ($sessionUserId !== null && !isset($users[$sessionUserId])) {
$displayName = $this->userManager->getDisplayName($sessionUserId);
if (stripos($displayName, $filter) !== false || stripos($sessionUserId, $filter) !== false) {
if ($displayName && stripos($displayName, $filter) !== false || stripos($sessionUserId, $filter) !== false) {
$users[$sessionUserId] = $displayName;
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/Controller/UserApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public function testUsersIndex(int $documentId, int $sessionId, string $sessionT
'userId' => 'admin',
'displayName' => 'admin',
]]);
$this->userManager->expects($this->once())
->method('getDisplayName')
->willReturn('Administrator');
$this->sessionService
->expects($this->once())
->method('getSession')->willReturn($session);
Expand Down

0 comments on commit 80bdef9

Please sign in to comment.