summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-08-18 09:58:04 +0200
committerJoas Schilling <coding@schilljs.com>2022-08-19 12:06:20 +0200
commitfa2dfc51e6d4f75950f777bb7b2d607004c1f2f7 (patch)
tree361f7dfa5b6c782c3f016ff8c77885910547fc94 /tests
parent659c2ba7ff5bad286f9ed3f456b5759b0906c8c6 (diff)
Use user displayname cache in mention rendering
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/php/Chat/Parser/UserMentionTest.php33
1 files changed, 20 insertions, 13 deletions
diff --git a/tests/php/Chat/Parser/UserMentionTest.php b/tests/php/Chat/Parser/UserMentionTest.php
index e72afeed2..b52611b1f 100644
--- a/tests/php/Chat/Parser/UserMentionTest.php
+++ b/tests/php/Chat/Parser/UserMentionTest.php
@@ -97,7 +97,7 @@ class UserMentionTest extends TestCase {
$this->assertEquals([], $chatMessage->getMessageParameters());
}
- public function testGetRichMessageWithSingleMention() {
+ public function testGetRichMessageWithSingleMention(): void {
$mentions = [
['type' => 'user', 'id' => 'testUser'],
];
@@ -109,9 +109,9 @@ class UserMentionTest extends TestCase {
->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 +148,9 @@ class UserMentionTest extends TestCase {
->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 +210,15 @@ class UserMentionTest extends TestCase {
});
$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 +274,17 @@ class UserMentionTest extends TestCase {
);
$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 +332,10 @@ class UserMentionTest extends TestCase {
->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 +372,9 @@ class UserMentionTest extends TestCase {
->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);