public function testloadPreferences() { //unset and reconnect Db to resolve mysqli fetch exeception global $db; unset($db->database); $db->checkConnection(); $user = new User(); $user->retrieve(1); $result = $user->loadPreferences(); $this->assertEquals(true, $result); }
/** * Forces a fresh fetching of user preferences. * * User preferences are written to the users session, so when an admin changes * a preference for a user, that user won't get the change until they logout. * This forces a fresh fetching of a users preferences from the DB when called. * This shouldn't be too expensive of a hit since user preferences need only * be fetched once and can be stored on the client. * * @param User $current_user A User bean */ public function forceUserPreferenceReload($current_user) { // If there is a unique_key in the session, save it and change it so that // loadPreferences() on the user will be forced to collect a fresh set // of preferences. $uniqueKey = null; if (isset($_SESSION['unique_key'])) { $uniqueKey = $_SESSION['unique_key']; $_SESSION['unique_key'] = 't_' . time(); } $current_user->loadPreferences(); // Set this back to what it was $_SESSION['unique_key'] = $uniqueKey; }