Mercurial > hg > rr-repo
diff sites/all/modules/ctools/tests/object_cache.test @ 0:ff03f76ab3fe
initial version
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Wed, 21 Aug 2013 18:51:11 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/all/modules/ctools/tests/object_cache.test Wed Aug 21 18:51:11 2013 +0100 @@ -0,0 +1,46 @@ +<?php +/** + * @file + * Tests for different parts of the ctools object caching system. + */ + +/** + * Test object cache storage. + */ +class CtoolsObjectCache extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Ctools object cache storage', + 'description' => 'Verify that objects are written, readable and lockable.', + 'group' => 'Chaos Tools Suite', + ); + } + + public function setUp() { + // Additionally enable ctools module. + parent::setUp('ctools'); + } + + public function testObjectStorage() { + $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. + } +}