/
CacheTest.php
73 lines (59 loc) · 1.72 KB
/
CacheTest.php
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
62
63
64
65
66
67
68
69
70
71
72
<?php
require_once 'Cache.php';
require_once 'PHPUnit/Framework/TestCase.php';
/**
* Cache test case.
*/
class CacheTest extends PHPUnit_Framework_TestCase {
/**
* @var Cache
*/
private $Cache;
/**
* Prepares the environment before running a test.
*/
protected function setUp() {
parent::setUp ();
}
/**
* Cleans up the environment after running a test.
*/
protected function tearDown() {
$this->Cache = null;
parent::tearDown ();
}
/**
* Tests Cache->Cache()
*/
public function testCacheNoContainer() {
$this->Cache = New Cache('_otherContainer_');
$this->assertInstanceOf('Cache_Error', $this->Cache->container);
}
public function testCacheCoveredContainer() {
$this->Cache = New Cache('file');
$this->assertInstanceOf('Cache_Container_file', $this->Cache->container);
}
public function testCacheInvalidOptionType() {
$this->Cache = New Cache('file', 'wrong_parameter_type_need_be_array');
$this->assertInstanceOf('Cache_Error', $this->Cache->container);
}
/**
* Test Cache setCaching
*/
public function testCachegetCaching() {
$this->Cache = New Cache('file');
$this->assertTrue($this->Cache->getCaching());
$this->Cache->setCaching(false);
$this->assertFalse($this->Cache->getCaching());
}
/**
* Tests Cache->generateID()
*/
public function testGenerateID() {
$this->Cache = New Cache('file');
$name = 'samplename';
$expectedID = '2081d6c6cc5f4593df2c149db6b30eda';
$id = $this->Cache->generateID($name);
$this->assertEquals($expectedID, $id);
}
}