userManager = $this->createMock(IUserManager::class); $this->controller = new UserController( 'core', $this->createMock(IRequest::class), $this->userManager ); } public function testGetDisplayNames(): void { $user = $this->createMock(IUser::class); $user->method('getDisplayName') ->willReturn('FooDisplay Name'); $this->userManager ->method('get') ->willReturnCallback(function ($uid) use ($user) { if ($uid === 'foo') { return $user; } return null; }); $expected = new JSONResponse([ 'users' => [ 'foo' => 'FooDisplay Name', 'bar' => 'bar', ], 'status' => 'success' ]); $result = $this->controller->getDisplayNames(['foo', 'bar']); $this->assertEquals($expected, $result); } }