diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-09-08 20:49:47 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-09-08 20:49:47 +0000 |
commit | e4ff0cd6f4d70b0b12221d1256dfaa6533f74a4d (patch) | |
tree | e60c2f7c65d0803758a5d1abb85dbac53d50c7aa | |
parent | 763b11c8c708d0e4fd356b78c878fb369f33fa43 (diff) | |
download | brdo-e4ff0cd6f4d70b0b12221d1256dfaa6533f74a4d.tar.gz brdo-e4ff0cd6f4d70b0b12221d1256dfaa6533f74a4d.tar.bz2 |
- Patch #304139 by Rob Loach, beeradb, Damien, et al: tests for the variable_*() functions.
-rw-r--r-- | modules/simpletest/tests/bootstrap.test | 42 | ||||
-rw-r--r-- | modules/simpletest/tests/system_test.module | 8 |
2 files changed, 50 insertions, 0 deletions
diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test index de833f117..ea59fa7eb 100644 --- a/modules/simpletest/tests/bootstrap.test +++ b/modules/simpletest/tests/bootstrap.test @@ -108,3 +108,45 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase { } } + +class BootstrapVariableTestCase extends DrupalWebTestCase { + + /** + * Implementation of setUp(). + */ + function setUp() { + parent::setUp('system_test'); + } + + /** + * Implementation of getInfo(). + */ + function getInfo() { + return array( + 'name' => t('Variable test'), + 'description' => t('Make sure the variable system functions correctly.'), + 'group' => t('Bootstrap') + ); + } + + /** + * testVariable + */ + 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', NULL), t('Setting and retrieving values')); + + // Make sure the variable persists across multiple requests. + $this->drupalGet('system-test/variable-get'); + $this->assertText($variable, t('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, t('Deleting variables')); + } + +} diff --git a/modules/simpletest/tests/system_test.module b/modules/simpletest/tests/system_test.module index 60b193152..d3db9b587 100644 --- a/modules/simpletest/tests/system_test.module +++ b/modules/simpletest/tests/system_test.module @@ -40,6 +40,14 @@ function system_test_menu() { 'type' => MENU_CALLBACK, ); + $items['system-test/variable-get'] = array( + 'title' => 'Variable Get', + 'page callback' => 'variable_get', + 'page arguments' => array('simpletest_bootstrap_variable_test', NULL), + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + return $items; } |