seed([RoleSeeder::class, SamplePsgcSeeder::class, SampleDropOffPointsSeeder::class]); Notification::fake(); $driver = User::factory()->create(['role' => User::ROLE_DRIVER, 'status' => 'active']); $resident = User::factory()->create(['role' => User::ROLE_RESIDENT, 'status' => 'active']); $otherResident = User::factory()->create(['role' => User::ROLE_RESIDENT, 'status' => 'active']); $dop = DropOffPoint::where('code', 'DOP-QC-DLM-01')->firstOrFail(); $otherDop = DropOffPoint::where('code', 'DOP-QC-CMW-01')->firstOrFail(); // Resident's household assigned to this DOP — should be notified Household::factory()->create([ 'head_user_id' => $resident->id, 'assigned_drop_off_point_id' => $dop->id, ]); // Other household assigned to a different DOP — should NOT be notified Household::factory()->create([ 'head_user_id' => $otherResident->id, 'assigned_drop_off_point_id' => $otherDop->id, ]); $team = CollectionTeam::create([ 'name' => 'TX', 'driver_id' => $driver->id, 'status' => 'active', ]); $route = Route::create(['name' => 'R', 'code' => 'RT-PI', 'status' => 'active']); RouteStop::create(['route_id' => $route->id, 'drop_off_point_id' => $dop->id, 'sequence' => 1]); $trip = Trip::create([ 'trip_number' => 'TRIP-PI', 'route_id' => $route->id, 'team_id' => $team->id, 'scheduled_date' => now()->toDateString(), 'status' => 'in_progress', 'actual_start_time' => now(), ]); $stop = TripStop::create([ 'trip_id' => $trip->id, 'drop_off_point_id' => $dop->id, 'sequence' => 1, 'status' => 'pending', ]); Sanctum::actingAs($driver); $this->postJson("/api/v1/driver/trips/{$trip->uuid}/stops/{$stop->id}/arrive", [ 'lat' => 14.6539, 'lng' => 121.0685, ])->assertOk(); Notification::assertSentTo($resident, PickupImminent::class); Notification::assertNotSentTo($otherResident, PickupImminent::class); } }