<?php

namespace App\Tests\Entity;

use App\Entity\Attestation;
use App\Entity\Event;
use App\Entity\User;
use PHPUnit\Framework\TestCase;

class AttestationTest extends TestCase
{
    public function testConstructorAndGetters(): void
    {
        $event = $this->createMock(Event::class);
        $user = $this->createMock(User::class);
        $payload = ['ticket_type' => 'VIP', 'count' => 5];

        $attestation = new Attestation(
            'REF-001',
            'hash123abc',
            $event,
            $user,
            150,
            $payload,
        );

        self::assertNull($attestation->getId());
        self::assertSame('REF-001', $attestation->getReference());
        self::assertSame('hash123abc', $attestation->getSignatureHash());
        self::assertSame($event, $attestation->getEvent());
        self::assertSame($user, $attestation->getGeneratedBy());
        self::assertSame(150, $attestation->getTotalSold());
        self::assertSame($payload, $attestation->getPayload());
        self::assertInstanceOf(\DateTimeImmutable::class, $attestation->getCreatedAt());
    }

    public function testEmptyPayload(): void
    {
        $event = $this->createMock(Event::class);
        $user = $this->createMock(User::class);

        $attestation = new Attestation(
            'REF-002',
            'hash456def',
            $event,
            $user,
            0,
            [],
        );

        self::assertSame([], $attestation->getPayload());
        self::assertSame(0, $attestation->getTotalSold());
    }
}
