feat: resolve outcodes from local DB before HTTP

This commit is contained in:
Ovidiu U
2026-04-22 12:13:52 +01:00
parent 9fa9ea7835
commit 1e3b246172
2 changed files with 42 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
<?php
use App\Models\Outcode;
use App\Models\Postcode;
use App\Services\ApiLogger;
use App\Services\LocationResult;
@@ -194,3 +195,24 @@ it('resolves a full postcode from local DB without calling HTTP', function (): v
Http::assertNothingSent();
});
// --- Local DB (outcode) ---
it('resolves an outcode from local DB without calling HTTP', function (): void {
Outcode::create([
'outcode' => 'PE7',
'lat' => 52.536397,
'lng' => -0.210181,
]);
Http::fake();
$result = $this->service->resolve('PE7');
expect($result)->toBeInstanceOf(LocationResult::class)
->and($result->displayName)->toBe('PE7')
->and($result->lat)->toBe(52.536397)
->and($result->lng)->toBe(-0.210181);
Http::assertNothingSent();
});