count(2)->create(['is_active' => true]); Company::factory()->create(['is_active' => false]); $stats = app(AdminPerformanceCache::class)->activeInactiveStats(Company::query()); expect($stats)->toBe([ 'total' => 3, 'active' => 2, 'inactive' => 1, ]); }); test('admin performance cache is flushed when observed models change', function () { Cache::put(AdminPerformanceCache::DashboardStats, ['stale' => true], 600); Cache::put(AdminPerformanceCache::PressReleaseStats, ['stale' => true], 600); Cache::put(AdminPerformanceCache::RoleOptions, ['stale' => true], 600); Company::factory()->create(); expect(Cache::has(AdminPerformanceCache::DashboardStats))->toBeFalse() ->and(Cache::has(AdminPerformanceCache::PressReleaseStats))->toBeFalse() ->and(Cache::has(AdminPerformanceCache::RoleOptions))->toBeFalse(); }); test('admin role option cache is flushed when roles change', function () { Cache::put(AdminPerformanceCache::RoleOptions, ['stale' => true], 600); Role::query()->create([ 'name' => 'temporary-admin-role', 'guard_name' => 'web', ]); expect(Cache::has(AdminPerformanceCache::RoleOptions))->toBeFalse(); });