You are here

function VariableTestCase::testVariableAPI in Variable 7

Same name and namespace in other branches
  1. 7.2 variable.test \VariableTestCase::testVariableAPI()

Test that all core modules can be enabled, disabled and uninstalled.

File

./variable.test, line 32
Tests for variable.module.

Class

VariableTestCase
Helper class for module test cases.

Code

function testVariableAPI() {

  // Check default values, set, get, delete.
  $this
    ->assertEqual(variable_get_value('site_name'), 'Drupal', 'Function variable_get_value() returns proper default values.');
  $name = 'My test site';
  variable_set_value('site_name', $name);
  $this
    ->assertTrue(variable_get('site_name'), 'Variable has been set using Variable API.');
  $this
    ->drupalGet('');
  $this
    ->assertText($name, 'Site name set with variable_set_value() is displayed.');
  variable_delete('site_name');
  $this
    ->assertFalse(variable_get('site_name'), 'Variable has been deleted using Variable API.');
  $this
    ->assertEqual(variable_get_value('site_name'), 'Drupal', 'Variable has been reset to its default value.');

  // Find variable information and specific variable in module and group list
  $variable = variable_get_info('site_name');
  $this
    ->assertEqual($variable['title'], t('Site name'), 'Variable information can be retrieved for specific variable.');

  // Check our admin pages just to make sure all variable widgets are properly displayed.
  $this
    ->drupalGet('admin/config/system/variable');
  $this
    ->drupalGet('admin/config/system/variable/module');
  $this
    ->drupalGet('admin/config/system/variable/edit/site_name');
}