Projet

Général

Profil

Paste
Télécharger (1,33 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / tests / object_cache.test @ 1e39edcb

1
<?php
2
/**
3
 * @file
4
 * Tests for different parts of the ctools object caching system.
5
 */
6

    
7
/**
8
 * Test object cache storage.
9
 */
10
class CtoolsObjectCache extends DrupalWebTestCase {
11
  public static function getInfo() {
12
    return array(
13
      'name' => 'Ctools object cache storage',
14
      'description' => 'Verify that objects are written, readable and lockable.',
15
      'group' => 'ctools',
16
    );
17
  }
18

    
19
  public function setUp() {
20
    // Additionally enable ctools module.
21
    parent::setUp('ctools');
22
  }
23

    
24
  public function testObjectStorage() {
25
    $account1 = $this->drupalCreateUser(array());
26
    $this->drupalLogin($account1);
27

    
28
    $data = array(
29
      'test1' => 'foobar',
30
    );
31

    
32
    ctools_include('object-cache');
33
    ctools_object_cache_set('testdata', 'one', $data);
34
    $this->assertEqual($data, ctools_object_cache_get('testdata', 'one'), 'Object cache data successfully stored');
35

    
36
    // TODO Test object locking somehow.
37
    // Object locking/testing works on session_id but simpletest uses
38
    // $this->session_id so can't be tested ATM.
39

    
40
    ctools_object_cache_clear('testdata', 'one');
41
    $this->assertFalse(ctools_object_cache_get('testdata', 'one'), 'Object cache data successfully cleared');
42

    
43
    // TODO Test ctools_object_cache_clear_all somehow...
44
    // ctools_object_cache_clear_all requires session_id funtionality as well.
45
  }
46
}