<?php

namespace Tests\Unit\SystemCore\Enums;

use Modules\SystemCore\App\Enums\SupplierStatus;
use PHPUnit\Framework\TestCase;

class SupplierStatusTest extends TestCase
{
    // ==========================================
    // Cases Tests
    // ==========================================

    public function test_all_expected_cases_exist(): void
    {
        $cases = SupplierStatus::cases();

        $this->assertCount(5, $cases);
        $this->assertContains(SupplierStatus::Active, $cases);
        $this->assertContains(SupplierStatus::Inactive, $cases);
        $this->assertContains(SupplierStatus::Blocked, $cases);
        $this->assertContains(SupplierStatus::Pending, $cases);
        $this->assertContains(SupplierStatus::Suspended, $cases);
    }

    public function test_case_values_are_correct(): void
    {
        $this->assertEquals('active', SupplierStatus::Active->value);
        $this->assertEquals('inactive', SupplierStatus::Inactive->value);
        $this->assertEquals('blocked', SupplierStatus::Blocked->value);
        $this->assertEquals('pending', SupplierStatus::Pending->value);
        $this->assertEquals('suspended', SupplierStatus::Suspended->value);
    }

    // ==========================================
    // Label Tests
    // ==========================================

    public function test_label_returns_correct_string_for_active(): void
    {
        $this->assertEquals('Active', SupplierStatus::Active->label());
    }

    public function test_label_returns_correct_string_for_inactive(): void
    {
        $this->assertEquals('Inactive', SupplierStatus::Inactive->label());
    }

    public function test_label_returns_correct_string_for_blocked(): void
    {
        $this->assertEquals('Blocked', SupplierStatus::Blocked->label());
    }

    public function test_label_returns_correct_string_for_pending(): void
    {
        $this->assertEquals('Pending', SupplierStatus::Pending->label());
    }

    public function test_label_returns_correct_string_for_suspended(): void
    {
        $this->assertEquals('Suspended', SupplierStatus::Suspended->label());
    }

    // ==========================================
    // Color Tests
    // ==========================================

    public function test_color_returns_valid_bootstrap_class(): void
    {
        $validColors = ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'];

        foreach (SupplierStatus::cases() as $case) {
            $this->assertContains($case->color(), $validColors, "Invalid color for {$case->name}");
        }
    }

    public function test_color_returns_success_for_active(): void
    {
        $this->assertEquals('success', SupplierStatus::Active->color());
    }

    public function test_color_returns_secondary_for_inactive(): void
    {
        $this->assertEquals('secondary', SupplierStatus::Inactive->color());
    }

    public function test_color_returns_danger_for_blocked(): void
    {
        $this->assertEquals('danger', SupplierStatus::Blocked->color());
    }

    public function test_color_returns_warning_for_pending(): void
    {
        $this->assertEquals('warning', SupplierStatus::Pending->color());
    }

    public function test_color_returns_dark_for_suspended(): void
    {
        $this->assertEquals('dark', SupplierStatus::Suspended->color());
    }

    // ==========================================
    // TryFrom Tests
    // ==========================================

    public function test_try_from_returns_enum_for_valid_value(): void
    {
        $status = SupplierStatus::tryFrom('blocked');

        $this->assertInstanceOf(SupplierStatus::class, $status);
        $this->assertEquals(SupplierStatus::Blocked, $status);
    }

    public function test_try_from_returns_null_for_invalid_value(): void
    {
        $status = SupplierStatus::tryFrom('removed');

        $this->assertNull($status);
    }
}
