seed(RoleSeeder::class); $this->superAdmin = User::factory()->create(); $this->superAdmin->assignRole('super_admin'); $this->regularUser = User::factory()->create(); } public function test_returns_aggregate_counts(): void { $org = Organisation::factory()->create(['billing_status' => 'active']); Event::factory()->count(2)->create([ 'organisation_id' => $org->id, 'status' => 'draft', ]); Sanctum::actingAs($this->superAdmin); $response = $this->getJson('/api/v1/admin/stats'); $response->assertOk(); $response->assertJsonStructure([ 'data' => [ 'organisations' => ['total', 'by_billing_status'], 'events' => ['total', 'by_status'], 'users' => ['total', 'verified'], 'persons' => ['total'], ], ]); $this->assertGreaterThanOrEqual(1, $response->json('data.organisations.total')); $this->assertGreaterThanOrEqual(2, $response->json('data.events.total')); } public function test_denied_for_non_super_admin(): void { Sanctum::actingAs($this->regularUser); $response = $this->getJson('/api/v1/admin/stats'); $response->assertForbidden(); } }