<?php

it('invalidates related user permission and auth-session caches when group permissions change', function (): void {
    $content = file_get_contents(app_path('objects/groups_permissions_o.php'));

    expect($content)->not->toBeFalse();
    expect($content)->toContain('private function invalidateGroupSessionCaches(int $group_id): void');
    expect($content)->toContain('$this->invalidateGroupSessionCaches($group_id);');
    expect(substr_count((string)$content, '$this->invalidateGroupSessionCaches($group_id);'))->toBeGreaterThanOrEqual(2);
    expect($content)->toContain("redis->clear_keys('perm:user:' . \$userId . ':*');");
    expect($content)->toContain('redis->clear_auth_session($token);');
});

