Commit c1f57a9c9d8600e1fa33534fb3a17beb4410acc2
1 parent
5a2bd8c5
Convert existing test to SimpleTest unit test, and add more tests.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5405 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
40 additions
and
0 deletions
tests/cache/testCache.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +require_once(dirname(__FILE__) . '/../test.php'); | ||
| 4 | + | ||
| 5 | +class CacheTestCase extends KTUnitTestCase { | ||
| 6 | + function testListCache() { | ||
| 7 | + $f = Group::getList(); | ||
| 8 | + $iNumGroups = count($f); | ||
| 9 | + DBUtil::startTransaction(); | ||
| 10 | + $g = Group::createFromArray(array( | ||
| 11 | + 'name' => 'foo', | ||
| 12 | + )); | ||
| 13 | + if (!$this->assertGroup($g)) { | ||
| 14 | + return; | ||
| 15 | + } | ||
| 16 | + $f = Group::getList(); | ||
| 17 | + $iNowNumGroups = count($f); | ||
| 18 | + $this->assertEqual($iNumGroups + 1, $iNowNumGroups, 'New group not in list'); | ||
| 19 | + DBUtil::rollback(); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + function testRollback() { | ||
| 23 | + $f = Group::getList(); | ||
| 24 | + $iNumGroups = count($f); | ||
| 25 | + DBUtil::startTransaction(); | ||
| 26 | + $g = Group::createFromArray(array( | ||
| 27 | + 'name' => 'rollback', | ||
| 28 | + )); | ||
| 29 | + if (!$this->assertGroup($g)) { | ||
| 30 | + return; | ||
| 31 | + } | ||
| 32 | + $f = Group::getList(); | ||
| 33 | + $iNowNumGroups = count($f); | ||
| 34 | + $this->assertEqual($iNumGroups + 1, $iNowNumGroups, 'New group not in list'); | ||
| 35 | + DBUtil::rollback(); | ||
| 36 | + $f = Group::getList(); | ||
| 37 | + $iRollbackNumGroups = count($f); | ||
| 38 | + $this->assertEqual($iNumGroups, $iRollbackNumGroups, 'New group still in list (should be rolled back)'); | ||
| 39 | + } | ||
| 40 | +} |