<?php

declare(strict_types=1);

namespace App\Tests\Mcp\Tool\Document;

use App\Tests\AbstractApiTestCase;

/**
 * @internal
 */
class DocumentToolsTest extends AbstractApiTestCase
{
    public function testListDocuments(): void
    {
        $site    = $this->createSite(name: 'Doc Site');
        $session = $this->createMcpClient('ROLE_VIEWER');

        $data = $this->callMcpTool($session, 'list_documents', [
            'entityType' => 'site',
            'entityId'   => $site->getId(),
        ]);

        $this->assertArrayHasKey('_parsed', $data);
        $this->assertSame('site', $data['_parsed']['entityType']);
        $this->assertSame($site->getId(), $data['_parsed']['entityId']);
        $this->assertIsArray($data['_parsed']['items']);
        $this->assertSame(0, $data['_parsed']['total']);
    }

    public function testDeleteDocumentRequiresGestionnaire(): void
    {
        $session = $this->createMcpClient('ROLE_VIEWER');

        $data = $this->callMcpTool($session, 'delete_document', [
            'documentId' => 'nonexistent-id',
        ]);

        $this->assertArrayHasKey('error', $data);
    }
}
