feat: add distance value object and ci workflows

This commit is contained in:
Bernard Ngandu
2025-10-10 16:13:48 +02:00
parent d3338e8901
commit 2ed7a48d36
44 changed files with 4263 additions and 1370 deletions
@@ -0,0 +1,32 @@
<?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::betweenPoints($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::betweenPoints($origin, $destination);
self::assertEqualsWithDelta(1000, $distance->inMeters(), 10);
}
}