toHaveCount(2) ->and($GLOBALS['auth_cache_queries'][0][0])->toBe('DELETE FROM user_auth_cache WHERE user_id = ?') ->and($GLOBALS['auth_cache_queries'][0][1])->toBe([42]) ->and($GLOBALS['auth_cache_queries'][1][0])->toContain('UPDATE user_auth') ->and($GLOBALS['auth_cache_queries'][1][1])->toBe([42]) ->and($GLOBALS['auth_cache_session_kills'])->toBe([]); }); test('permission resets still clear the current user session caches', function () : void { reset_user_perms_under_test(7); expect($GLOBALS['auth_cache_session_kills'])->toBe([ SESS_USER_REALMS, OPTIONS_USER, OPTIONS_WEB, SESS_AUTH_NAMES ]); }); test('group permission resets invalidate every member token', function () : void { $GLOBALS['auth_cache_group_users'] = [['user_id' => 10], ['user_id' => 11]]; reset_group_perms_under_test(5); expect($GLOBALS['auth_cache_queries'])->toHaveCount(2) ->and($GLOBALS['auth_cache_queries'][0][0])->toContain('DELETE FROM user_auth_cache') ->and($GLOBALS['auth_cache_queries'][0][0])->toContain('user_id IN (?,?)') ->and($GLOBALS['auth_cache_queries'][0][1])->toBe([10, 11]) ->and($GLOBALS['auth_cache_queries'][1][0])->toContain('UPDATE user_auth') ->and($GLOBALS['auth_cache_queries'][1][0])->toContain('id IN (?,?)') ->and($GLOBALS['auth_cache_queries'][1][1])->toBe([10, 11]); }); test('empty groups do not issue invalidation queries', function () : void { reset_group_perms_under_test(5); expect($GLOBALS['auth_cache_queries'])->toBe([]); });