not->toBeFalse(); expect($cookie)->not->toBeFalse(); // clear_auth_cookie() reads $_COOKIE['cacti_remembers'], which cacti_cookie_logout() unsets expect($clear)->toBeLessThan($cookie); }); test('logout revokes the token on every branch, not only the default one', function () use ($logoutSrc) { // exactly one call, above the timeout/disabled/remote vs default branch split expect(substr_count($logoutSrc, 'clear_auth_cookie();'))->toBe(1); $clear = strpos($logoutSrc, 'clear_auth_cookie();'); $branch = strpos($logoutSrc, "grv('action') == 'timeout'"); expect($branch)->not->toBeFalse(); expect($clear)->toBeLessThan($branch); }); test('logout everywhere terminates other sessions, not just remember-me tokens', function () use ($profileSrc) { $start = strpos($profileSrc, 'function api_auth_logout_everywhere('); expect($start)->not->toBeFalse(); $end = strpos($profileSrc, "\n}", $start); expect($end)->not->toBeFalse(); $body = substr($profileSrc, $start, $end - $start); expect($body)->toContain('DELETE FROM user_auth_cache'); expect($body)->toContain('DELETE FROM sessions'); // keep the current session so the action does not log the caller out expect($body)->toContain('AND id != ?'); expect($body)->toContain('session_id()'); });