<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Tests\Cart;

use CpCreation\VitiCore\Cart\Model\Cart;
use PHPUnit\Framework\TestCase;

final class CartFulfillmentTest extends TestCase
{
    public function testFulfillmentDateIsRecordedOnce(): void
    {
        $cart = new Cart();
        $firstDate = new \DateTimeImmutable('2026-07-23 10:00:00');

        $cart->markFulfilled($firstDate);
        $cart->markFulfilled($firstDate->modify('+1 day'));

        self::assertTrue($cart->isDelivery());
        self::assertSame($firstDate, $cart->getFulfilledAt());
    }

    public function testFulfillmentCanBeClearedExplicitly(): void
    {
        $cart = new Cart();
        $cart->markFulfilled(new \DateTimeImmutable());

        $cart->clearFulfillment();

        self::assertFalse($cart->isDelivery());
        self::assertNull($cart->getFulfilledAt());
    }

    public function testTrackingCarrierCanBeStoredWithoutTrackingUrl(): void
    {
        $cart = new Cart();

        $cart->setTrackingCarrier('transvins');

        self::assertSame('transvins', $cart->getTrackingCarrier());
        self::assertNull($cart->getUrlDeSuiviCarrier());
    }
}
