<?php

declare(strict_types=1);

namespace App\Tests\Unit\ValueObject;

use App\ValueObject\Distance;
use App\ValueObject\Point;
use PHPUnit\Framework\TestCase;

final class DistanceTest extends TestCase
{
    public function testCalculatesDistanceBetweenTwoPointsInKilometers(): void
    {
        $origin = Point::fromLatLng(48.8566, 2.3522); // Paris
        $destination = Point::fromLatLng(51.5074, -0.1278); // London

        $distance = Distance::between($origin, $destination);

        self::assertEqualsWithDelta(343.4, $distance->inKilometers(), 0.5);
    }

    public function testCanConvertDistanceToMeters(): void
    {
        $origin = Point::fromLatLng(0.0, 0.0);
        $destination = Point::fromLatLng(0.0, 0.009); // ~1km east on equator

        $distance = Distance::between($origin, $destination);

        self::assertEqualsWithDelta(1000, $distance->inMeters(), 10);
    }
}
