Files
Verde-Web/tests/Feature/Api/V1/Geo/ResolveLocationTest.php
admin c8404564fe feat(backend): complete Modules 2 + 3 (geo + user management)
Module 2 — Geographic Data: PSGC tables (regions/provinces/cities/
barangays) with native geometry(polygon|point, 4326) columns; cascading
dropdown endpoints; ST_Contains-based GPS resolution; service-area CRUD
with barangay attach/detach; SamplePsgcSeeder + psgc:import command.

Module 3 — User Management: 5 role-specific profile tables (driver/
helper/scanner/store_partner with verification_status + rejection
reason); profile auto-created on register; admin user CRUD with
filters/pagination, suspend/activate, profile approve/reject;
self-service /me + /me/profile with role-aware validation that blocks
self-approval and resets rejected profiles to pending on resubmit.

69 feature tests passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 23:59:56 +08:00

86 lines
2.3 KiB
PHP

<?php
namespace Tests\Feature\Api\V1\Geo;
use Database\Seeders\RoleSeeder;
use Database\Seeders\SamplePsgcSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ResolveLocationTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->seed([RoleSeeder::class, SamplePsgcSeeder::class]);
}
public function test_resolves_qc_coordinates_to_diliman(): void
{
$response = $this->postJson('/api/v1/geo/resolve', [
'lat' => 14.6539,
'lng' => 121.0685,
]);
$response->assertOk()
->assertJsonPath('data.barangay.name', 'Diliman')
->assertJsonPath('data.city_municipality', 'Quezon City')
->assertJsonPath('data.region', 'National Capital Region');
}
public function test_resolves_makati_coordinates_to_poblacion(): void
{
$response = $this->postJson('/api/v1/geo/resolve', [
'lat' => 14.5648,
'lng' => 121.0306,
]);
$response->assertOk()
->assertJsonPath('data.barangay.name', 'Poblacion');
}
public function test_returns_404_for_uncovered_coordinates(): void
{
$response = $this->postJson('/api/v1/geo/resolve', [
'lat' => 14.5500,
'lng' => 121.5000,
]);
$response->assertStatus(404)
->assertJsonPath('errors.coordinates.0', 'out_of_coverage');
}
public function test_returns_404_for_coordinates_outside_philippines(): void
{
$response = $this->postJson('/api/v1/geo/resolve', [
'lat' => 35.6762,
'lng' => 139.6503,
]);
$response->assertStatus(404);
}
public function test_validates_coordinate_bounds(): void
{
$response = $this->postJson('/api/v1/geo/resolve', [
'lat' => 999,
'lng' => 121,
]);
$response->assertStatus(422)
->assertJsonValidationErrors(['lat']);
}
public function test_requires_both_lat_and_lng(): void
{
$response = $this->postJson('/api/v1/geo/resolve', [
'lat' => 14.5,
]);
$response->assertStatus(422)
->assertJsonValidationErrors(['lng']);
}
}