You are here

function DrupalTestCase::drupalVariableSet in SimpleTest 5

Same name and namespace in other branches
  1. 6 drupal_test_case.php \DrupalTestCase::drupalVariableSet()

Set a druapl variable and keep track of the changes for tearDown()

Parameters

string $name name of the value:

mixed $value value:

5 calls to DrupalTestCase::drupalVariableSet()
PageCreationTest::testPageCreation in tests/page_creation.test
ProfileModuleTestUrl::testProfileSingle in tests/profile_module.test
SearchMatchTest::_setup in tests/search_match.test
Set up a small index of items to test against.
UserAccessTest::testAccess in tests/user_access.test
UserRegistrationTest::testUserRegistration in tests/user_registration_test.test

File

./drupal_test_case.php, line 233

Class

DrupalTestCase
Test case for typical Drupal tests. Extends WebTestCase for comfortable browser usage but also implements all UnitTestCase methods, I wish WebTestCase would do this.

Code

function drupalVariableSet($name, $value) {

  /* NULL variables would anyways result in default because of isset */
  $old_value = variable_get($name, NULL);
  if ($value !== $old_value) {
    variable_set($name, $value);

    /* Use array_key_exists instead of isset so NULL values do not get overwritten */
    if (!array_key_exists($name, $this->_cleanupVariables)) {
      $this->_cleanupVariables[$name] = $old_value;
    }
  }
}