diff options
author | Joas Schilling <coding@schilljs.com> | 2022-08-18 09:57:34 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-08-19 12:06:20 +0200 |
commit | 659c2ba7ff5bad286f9ed3f456b5759b0906c8c6 (patch) | |
tree | 77bc132123e5f5e7fde0a7c4430efadf97495dc7 /tests/php | |
parent | 62c85c3c7ef888c43f34f568ac139a0885a0aa9f (diff) |
Use user displayname cache in activities
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/php')
-rw-r--r-- | tests/php/Activity/Provider/BaseTest.php | 59 |
1 files changed, 11 insertions, 48 deletions
diff --git a/tests/php/Activity/Provider/BaseTest.php b/tests/php/Activity/Provider/BaseTest.php index 7a598279a..9fc2bc7dc 100644 --- a/tests/php/Activity/Provider/BaseTest.php +++ b/tests/php/Activity/Provider/BaseTest.php @@ -254,44 +254,7 @@ class BaseTest extends TestCase { ], 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 @@ class BaseTest extends TestCase { } /** - * @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])); } } |