function RefreshVariablesTrait::refreshVariables
Refreshes in-memory configuration and state information.
Useful after a page request is made that changes configuration or state in a different thread.
In other words calling a settings page with $this->submitForm() with a changed value would update configuration to reflect that change, but in the thread that made the call (thread running the test) the changed values would not be picked up.
This method clears the cache and loads a fresh copy.
1 call to RefreshVariablesTrait::refreshVariables()
- FunctionalTestSetupTrait::resetAll in core/
lib/ Drupal/ Core/ Test/ FunctionalTestSetupTrait.php - Resets all data structures after having enabled new modules.
File
-
core/
lib/ Drupal/ Core/ Test/ RefreshVariablesTrait.php, line 25
Class
- RefreshVariablesTrait
- Provides a method to refresh in-memory configuration and state information.
Namespace
Drupal\Core\TestCode
protected function refreshVariables() {
// Clear the tag cache.
\Drupal::service('cache_tags.invalidator')->resetChecksums();
foreach (Cache::getBins() as $backend) {
if (is_callable([
$backend,
'reset',
])) {
$backend->reset();
}
}
foreach (Cache::getMemoryBins() as $backend) {
if (is_callable([
$backend,
'reset',
])) {
$backend->reset();
}
}
\Drupal::service('config.factory')->reset();
\Drupal::service('state')->reset();
}