object_cache.test 1.4 KB

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