- **Sentry** wired in bootstrap/app.php via Sentry\Laravel\Integration.
No-op when SENTRY_LARAVEL_DSN is empty.
- **Audit logging** broadened: LogsActivity applied to Household, QrCode,
Trip, Payment with tight logOnly whitelists and named log channels
('household', 'qr_code', 'trip', 'payment') to keep the activity
stream useful.
- **Bulk admin actions**:
POST /admin/households/bulk-approve — skips already-approved /
no-proof / unknown ids, reports per-id outcomes
POST /admin/bulk/users/{suspend,activate} — admins protected
POST /admin/bulk/qr-codes/void — respects state machine transitions
- **FCM push scaffold**: PushDriver contract with LogPushDriver
(default) and FcmPushDriver (activates when FCM_SERVER_KEY is set).
PushChannel adapts notifications. RoutesByPreferences now also
routes via push when push_enabled + fcm_token. toPush() payloads
added to HouseholdApproved / QrBalanceLow / PickupImminent.
- **Reverb WebSocket broadcast**: laravel/reverb installed.
TruckLocationBroadcast fires on every TruckTracker::record().
routes/channels.php authenticates: admins → private-admin.live,
residents → area.{id}.trucks (only if their household barangay is
covered by the service area).
- **PSGC seeder** expanded: all 17 PH regions, 4 NCR districts,
all 17 NCR cities. Sample barangays still carry rectangular
boundaries for point-in-polygon resolution tests.
- **Conditional SPATIAL INDEX migration** for barangays.boundary —
safe no-op until every row has a polygon (i.e., after full PSA
dataset import). Re-running `php artisan migrate` after import
flips the column to NOT NULL and adds the index.
196 feature tests passing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Audit;
|
|
|
|
use App\Events\HouseholdVerified;
|
|
use App\Models\Household;
|
|
use App\Models\QrCode;
|
|
use App\Models\QrCodeBatch;
|
|
use App\Models\User;
|
|
use App\Services\Qr\BatchGenerator;
|
|
use App\States\QrCode\Voided;
|
|
use Database\Seeders\RoleSeeder;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Spatie\Activitylog\Models\Activity;
|
|
use Tests\TestCase;
|
|
|
|
class ActivityLogTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->seed(RoleSeeder::class);
|
|
}
|
|
|
|
public function test_household_verification_writes_activity_log(): void
|
|
{
|
|
$admin = User::factory()->create(['role' => User::ROLE_ADMIN, 'status' => 'active']);
|
|
$h = Household::factory()->create(['verification_status' => 'pending', 'proof_of_residency_path' => 'p.jpg']);
|
|
|
|
$h->markVerified($admin);
|
|
HouseholdVerified::dispatch($h->fresh(), $admin);
|
|
|
|
$log = Activity::where('log_name', 'household')
|
|
->where('event', 'updated')
|
|
->where('subject_id', $h->id)
|
|
->orderByDesc('id')
|
|
->first();
|
|
$this->assertNotNull($log);
|
|
$this->assertSame(Household::class, $log->subject_type);
|
|
$this->assertEquals('approved', $log->properties['attributes']['verification_status']);
|
|
}
|
|
|
|
public function test_qr_code_void_writes_activity_log(): void
|
|
{
|
|
$batch = app(BatchGenerator::class)->generate(1, QrCodeBatch::PURPOSE_FREE);
|
|
$code = $batch->codes()->first();
|
|
|
|
$code->status->transitionTo(Voided::class);
|
|
|
|
$log = Activity::where('log_name', 'qr_code')->latest()->first();
|
|
$this->assertNotNull($log);
|
|
$this->assertSame('voided', $log->properties['attributes']['status']);
|
|
}
|
|
}
|