<?php

namespace App\Tests\Entity;

use App\Entity\Service;
use App\Entity\ServiceCategory;
use App\Entity\ServiceStatusHistory;
use PHPUnit\Framework\TestCase;

class ServiceStatusHistoryTest extends TestCase
{
    private function createService(): Service
    {
        $category = new ServiceCategory('Web', 'web');

        return new Service('Test Service', 'test-service', $category);
    }

    public function testConstructor(): void
    {
        $service = $this->createService();
        $history = new ServiceStatusHistory($service, 'up', 'All good');

        $this->assertNull($history->getId());
        $this->assertSame($service, $history->getService());
        $this->assertSame('up', $history->getStatus());
        $this->assertSame('All good', $history->getMessage());
        $this->assertInstanceOf(\DateTimeImmutable::class, $history->getCreatedAt());
    }

    public function testConstructorWithoutMessage(): void
    {
        $service = $this->createService();
        $history = new ServiceStatusHistory($service, 'down');

        $this->assertSame('down', $history->getStatus());
        $this->assertNull($history->getMessage());
    }
}
