feat: implement drop-off points & dumpsites edit/delete and status transition logic

This commit is contained in:
Super Admin
2026-06-29 23:15:55 +08:00
parent f2c1573f00
commit cfd7166a24
6 changed files with 355 additions and 33 deletions

View File

@@ -152,4 +152,32 @@ class DropOffPointTest extends TestCase
$this->deleteJson("/api/v1/admin/drop-off-points/{$dop->uuid}")->assertOk();
$this->assertSoftDeleted('drop_off_points', ['id' => $dop->id]);
}
public function test_dop_status_transition_reassigns_households(): void
{
$admin = User::factory()->create(['role' => User::ROLE_ADMIN, 'status' => User::STATUS_ACTIVE]);
Sanctum::actingAs($admin);
$dop1 = DropOffPoint::where('status', DropOffPoint::STATUS_ACTIVE)->first();
$household = \App\Models\Household::create([
'tenant_id' => $dop1->tenant_id,
'head_user_id' => User::factory()->create()->id,
'barangay_id' => $dop1->barangay_id,
'address_line' => '123 Test St',
'coordinates' => new \MatanYadaev\EloquentSpatial\Objects\Point(14.6539, 121.0685, 4326),
'household_size' => 3,
'assigned_drop_off_point_id' => $dop1->id,
'verification_status' => 'approved',
]);
$response = $this->patchJson("/api/v1/admin/drop-off-points/{$dop1->uuid}", [
'status' => DropOffPoint::STATUS_MAINTENANCE,
]);
$response->assertOk();
$household->refresh();
$this->assertNotEquals($dop1->id, $household->assigned_drop_off_point_id);
}
}