testCache.php
1.21 KB
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
<?php
require_once(dirname(__FILE__) . '/../test.php');
class CacheTestCase extends KTUnitTestCase {
function testListCache() {
$f = Group::getList();
$iNumGroups = count($f);
DBUtil::startTransaction();
$g = Group::createFromArray(array(
'name' => 'foo',
));
if (!$this->assertGroup($g)) {
return;
}
$f = Group::getList();
$iNowNumGroups = count($f);
$this->assertEqual($iNumGroups + 1, $iNowNumGroups, 'New group not in list');
DBUtil::rollback();
}
function testRollback() {
$f = Group::getList();
$iNumGroups = count($f);
DBUtil::startTransaction();
$g = Group::createFromArray(array(
'name' => 'rollback',
));
if (!$this->assertGroup($g)) {
return;
}
$f = Group::getList();
$iNowNumGroups = count($f);
$this->assertEqual($iNumGroups + 1, $iNowNumGroups, 'New group not in list');
DBUtil::rollback();
$f = Group::getList();
$iRollbackNumGroups = count($f);
$this->assertEqual($iNumGroups, $iRollbackNumGroups, 'New group still in list (should be rolled back)');
}
}