<?php

declare(strict_types=1);

namespace App\Tests\Unit\Shared\Domain;

use App\Shared\Domain\EntityId;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;

final class EntityIdTest extends TestCase
{
    public function testGenerateCreatesValidUuid(): void
    {
        $id = TestEntityId::generate();

        $this->assertInstanceOf(TestEntityId::class, $id);
        $this->assertTrue(Uuid::isValid((string) $id));
    }

    public function testFromStringCreatesEntityIdFromValidUuid(): void
    {
        $uuid = '550e8400-e29b-41d4-a716-446655440000';
        $id = TestEntityId::fromString($uuid);

        $this->assertSame($uuid, (string) $id);
    }

    public function testEqualsReturnsTrueForSameValue(): void
    {
        $uuid = '550e8400-e29b-41d4-a716-446655440000';
        $id1 = TestEntityId::fromString($uuid);
        $id2 = TestEntityId::fromString($uuid);

        $this->assertTrue($id1->equals($id2));
    }

    public function testEqualsReturnsFalseForDifferentValue(): void
    {
        $id1 = TestEntityId::generate();
        $id2 = TestEntityId::generate();

        $this->assertFalse($id1->equals($id2));
    }

    public function testToStringReturnsUuidString(): void
    {
        $uuid = '550e8400-e29b-41d4-a716-446655440000';
        $id = TestEntityId::fromString($uuid);

        $this->assertSame($uuid, (string) $id);
    }
}

// Test concrete implementation
final readonly class TestEntityId extends EntityId
{
}
