summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-05-02 22:34:52 +0200
committerGitHub <noreply@github.com>2023-05-02 22:34:52 +0200
commitbcea5d70afaed5d1b492837e294cc4a1db6520dc (patch)
tree75844c2ecbb647d363be674fc560b4904d3d3ade /tests
parentc4fee5eec162fc146c9000f171ea4d4273fc70de (diff)
parent9db415f2c5caa902f9ec970c4224cc0290039724 (diff)
Merge pull request #9424 from nextcloud/feat/8444/populate-emoji-from-roomname-as-avatar
feat(avatar): Use the first emoji of room names as avatar emoji
Diffstat (limited to 'tests')
-rw-r--r--tests/php/Service/AvatarServiceTest.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/php/Service/AvatarServiceTest.php b/tests/php/Service/AvatarServiceTest.php
index 4219c6c87..97cfc80fe 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;
@@ -34,6 +35,7 @@ use OCP\IAvatarManager;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Security\ISecureRandom;
+use OCP\Server;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -51,6 +53,8 @@ class AvatarServiceTest extends TestCase {
private $roomService;
/** @var IAvatarManager|MockObject */
private $avatarManager;
+ /** @var EmojiHelper|MockObject */
+ private $emojiHelper;
public function setUp(): void {
parent::setUp();
@@ -61,13 +65,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 = 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 +97,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]));
+ }
}