function RefreshVariablesTrait::refreshVariables

Same name in other branches
  1. 9 core/lib/Drupal/Core/Test/RefreshVariablesTrait.php \Drupal\Core\Test\RefreshVariablesTrait::refreshVariables()
  2. 10 core/lib/Drupal/Core/Test/RefreshVariablesTrait.php \Drupal\Core\Test\RefreshVariablesTrait::refreshVariables()
  3. 11.x core/lib/Drupal/Core/Test/RefreshVariablesTrait.php \Drupal\Core\Test\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->drupalPostForm() 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.

17 calls to RefreshVariablesTrait::refreshVariables()
BrowserWithJavascriptTest::drupalGetWithAlert in core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php
Retrieves a Drupal path or an absolute path.
FunctionalTestSetupTrait::resetAll in core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
Resets all data structures after having enabled new modules.
InstallerTestBase::refreshVariables in core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
FunctionalTestSetupTrait::refreshVariables() tries to operate on persistent storage, which is only available after the installer completed.
InstallerTestBase::refreshVariables in core/modules/simpletest/src/InstallerTestBase.php
WebTestBase::refreshVariables() tries to operate on persistent storage, which is only available after the installer completed.
LanguageNegotiationInfoTest::stateSet in core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
Sets state flags for language_test module.

... See full list

3 methods override RefreshVariablesTrait::refreshVariables()
InstallerTestBase::refreshVariables in core/modules/simpletest/src/InstallerTestBase.php
WebTestBase::refreshVariables() tries to operate on persistent storage, which is only available after the installer completed.
InstallerTestBase::refreshVariables in core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
FunctionalTestSetupTrait::refreshVariables() tries to operate on persistent storage, which is only available after the installer completed.
SelectProfileFormTest::refreshVariables in core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php
BrowserTestBase::refreshVariables() tries to operate on persistent storage, which is only available after the installer completed.

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\Test

Code

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();
        }
    }
    \Drupal::service('config.factory')->reset();
    \Drupal::service('state')->resetCache();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.