SuperSeller3000/tests/Unit/Infrastructure/AI/Agent/OllamaVisionAgentTest.php
Simon Kuehn fddfd920f5 feat: add Symfony Messenger pipeline with AI agents and handlers
Messages and handlers for the full AI pipeline:
DraftArticle → Validation → SpecsResearch → PhotoUpload → EbayText →
JsonCoding → PublishToChannel / DeactivateListingMessage / TrackingPush /
UpdateStockOnChannels / OrderReceived.

OllamaClient and OllamaClientInterface provide the base LLM backend.
AI agents (EbayTextAgent, JsonCodingAgent, OllamaVisionAgent,
SpecsResearchAgent) wrap the client with task-specific prompts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 22:43:47 +00:00

44 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Unit\Infrastructure\AI\Agent;
use App\Infrastructure\AI\Agent\OllamaVisionAgent;
use App\Infrastructure\AI\OllamaClientInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
final class OllamaVisionAgentTest extends TestCase
{
private OllamaClientInterface&MockObject $ollama;
private OllamaVisionAgent $agent;
protected function setUp(): void
{
$this->ollama = $this->createMock(OllamaClientInterface::class);
$this->agent = new OllamaVisionAgent($this->ollama, 'llava');
}
public function testParsesModelAndSerialFromResponse(): void
{
$this->ollama->method('generateWithImage')
->willReturn("MODEL: Dell Latitude 5520\nSERIAL: ABC12345");
$result = $this->agent->analyze('/tmp/photo.jpg');
self::assertSame('Dell Latitude 5520', $result['model']);
self::assertSame('ABC12345', $result['serial']);
}
public function testReturnsEmptyStringsWhenNotFound(): void
{
$this->ollama->method('generateWithImage')
->willReturn('I cannot read the nameplate clearly.');
$result = $this->agent->analyze('/tmp/photo.jpg');
self::assertSame('', $result['model']);
self::assertSame('', $result['serial']);
}
}