diff options
author | Joas Schilling <coding@schilljs.com> | 2022-08-18 09:58:42 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-08-19 12:06:21 +0200 |
commit | e32de5d5f9ea86cc66dbd472b0aee09fc81f7113 (patch) | |
tree | 961e7d37ea0577753442382fe5d7ad36fca64954 /tests/php | |
parent | 1c29d7714f899b44507306dd4b3b05e0c4e02dfc (diff) |
Use user displayname cache in autocomplete search
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/php')
-rw-r--r-- | tests/php/Chat/AutoComplete/SearchPluginTest.php | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/tests/php/Chat/AutoComplete/SearchPluginTest.php b/tests/php/Chat/AutoComplete/SearchPluginTest.php index a88a0c605..d60d1ee8c 100644 --- a/tests/php/Chat/AutoComplete/SearchPluginTest.php +++ b/tests/php/Chat/AutoComplete/SearchPluginTest.php @@ -167,13 +167,13 @@ class SearchPluginTest extends TestCase { 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 @@ class SearchPluginTest extends TestCase { 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 @@ class SearchPluginTest extends TestCase { 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); } |