<?php
declare(strict_types=1);

namespace Tests\Unit;

use App\Modules\Shipments\DeliveryStatus;
use PHPUnit\Framework\TestCase;

final class DeliveryStatusTest extends TestCase
{
    public function testSlugifyAndNormalizeEnglishAwaitingPickup(): void
    {
        $slug = DeliveryStatus::slugifyAllegroDescription('Parcel is awaiting pick-up');
        $normalized = DeliveryStatus::normalize('allegro_edge', $slug);

        $this->assertSame('awaiting_pick_up', $slug);
        $this->assertSame(DeliveryStatus::READY_FOR_PICKUP, $normalized);
    }

    public function testSlugifyAndNormalizeEnglishDelivered(): void
    {
        $slug = DeliveryStatus::slugifyAllegroDescription('Parcel has been delivered');
        $normalized = DeliveryStatus::normalize('allegro_edge', $slug);

        $this->assertSame('delivered', $slug);
        $this->assertSame(DeliveryStatus::DELIVERED, $normalized);
    }

    public function testGuessStatusFromEnglishDescriptionFallback(): void
    {
        $normalized = DeliveryStatus::guessStatusFromDescription('Parcel has been released for delivery');

        $this->assertSame(DeliveryStatus::OUT_FOR_DELIVERY, $normalized);
    }

    public function testPolishMappingRegressionStillWorks(): void
    {
        $slug = DeliveryStatus::slugifyAllegroDescription('Przesylka zostala dostarczona');
        $normalized = DeliveryStatus::normalize('allegro_edge', $slug);

        $this->assertSame('dostarczona', $slug);
        $this->assertSame(DeliveryStatus::DELIVERED, $normalized);
    }
}

