Files
Verde-Web/tests/Feature/Api/V1/Geo/GeoLookupTest.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

80 lines
2.2 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 GeoLookupTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->seed([RoleSeeder::class, SamplePsgcSeeder::class]);
}
public function test_lists_regions(): void
{
$response = $this->getJson('/api/v1/geo/regions');
$response->assertOk()
->assertJsonPath('success', true)
->assertJsonFragment(['code' => 'NCR'])
->assertJsonFragment(['code' => 'R03']);
}
public function test_lists_provinces_filtered_by_region(): void
{
$response = $this->getJson('/api/v1/geo/provinces?region=NCR');
$response->assertOk()
->assertJsonCount(4, 'data');
}
public function test_lists_cities_filtered_by_province(): void
{
$response = $this->getJson('/api/v1/geo/cities?province=NCR-2');
$response->assertOk()
->assertJsonFragment(['code' => 'QC'])
->assertJsonFragment(['code' => 'PSG']);
}
public function test_lists_cities_filtered_by_region(): void
{
$response = $this->getJson('/api/v1/geo/cities?region=NCR');
$response->assertOk();
$this->assertGreaterThanOrEqual(5, count($response->json('data')));
}
public function test_lists_barangays_filtered_by_city(): void
{
$response = $this->getJson('/api/v1/geo/barangays?city=QC');
$response->assertOk()
->assertJsonFragment(['name' => 'Diliman'])
->assertJsonFragment(['name' => 'Commonwealth']);
}
public function test_searches_barangays_by_name(): void
{
$response = $this->getJson('/api/v1/geo/barangays?q=Pob');
$response->assertOk()
->assertJsonFragment(['name' => 'Poblacion']);
}
public function test_invalid_region_filter_returns_empty(): void
{
$response = $this->getJson('/api/v1/geo/provinces?region=ZZZ');
$response->assertOk()
->assertJsonCount(0, 'data');
}
}