appData = $this->createMock(IAppData::class); $this->l = $this->createMock(IL10N::class); $this->url = $this->createMock(IURLGenerator::class); $this->random = $this->createMock(ISecureRandom::class); $this->roomService = $this->createMock(RoomService::class); $this->avatarManager = $this->createMock(IAvatarManager::class); $this->emojiService = Server::get(EmojiService::class); $this->service = new AvatarService( $this->appData, $this->l, $this->url, $this->random, $this->roomService, $this->avatarManager, $this->emojiService, ); } public static function dataGetAvatarVersion(): array { return [ ['', 'STRING WITH 8 CHARS'], ['1', '1'], ['1.png', '1'], ]; } #[DataProvider('dataGetAvatarVersion')] public function testGetAvatarVersion(string $avatar, string $expected): void { /** @var Room&MockObject $room */ $room = $this->createMock(Room::class); $room->method('getAvatar') ->willReturn($avatar); $actual = $this->service->getAvatarVersion($room); if ($expected === 'STRING WITH 8 CHARS') { $this->assertEquals(8, strlen($actual)); } else { $this->assertEquals($expected, $actual); } } }