function CtoolsObjectCache::testObjectStorage

File

tests/object_cache.test, line 29

Class

CtoolsObjectCache
Test object cache storage.

Code

public function testObjectStorage() {
    ctools_include('cache');
    $account1 = $this->drupalCreateUser(array());
    $this->drupalLogin($account1);
    $data = array(
        'test1' => 'foobar',
    );
    ctools_include('object-cache');
    ctools_object_cache_set('testdata', 'one', $data);
    $this->assertEqual($data, ctools_object_cache_get('testdata', 'one'), 'Object cache data successfully stored');
    // TODO Test object locking somehow.
    // Object locking/testing works on session_id but simpletest uses
    // $this->session_id so can't be tested ATM.
    ctools_object_cache_clear('testdata', 'one');
    $this->assertFalse(ctools_object_cache_get('testdata', 'one'), 'Object cache data successfully cleared');
    // TODO Test ctools_object_cache_clear_all somehow...
    // ctools_object_cache_clear_all requires session_id funtionality as well.
}