/** * Act on a field being updated. * * This hook is invoked just after field is updated in field_update_field(). * * @param $field * The field as it is post-update. * @param $prior_field * The field as it was pre-update. * @param $has_data * Whether any data already exists for this field. */ function hook_field_update_field($field, $prior_field, $has_data) { // Reset the static value that keeps track of allowed values for list fields. backdrop_static_reset('list_allowed_values'); }
/** * Refresh the in-memory set of variables and state values. Useful after a * page request is made that changes a variable in a different thread. * * In other words calling a settings page with $this->backdropPost() with a changed * value would update a variable to reflect that change, but in the thread that * made the call (thread running the test) the changed variable would not be * picked up. * * This method clears the variables cache and loads a fresh copy from the database * to ensure that the most up-to-date set of variables is loaded. */ protected function refreshVariables() { global $conf; cache('bootstrap')->delete('variables'); $conf = variable_initialize(); backdrop_static_reset('states'); backdrop_static_reset('config'); }
/** * Sets up a Backdrop site to be used as a cached installation profile. */ protected function setUp() { global $conf; // Prepare the environment for running tests. $this->prepareEnvironment(); if (!$this->setupEnvironment) { return FALSE; } // Reset all statics and variables to perform tests in a clean environment. $conf = array(); backdrop_static_reset(); // Change the database prefix. // All static variables need to be reset before the database prefix is // changed, since BackdropCacheArray implementations attempt to // write back to persistent caches when they are destructed. $this->changeDatabasePrefix(); if (!$this->setupDatabasePrefix) { return FALSE; } // Preset the 'install_profile' system variable, so the first call into // system_rebuild_module_data() (in backdrop_install_system()) will register // the test's profile as a module. Without this, the installation profile of // the parent site (executing the test) is registered, and the test // profile's hook_install() and other hook implementations are never invoked. config_install_default_config('system'); config_set('system.core', 'install_profile', $this->profile); // Perform the actual Backdrop installation. include_once BACKDROP_ROOT . '/core/includes/install.inc'; backdrop_install_system(); // Set path variables. $core_config = config('system.core'); $core_config->set('file_default_scheme', 'public'); $core_config->set('file_public_path', $this->public_files_directory); $core_config->set('file_private_path', $this->private_files_directory); $core_config->set('file_temporary_path', $this->temp_files_directory); $core_config->save(); // Ensure schema versions are recalculated. backdrop_static_reset('backdrop_get_schema_versions'); // Include the testing profile. config_set('system.core', 'install_profile', $this->profile); $profile_details = install_profile_info($this->profile, 'en'); // Install the modules specified by the testing profile. module_enable($profile_details['dependencies'], FALSE); // Install the profile itself. $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField(); if ($install_profile_module_exists) { module_enable(array($this->profile), FALSE); } return TRUE; }