class MemCacheSavingCase in Zircon Profile 8
Same name in this branch
- 8 modules/memcache/tests/memcache.test \MemCacheSavingCase
- 8 modules/memcache/tests/memcache6.test \MemCacheSavingCase
Same name and namespace in other branches
- 8.0 modules/memcache/tests/memcache.test \MemCacheSavingCase
- 8.0 modules/memcache/tests/memcache6.test \MemCacheSavingCase
Hierarchy
- class \MemCacheSavingCase extends \MemcacheTestCase
Expanded class hierarchy of MemCacheSavingCase
File
- modules/
memcache/ tests/ memcache6.test, line 107
View source
class MemCacheSavingCase extends MemcacheTestCase {
public static function getInfo() {
return array(
'name' => 'Memcache saving test',
'description' => 'Check our variables are saved and restored the right way.',
'group' => 'Memcache',
);
}
function setUp() {
parent::setUp();
variable_set("cache_flush_cache", 0);
}
/**
* Test the saving and restoring of a string.
*/
function testString() {
$this
->checkVariable($this
->randomName(100));
}
/**
* Test the saving and restoring of an integer.
*/
function testInteger() {
$this
->checkVariable(100);
}
/**
* Test the saving and restoring of a double.
*/
function testDouble() {
$this
->checkVariable(1.29);
}
/**
* Test the saving and restoring of an array.
*/
function testArray() {
$this
->checkVariable(array(
'drupal1',
'drupal2' => 'drupal3',
'drupal4' => array(
'drupal5',
'drupal6',
),
));
}
/**
* Test the saving and restoring of an object.
*/
function testObject() {
$test_object = new stdClass();
$test_object->test1 = $this
->randomName(100);
$test_object->test2 = 100;
$test_object->test3 = array(
'drupal1',
'drupal2' => 'drupal3',
'drupal4' => array(
'drupal5',
'drupal6',
),
);
cache_set('test_object', $test_object, 'cache');
$cache = cache_get('test_object', 'cache');
$this
->assertTrue(isset($cache->data) && $cache->data == $test_object, t('Object is saved and restored properly.'));
}
/*
* Check or a variable is stored and restored properly.
**/
function checkVariable($var) {
cache_set('test_var', $var, 'cache');
$cache = cache_get('test_var', 'cache');
$this
->assertTrue(isset($cache->data) && $cache->data === $var, t('@type is saved and restored properly.', array(
'@type' => ucfirst(gettype($var)),
)));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MemCacheSavingCase:: |
function | |||
MemCacheSavingCase:: |
public static | function | ||
MemCacheSavingCase:: |
function | |||
MemCacheSavingCase:: |
function | Test the saving and restoring of an array. | ||
MemCacheSavingCase:: |
function | Test the saving and restoring of a double. | ||
MemCacheSavingCase:: |
function | Test the saving and restoring of an integer. | ||
MemCacheSavingCase:: |
function | Test the saving and restoring of an object. | ||
MemCacheSavingCase:: |
function | Test the saving and restoring of a string. |