<?php

namespace Tests\Unit\Enums;

use App\Enums\PublishStatusEnum;
use PHPUnit\Framework\TestCase;

class PublishStatusEnumTest extends TestCase
{
    public function test_published_and_error_are_settled(): void
    {
        $this->assertTrue(PublishStatusEnum::PUBLISHED->isSettled());
        $this->assertTrue(PublishStatusEnum::ERROR->isSettled());
    }

    public function test_skipped_is_not_a_publish_outcome(): void
    {
        $this->assertFalse(PublishStatusEnum::SKIPPED->isSettled());
    }

    public function test_in_flight_statuses_are_not_settled(): void
    {
        $this->assertFalse(PublishStatusEnum::UNPUBLISHED->isSettled());
        $this->assertFalse(PublishStatusEnum::PUBLISHING->isSettled());
    }

    public function test_settled_values_lists_every_settled_case(): void
    {
        $this->assertSame(['published', 'error'], PublishStatusEnum::settledValues());
    }

    public function test_settled_values_stays_in_step_with_the_cases(): void
    {
        $expected = array_values(array_map(
            fn (PublishStatusEnum $status): string => $status->value,
            array_filter(
                PublishStatusEnum::cases(),
                fn (PublishStatusEnum $status): bool => $status->isSettled(),
            ),
        ));

        $this->assertSame($expected, PublishStatusEnum::settledValues());
    }
}
