summaryrefslogtreecommitdiff
path: root/test/TestBitCache.php
blob: cdfe86015ed6d32d443b15c41f1a550283f3b669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
require_once('bit_setup_inc.php');

class TestBitCache extends UnitTestCase {
    
    var $test;
    var $name ="TestBitCache";

    function TestBitCache()
    {
      // global $gBitCache;
      $this->test = new BitCache();
      ## This test can not be performed in the constructor in simpleTest
      # $this->assertTrue(is_object($this->test), 'Error during initialisation');
      if (!is_object($this->test)) {
	$this = NULL;	
	return;
      }
	
    }
    
    function testGetNonexistentCachedItem()
    {
      $this->assertNull($this->test->getCached("TestBitCache"));
    }
    
    function testIsNonexistentItemCached()
    {
        $this->assertFalse($this->test->isCached("TestBitCache"));
    }

    function testRemoveNonexistentCachedItem()
    {
        $this->test->removeCached("TestBitCache");
        $this->assertFalse($this->test->isCached("TestBitCache"));
    }
    
    function testSetCachedItem()
    {
        $this->test->setCached("TestBitCache", "123");
        $this->assertTrue($this->test->isCached("TestBitCache"));
    }
    
    function testGetCachedItem()
    {
        $this->assertEqual($this->test->getCached("TestBitCache"), "123");
    }
    
    function testIsItemCached()
    {
        $this->assertTrue($this->test->isCached("TestBitCache"));
    }

    function testRemoveCachedItem()
    {
        $this->test->removeCached("TestBitCache");
        $this->assertFalse($this->test->isCached("TestBitCache") ||
			   $this->test->getCached("TestBitCache") != NULL);
    }
}
?>