You are here

function DrupalTestCase::drupalVariableSet in SimpleTest 6

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

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

Parameters

string $name name of the value:

mixed $value value:

12 calls to DrupalTestCase::drupalVariableSet()
BookModuleTestCase::createBookNode in tests/book_module.test
Create book node.
CommentModuleTestCase::set_comment_settings in tests/comment_module.test
Set comment setting for story content type.
PageCreationTest::testPageCreation in tests/page_creation.test
PathModuleTestCase::createNode in tests/path_module.test
ProfileModuleTestUrl::testProfileSingle in tests/profile_module.test

... See full list

File

./drupal_test_case.php, line 337

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;
    }
  }
}