object_cache.test 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @file
  4. * Tests for different parts of the ctools object caching system.
  5. */
  6. /**
  7. * Test object cache storage.
  8. */
  9. class CtoolsObjectCache extends DrupalWebTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Ctools object cache storage',
  13. 'description' => 'Verify that objects are written, readable and lockable.',
  14. 'group' => 'ctools',
  15. );
  16. }
  17. public function setUp() {
  18. // Additionally enable ctools module.
  19. parent::setUp('ctools');
  20. }
  21. public function testObjectStorage() {
  22. $account1 = $this->drupalCreateUser(array());
  23. $this->drupalLogin($account1);
  24. $data = array(
  25. 'test1' => 'foobar',
  26. );
  27. ctools_include('object-cache');
  28. ctools_object_cache_set('testdata', 'one', $data);
  29. $this->assertEqual($data, ctools_object_cache_get('testdata', 'one'), 'Object cache data successfully stored');
  30. // TODO Test object locking somehow.
  31. // Object locking/testing works on session_id but simpletest uses
  32. // $this->session_id so can't be tested ATM.
  33. ctools_object_cache_clear('testdata', 'one');
  34. $this->assertFalse(ctools_object_cache_get('testdata', 'one'), 'Object cache data successfully cleared');
  35. // TODO Test ctools_object_cache_clear_all somehow...
  36. // ctools_object_cache_clear_all requires session_id funtionality as well.
  37. }
  38. }