diff options
author | Joas Schilling <coding@schilljs.com> | 2023-05-02 16:27:11 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-05-02 16:27:11 +0200 |
commit | 3d28d93e175350eede30293cd475481bec6c865d (patch) | |
tree | 4dc446f5e45ef6235426685f56e100442233ebeb /tests/php | |
parent | 5e28cae6cc66bd11af0ed2893507bfeb3aadd17c (diff) |
feat(avatar): Use the first emoji of room names as avatar emoji
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/php')
-rw-r--r-- | tests/php/Service/AvatarServiceTest.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/php/Service/AvatarServiceTest.php b/tests/php/Service/AvatarServiceTest.php index 4219c6c87..ec4e185d8 100644 --- a/tests/php/Service/AvatarServiceTest.php +++ b/tests/php/Service/AvatarServiceTest.php @@ -26,6 +26,7 @@ declare(strict_types=1); namespace OCA\Talk\Tests\php\Service; +use OC\EmojiHelper; use OCA\Talk\Room; use OCA\Talk\Service\AvatarService; use OCA\Talk\Service\RoomService; @@ -61,13 +62,15 @@ class AvatarServiceTest extends TestCase { $this->random = $this->createMock(ISecureRandom::class); $this->roomService = $this->createMock(RoomService::class); $this->avatarManager = $this->createMock(IAvatarManager::class); + $this->emojiHelper = \OCP\Server::get(EmojiHelper::class); $this->service = new AvatarService( $this->appData, $this->l, $this->url, $this->random, $this->roomService, - $this->avatarManager + $this->avatarManager, + $this->emojiHelper, ); } @@ -91,4 +94,19 @@ class AvatarServiceTest extends TestCase { ['1.png', '1'], ]; } + + public function dataGetFirstCombinedEmoji(): array { + return [ + ['👋 Hello', '👋'], + ['Only leading emojis 🚀', ''], + ['👩🏽💻👩🏻💻👨🏿💻 Only one, but with all attributes', '👩🏽💻'], + ]; + } + + /** + * @dataProvider dataGetFirstCombinedEmoji + */ + public function testGetFirstCombinedEmoji(string $roomName, string $avatarEmoji): void { + $this->assertSame($avatarEmoji, self::invokePrivate($this->service, 'getFirstCombinedEmoji', [$roomName])); + } } |