<?php

namespace Tests\Unit;

use App\Modules\Valuation\ConditionPriceTier;
use PHPUnit\Framework\TestCase;

class ConditionPriceTierTest extends TestCase
{
    public function testReturnsNullForMissingCondition(): void
    {
        $this->assertNull(ConditionPriceTier::fromCondition(null));
        $this->assertNull(ConditionPriceTier::fromCondition(''));
    }

    public function testMapsExcellentAndGoodToCleanPrice(): void
    {
        $this->assertEquals(ConditionPriceTier::TIER_CLEAN, ConditionPriceTier::fromCondition('excellent'));
        $this->assertEquals(ConditionPriceTier::TIER_CLEAN, ConditionPriceTier::fromCondition('good'));
    }

    public function testMapsAverageToAveragePrice(): void
    {
        $this->assertEquals(ConditionPriceTier::TIER_AVERAGE, ConditionPriceTier::fromCondition('average'));
    }

    public function testMapsBelowAverageAndPoorToBelowPrice(): void
    {
        $this->assertEquals(ConditionPriceTier::TIER_BELOW, ConditionPriceTier::fromCondition('below_average'));
        $this->assertEquals(ConditionPriceTier::TIER_BELOW, ConditionPriceTier::fromCondition('poor'));
    }

    public function testIsCaseInsensitive(): void
    {
        $this->assertEquals(ConditionPriceTier::TIER_CLEAN, ConditionPriceTier::fromCondition('EXCELLENT'));
        $this->assertEquals(ConditionPriceTier::TIER_BELOW, ConditionPriceTier::fromCondition('Poor'));
    }

    public function testReturnsNullForUnknownCondition(): void
    {
        $this->assertNull(ConditionPriceTier::fromCondition('fair'));
        $this->assertNull(ConditionPriceTier::fromCondition('gibberish'));
    }
}
