function VariableTest::testVariable

Tests variables then deletes them.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php, line 35
Definition of Drupal\system\Tests\Bootstrap\VariableTest.

Class

VariableTest
Tests variable system functions.

Namespace

Drupal\system\Tests\Bootstrap

Code

function testVariable() {

  // Setting and retrieving values.
  $variable = $this
    ->randomName();
  variable_set('simpletest_bootstrap_variable_test', $variable);
  $this
    ->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), 'Setting and retrieving values');

  // Make sure the variable persists across multiple requests.
  $this
    ->drupalGet('system-test/variable-get');
  $this
    ->assertText($variable, 'Variable persists across multiple requests');

  // Deleting variables.
  $default_value = $this
    ->randomName();
  variable_del('simpletest_bootstrap_variable_test');
  $variable = variable_get('simpletest_bootstrap_variable_test', $default_value);
  $this
    ->assertIdentical($variable, $default_value, 'Deleting variables');
}