protected function WebTestBase::refreshVariables

Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread.

In other words calling a settings page with $this->drupalPost() 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.

16 calls to WebTestBase::refreshVariables()
FormatDateTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
Sets up a Drupal site for running functional and integration tests.
InstallerTest::refreshVariables in drupal/core/modules/system/lib/Drupal/system/Tests/InstallerTest.php
During setup(), drupalPost calls refreshVariables() which tries to read variables which are not yet there because the child Drupal is not yet installed.
MatchPathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Path/MatchPathTest.php
Sets up a Drupal site for running functional and integration tests.
NodeFormButtonsTest::testNodeFormButtons in drupal/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php
Tests that the right buttons are displayed for saving nodes.
SearchEmbedFormTest::setUp in drupal/core/modules/search/lib/Drupal/search/Tests/SearchEmbedFormTest.php
Sets up a Drupal site for running functional and integration tests.

... See full list

2 methods override WebTestBase::refreshVariables()
InstallerTest::refreshVariables in drupal/core/modules/system/lib/Drupal/system/Tests/InstallerTest.php
During setup(), drupalPost calls refreshVariables() which tries to read variables which are not yet there because the child Drupal is not yet installed.
UpgradePathTestBase::refreshVariables in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php
Specialized refreshVariables().

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 950
Definition of Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function refreshVariables() {
  global $conf;
  cache('bootstrap')
    ->delete('variables');
  $conf = variable_initialize();
  drupal_container()
    ->get('config.factory')
    ->reset();
}