Files
nc-talk-ai/tests/unit/Service/AttachmentResolverTest.php
Pascal Kienast 0739d3da6a Initial open-source release of Talk AI
Talk AI is a multi-bot AI assistant manager for Nextcloud Talk:
per-bot prompts and models, agentic tool calling (MCP + built-in
tools), RAG over Nextcloud files, room-document search, vision and
speech-to-text attachments, persistent bot wikis, approval workflows,
rate limiting, and multi-provider LLM support (any OpenAI-compatible
endpoint).

Developed within EDUC - the European Digital UniverCity
(https://educalliance.eu), where it runs as the 'EDUC AI' assistant on
the alliance-wide Nextcloud portal. This public repository is the
upstream point of truth; deployment-specific tools plug in via the
tool-provider extension point (docs/TOOL_PROVIDERS.md).

License: AGPL-3.0-or-later.
2026-07-08 21:13:13 +02:00

58 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\EducAI\Tests\Unit\Service;
use OCA\EducAI\Service\AttachmentResolver;
use OCA\EducAI\Webhook\IncomingTalkAttachment;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Http\Client\IClientService;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
class AttachmentResolverTest extends TestCase {
public function testResolveSourceFileFallsBackToOwnerTalkFolderPath(): void {
$rootFolder = $this->createMock(IRootFolder::class);
$userFolder = $this->createMock(Folder::class);
$file = $this->createMock(File::class);
$rootFolder->expects($this->once())
->method('getById')
->with(1512)
->willReturn([]);
$rootFolder->expects($this->once())
->method('getUserFolder')
->with('admin')
->willReturn($userFolder);
$userFolder->expects($this->once())
->method('get')
->with('Talk/2025_03_03_EDUC_THINK_LAB_ThomasRoese_TR96206.jpg')
->willReturn($file);
$resolver = new AttachmentResolver(
$rootFolder,
$this->createMock(IClientService::class),
$this->createMock(LoggerInterface::class)
);
$attachment = new IncomingTalkAttachment(
IncomingTalkAttachment::KIND_IMAGE,
'file',
'image/jpeg',
'2025_03_03_EDUC_THINK_LAB_ThomasRoese_TR96206.jpg',
'file',
[
'id' => '1512',
'path' => '2025_03_03_EDUC_THINK_LAB_ThomasRoese_TR96206.jpg',
'_educai_owner_uid' => 'admin',
]
);
$this->assertSame($file, $resolver->resolveSourceFile($attachment));
}
}