Index: trunk/tests/CacheTest.php
===================================================================
--- trunk/tests/CacheTest.php	(revision 137)
+++ trunk/tests/CacheTest.php	(revision 137)
@@ -0,0 +1,90 @@
+<?php
+/// FIXME: Tests not implemented.
+return;
+
+/**
+ * PHPUnit test case for Cache
+ *
+ * The method skeletons below need to be filled in with
+ * real data so that the tests will run correctly. Replace
+ * all EXPECTED_VAL and PARAM strings with real data.
+ *
+ * Created with PHPUnit_Skeleton on 2005-08-09
+ */
+require_once 'PHPUnit.php';
+class CacheTest extends PHPUnit_TestCase {
+
+    var $Cache;
+
+    function CacheTest($name)
+    {
+        $this->PHPUnit_TestCase($name);
+    }
+
+    function setUp()
+    {
+        require dirname(__FILE__) . '/_config.inc.php';
+        require_once '../lib/Cache.inc.php';
+        $this->Cache =& new Cache(PARAM);
+    }
+
+    function tearDown()
+    {
+        unset($this->Cache);
+    }
+
+    function test_getinstance()
+    {
+        $result = $this->Cache->getinstance(PARAM);
+        $expected = EXPECTED_VAL;
+        $this->assertEquals($expected, $result);
+    }
+
+    function test_setparam()
+    {
+        $result = $this->Cache->setparam(PARAM);
+        $expected = EXPECTED_VAL;
+        $this->assertEquals($expected, $result);
+    }
+
+    function test_getparam()
+    {
+        $result = $this->Cache->getparam(PARAM);
+        $expected = EXPECTED_VAL;
+        $this->assertEquals($expected, $result);
+    }
+
+    function test_putcache()
+    {
+        $result = $this->Cache->putcache(PARAM);
+        $expected = EXPECTED_VAL;
+        $this->assertEquals($expected, $result);
+    }
+
+    function test_getcache()
+    {
+        $result = $this->Cache->getcache(PARAM);
+        $expected = EXPECTED_VAL;
+        $this->assertEquals($expected, $result);
+    }
+
+    function test_iscached()
+    {
+        $result = $this->Cache->iscached(PARAM);
+        $expected = EXPECTED_VAL;
+        $this->assertEquals($expected, $result);
+    }
+
+    function test_breakcache()
+    {
+        $result = $this->Cache->breakcache(PARAM);
+        $expected = EXPECTED_VAL;
+        $this->assertEquals($expected, $result);
+    }
+
+}
+// Running the test.
+$suite = new PHPUnit_TestSuite('CacheTest');
+$result = PHPUnit::run($suite);
+echo $result->toString();
+?>
Index: trunk/tests/LockTest.php
===================================================================
--- trunk/tests/LockTest.php	(revision 137)
+++ trunk/tests/LockTest.php	(revision 137)
@@ -0,0 +1,199 @@
+<?php
+/**
+ * PHPUnit test case for Lock
+ *
+ * The method skeletons below need to be filled in with
+ * real data so that the tests will run correctly. Replace
+ * all EXPECTED_VAL and PARAM strings with real data.
+ *
+ * Created with PHPUnit_Skeleton on 2005-08-09
+ */
+require_once 'PHPUnit.php';
+class LockTest extends PHPUnit_TestCase {
+
+    var $Lock;
+    var $Auth_SQL;
+
+    function LockTest($name)
+    {
+        $this->PHPUnit_TestCase($name);
+    }
+
+    function setUp()
+    {	
+        require dirname(__FILE__) . '/_config.inc.php';
+        require_once '../lib/Lock.inc.php';
+        require_once '../lib/Auth_SQL.inc.php';
+
+        $this->Auth_SQL =& new Auth_SQL('test');
+        $this->Auth_SQL->setParam(array(
+            'db_table'          => 'test_user_tbl',
+            'db_primary_key'    => 'user_id',
+            'db_login_table'    => 'test_login_tbl',
+            'login_url'         => '/login.php',
+            'blocking'          => true
+        ));
+
+        // Use fresh user table.
+        $this->Auth_SQL->initDB(true);
+
+        // Insert test data.
+        $db =& DB::getInstance();
+        $db->query("
+            INSERT INTO test_user_tbl (
+                username,
+                userpass,
+                first_name,
+                last_name,
+                email,
+                user_type
+            ) VALUES (
+                'testuser',
+                '" . $this->Auth_SQL->encryptPassword('testpass') . "',
+                'John',
+                'Doe',
+                'john@example.com',
+                'admin'
+            )
+        ");
+        $this->Auth_SQL->login('testuser', 'testpass');
+
+        if (!$this->Auth_SQL->isLoggedIn()) {
+            trigger_error("User login failed...tests canceled.", E_USER_ERROR);
+        }
+
+        $this->Lock =& Lock::getInstance($this->Auth_SQL);
+        $this->Lock->setParam(array('db_table' => 'test_lock_tbl'));
+
+        // Use fresh lock table.
+        $this->Lock->initDB(true);
+    }
+
+    function tearDown()
+    {
+		$db =& DB::getInstance();
+	
+        unset($this->Lock);
+        unset($this->Auth_SQL);
+        $db->query("DROP TABLE IF EXISTS test_user_tbl");
+        $db->query("DROP TABLE IF EXISTS test_login_tbl");
+        $db->query("DROP TABLE IF EXISTS test_lock_tbl");
+    }
+
+    function test_getinstance()
+    {
+        $result = Lock::getinstance($this->Auth_SQL);
+        $this->assertTrue($result && is_a($result, 'Lock'));
+    }
+
+    function test_setparam()
+    {
+        $this->Lock->setparam(array('var'=>'val'));
+    }
+
+    function test_getparam()
+    {
+        $this->Lock->getparam('var');
+    }
+
+    function test_select()
+    {
+        $this->Lock->set('test_user_tbl', 'user_id', '1');
+        $result = $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $this->assertTrue($result);
+    }
+
+    function test_islocked()
+    {
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+
+        $this->Lock->set('test_user_tbl', 'user_id', '1');
+        $result = $this->Lock->islocked();
+        $this->assertTrue($result, 'Lock was not set.');
+
+        $this->Lock->remove();
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $result = $this->Lock->islocked();
+        $this->assertFalse($result, 'Lock was not removed.');
+    }
+
+    function test_ismine()
+    {
+        $this->Lock->set('test_user_tbl', 'user_id', '1');
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $result = $this->Lock->ismine();
+        $this->assertTrue($result);
+    }
+
+    function test_set()
+    {
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $this->Lock->remove();
+        $this->Lock->set('test_user_tbl', 'user_id', '1');
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $result = $this->Lock->islocked();
+        $this->assertTrue($result);
+    }
+
+    function test_remove()
+    {
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $this->Lock->set('test_user_tbl', 'user_id', '1');
+        $this->Lock->remove();
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $result = $this->Lock->islocked();
+        $this->assertFalse($result);
+    }
+
+    function test_removeall()
+    {
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $this->Lock->set('test_user_tbl', 'user_id', '1');
+        $this->Lock->removeall();
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $result = $this->Lock->islocked();
+        $this->assertFalse($result);
+    }
+
+    function test__auto_timeout()
+    {
+        $this->Lock->_auto_timeout();
+    }
+
+    function test_getid()
+    {
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $this->Lock->set('test_user_tbl', 'user_id', '1');
+        $result = $this->Lock->getid();
+        $this->assertTrue('' != $result);
+        $this->assertTrue(is_numeric($result));
+    }
+
+    function test_gettitle()
+    {
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $this->Lock->set('test_user_tbl', 'user_id', '1', 'userlock');
+        $result = $this->Lock->gettitle();
+        $this->assertEquals('userlock', $result);
+    }
+
+    function test_geteditor()
+    {
+        $this->Lock->select('test_user_tbl', 'user_id', '1');
+        $this->Lock->set('test_user_tbl', 'user_id', '1', 'userlock');
+        $result = $this->Lock->geteditor();
+        $this->assertEquals('testuser', $result);
+    }
+
+    function test_getsecondselapsed()
+    {
+        $result = $this->Lock->getsecondselapsed();
+        $this->assertType('integer', $result);
+    }
+
+}
+// Running the test.
+$suite = new PHPUnit_TestSuite('LockTest');
+$result = PHPUnit::run($suite);
+echo $result->toString();
+?>
Index: trunk/tests/RecordLockTest.php
===================================================================
--- trunk/tests/RecordLockTest.php	(revision 136)
+++ 	(revision )
@@ -1,199 +1,0 @@
-<?php
-/**
- * PHPUnit test case for RecordLock
- *
- * The method skeletons below need to be filled in with
- * real data so that the tests will run correctly. Replace
- * all EXPECTED_VAL and PARAM strings with real data.
- *
- * Created with PHPUnit_Skeleton on 2005-08-09
- */
-require_once 'PHPUnit.php';
-class RecordLockTest extends PHPUnit_TestCase {
-
-    var $RecordLock;
-    var $Auth_SQL;
-
-    function RecordLockTest($name)
-    {
-        $this->PHPUnit_TestCase($name);
-    }
-
-    function setUp()
-    {	
-        require dirname(__FILE__) . '/_config.inc.php';
-        require_once '../lib/RecordLock.inc.php';
-        require_once '../lib/Auth_SQL.inc.php';
-
-        $this->Auth_SQL =& new Auth_SQL('test');
-        $this->Auth_SQL->setParam(array(
-            'db_table'          => 'test_user_tbl',
-            'db_primary_key'    => 'user_id',
-            'db_login_table'    => 'test_login_tbl',
-            'login_url'         => '/login.php',
-            'blocking'          => true
-        ));
-
-        // Use fresh user table.
-        $this->Auth_SQL->initDB(true);
-
-        // Insert test data.
-        $db =& DB::getInstance();
-        $db->query("
-            INSERT INTO test_user_tbl (
-                username,
-                userpass,
-                first_name,
-                last_name,
-                email,
-                user_type
-            ) VALUES (
-                'testuser',
-                '" . $this->Auth_SQL->encryptPassword('testpass') . "',
-                'John',
-                'Doe',
-                'john@example.com',
-                'admin'
-            )
-        ");
-        $this->Auth_SQL->login('testuser', 'testpass');
-
-        if (!$this->Auth_SQL->isLoggedIn()) {
-            trigger_error("User login failed...tests canceled.", E_USER_ERROR);
-        }
-
-        $this->RecordLock =& RecordLock::getInstance($this->Auth_SQL);
-        $this->RecordLock->setParam(array('db_table' => 'test_lock_tbl'));
-
-        // Use fresh lock table.
-        $this->RecordLock->initDB(true);
-    }
-
-    function tearDown()
-    {
-		$db =& DB::getInstance();
-	
-        unset($this->RecordLock);
-        unset($this->Auth_SQL);
-        $db->query("DROP TABLE IF EXISTS test_user_tbl");
-        $db->query("DROP TABLE IF EXISTS test_login_tbl");
-        $db->query("DROP TABLE IF EXISTS test_lock_tbl");
-    }
-
-    function test_getinstance()
-    {
-        $result = RecordLock::getinstance($this->Auth_SQL);
-        $this->assertTrue($result && is_a($result, 'RecordLock'));
-    }
-
-    function test_setparam()
-    {
-        $this->RecordLock->setparam(array('var'=>'val'));
-    }
-
-    function test_getparam()
-    {
-        $this->RecordLock->getparam('var');
-    }
-
-    function test_select()
-    {
-        $this->RecordLock->set('test_user_tbl', 'user_id', '1');
-        $result = $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $this->assertTrue($result);
-    }
-
-    function test_islocked()
-    {
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-
-        $this->RecordLock->set('test_user_tbl', 'user_id', '1');
-        $result = $this->RecordLock->islocked();
-        $this->assertTrue($result, 'Lock was not set.');
-
-        $this->RecordLock->remove();
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $result = $this->RecordLock->islocked();
-        $this->assertFalse($result, 'Lock was not removed.');
-    }
-
-    function test_ismine()
-    {
-        $this->RecordLock->set('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $result = $this->RecordLock->ismine();
-        $this->assertTrue($result);
-    }
-
-    function test_set()
-    {
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->remove();
-        $this->RecordLock->set('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $result = $this->RecordLock->islocked();
-        $this->assertTrue($result);
-    }
-
-    function test_remove()
-    {
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->set('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->remove();
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $result = $this->RecordLock->islocked();
-        $this->assertFalse($result);
-    }
-
-    function test_removeall()
-    {
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->set('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->removeall();
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $result = $this->RecordLock->islocked();
-        $this->assertFalse($result);
-    }
-
-    function test__auto_timeout()
-    {
-        $this->RecordLock->_auto_timeout();
-    }
-
-    function test_getid()
-    {
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->set('test_user_tbl', 'user_id', '1');
-        $result = $this->RecordLock->getid();
-        $this->assertTrue('' != $result);
-        $this->assertTrue(is_numeric($result));
-    }
-
-    function test_gettitle()
-    {
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->set('test_user_tbl', 'user_id', '1', 'userlock');
-        $result = $this->RecordLock->gettitle();
-        $this->assertEquals('userlock', $result);
-    }
-
-    function test_geteditor()
-    {
-        $this->RecordLock->select('test_user_tbl', 'user_id', '1');
-        $this->RecordLock->set('test_user_tbl', 'user_id', '1', 'userlock');
-        $result = $this->RecordLock->geteditor();
-        $this->assertEquals('testuser', $result);
-    }
-
-    function test_getsecondselapsed()
-    {
-        $result = $this->RecordLock->getsecondselapsed();
-        $this->assertType('integer', $result);
-    }
-
-}
-// Running the test.
-$suite = new PHPUnit_TestSuite('RecordLockTest');
-$result = PHPUnit::run($suite);
-echo $result->toString();
-?>
Index: trunk/tests/RecordVersionTest.php
===================================================================
--- trunk/tests/RecordVersionTest.php	(revision 136)
+++ 	(revision )
@@ -1,177 +1,0 @@
-<?php
-/**
- * PHPUnit test case for RecordVersion
- *
- * The method skeletons below need to be filled in with
- * real data so that the tests will run correctly. Replace
- * all EXPECTED_VAL and PARAM strings with real data.
- *
- * Created with PHPUnit_Skeleton on 2005-08-09
- */
-require_once 'PHPUnit.php';
-class RecordVersionTest extends PHPUnit_TestCase {
-
-    var $RecordVersion;
-    var $Auth_SQL;
-
-    function RecordVersionTest($name)
-    {
-        $this->PHPUnit_TestCase($name);
-    }
-
-    function setUp()
-    {	
-        require dirname(__FILE__) . '/_config.inc.php';
-        require_once '../lib/RecordVersion.inc.php';
-
-        require_once '../lib/Auth_SQL.inc.php';
-        $this->Auth_SQL =& new Auth_SQL('testauth');
-        $this->Auth_SQL->setParam(array(
-            'db_table'          => 'test_user_tbl',
-            'db_primary_key'    => 'user_id',
-            'db_login_table'    => 'test_login_tbl',
-            'login_url'         => '/login.php',
-            'blocking'          => true
-        ));
-
-        // Use fresh user table.
-        $this->Auth_SQL->initDB(true);
-
-        // Insert test data.
-        $db =& DB::getInstance();
-        $db->query("
-            INSERT INTO test_user_tbl (
-                username,
-                userpass,
-                first_name,
-                last_name,
-                email,
-                user_type
-            ) VALUES (
-                'testuser',
-                md5('testpass'),
-                'John',
-                'Doe',
-                'john@example.com',
-                'admin'
-            )
-        ");
-
-        $this->Auth_SQL->login('testuser', 'testpass');
-
-        $this->RecordVersion =& RecordVersion::getInstance($this->Auth_SQL);
-        $this->RecordVersion->setParam(array('db_table' => 'test_version_tbl'));
-
-        // Use fresh version table.
-        $this->RecordVersion->initDB(true);
-    }
-
-    function tearDown()
-    {
-		$db =& DB::getInstance();
-	
-        unset($this->RecordVersion);
-        unset($this->Auth_SQL);
-        $db->query("DROP TABLE IF EXISTS test_user_tbl");
-        $db->query("DROP TABLE IF EXISTS test_login_tbl");
-        $db->query("DROP TABLE IF EXISTS test_version_tbl");
-    }
-
-    function test_getinstance()
-    {
-        $result = RecordVersion::getinstance($this->Auth_SQL);
-        $this->assertTrue($result && is_a($result, 'RecordVersion'));
-    }
-
-    function test_setparam()
-    {
-        $this->RecordVersion->setparam(array('var'=>'val'));
-    }
-
-    function test_getparam()
-    {
-        $this->RecordVersion->getparam('var');
-    }
-
-    function test_create()
-    {
-        $result = $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
-        $this->assertTrue($result);
-    }
-
-    function test_restore()
-    {
-        $current = $this->RecordVersion->getCurrent('test_user_tbl', 'user_id', '1');
-        $version_id = $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
-        $versioned = $this->RecordVersion->getData($version_id);
-        $result = $this->RecordVersion->restore($version_id);
-        $restored = $this->RecordVersion->getCurrent('test_user_tbl', 'user_id', '1');
-        $this->assertTrue(is_array($result), 'Restore did not return array.');
-        $this->assertTrue($current === $versioned && $versioned === $restored, 'Restored version does not match original.');
-    }
-
-    function test_deleteold()
-    {
-        // Creat 3 test versions.
-        $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 1', '1 version of user');
-        $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 2', '2 version of user');
-        $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 3', '3 version of user');
-
-        $a = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
-
-        $this->RecordVersion->deleteold('test_user_tbl', 'user_id', '1');
-        $b = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
-
-        $this->RecordVersion->setparam(array('max_qty'=>2));
-        $this->RecordVersion->setparam(array('min_qty'=>1));
-        $this->RecordVersion->setparam(array('min_days'=>0));
-        $this->RecordVersion->deleteold('test_user_tbl', 'user_id', '1');
-        $c = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
-
-        $this->RecordVersion->setparam(array('max_qty'=>0));
-        $this->RecordVersion->setparam(array('min_qty'=>0));
-        $this->RecordVersion->setparam(array('min_days'=>0));
-        $this->RecordVersion->deleteold('test_user_tbl', 'user_id', '1');
-        $d = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
-
-        $this->assertTrue(sizeof($a) == 3, 'A is wrong');
-        $this->assertTrue(sizeof($b) == 3, 'B is wrong');
-        $this->assertTrue(sizeof($c) == 1, 'C is wrong');
-        $this->assertTrue(sizeof($d) == 0, 'D is wrong');
-    }
-
-    function test_getlist()
-    {
-        $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 1', '1 version of user');
-        $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 2', '2 version of user');
-        $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 3', '3 version of user');
-        $result = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
-        $this->assertTrue(is_array($result) && !empty($result));
-    }
-
-    function test_getverson()
-    {
-        $version_id = $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
-        $result = $this->RecordVersion->getverson($version_id);
-        $this->assertTrue(is_array($result) && !empty($result));
-    }
-
-    function test_getdata()
-    {
-        $version_id = $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
-        $result = $this->RecordVersion->getdata($version_id);
-        $this->assertTrue(is_array($result) && !empty($result));
-    }
-
-    function test_getcurrent()
-    {
-        $result = $this->RecordVersion->getCurrent('test_user_tbl', 'user_id', '1');
-        $this->assertTrue(is_array($result) && !empty($result));
-    }
-
-}
-// Running the test.
-$suite = new PHPUnit_TestSuite('RecordVersionTest');
-$result = PHPUnit::run($suite);
-echo $result->toString();
-?>
Index: trunk/tests/SessionCacheTest.php
===================================================================
--- trunk/tests/SessionCacheTest.php	(revision 136)
+++ 	(revision )
@@ -1,90 +1,0 @@
-<?php
-/// FIXME: Tests not implemented.
-return;
-
-/**
- * PHPUnit test case for Cache
- *
- * The method skeletons below need to be filled in with
- * real data so that the tests will run correctly. Replace
- * all EXPECTED_VAL and PARAM strings with real data.
- *
- * Created with PHPUnit_Skeleton on 2005-08-09
- */
-require_once 'PHPUnit.php';
-class CacheTest extends PHPUnit_TestCase {
-
-    var $Cache;
-
-    function CacheTest($name)
-    {
-        $this->PHPUnit_TestCase($name);
-    }
-
-    function setUp()
-    {
-        require dirname(__FILE__) . '/_config.inc.php';
-        require_once '../lib/Cache.inc.php';
-        $this->Cache =& new Cache(PARAM);
-    }
-
-    function tearDown()
-    {
-        unset($this->Cache);
-    }
-
-    function test_getinstance()
-    {
-        $result = $this->Cache->getinstance(PARAM);
-        $expected = EXPECTED_VAL;
-        $this->assertEquals($expected, $result);
-    }
-
-    function test_setparam()
-    {
-        $result = $this->Cache->setparam(PARAM);
-        $expected = EXPECTED_VAL;
-        $this->assertEquals($expected, $result);
-    }
-
-    function test_getparam()
-    {
-        $result = $this->Cache->getparam(PARAM);
-        $expected = EXPECTED_VAL;
-        $this->assertEquals($expected, $result);
-    }
-
-    function test_putcache()
-    {
-        $result = $this->Cache->putcache(PARAM);
-        $expected = EXPECTED_VAL;
-        $this->assertEquals($expected, $result);
-    }
-
-    function test_getcache()
-    {
-        $result = $this->Cache->getcache(PARAM);
-        $expected = EXPECTED_VAL;
-        $this->assertEquals($expected, $result);
-    }
-
-    function test_iscached()
-    {
-        $result = $this->Cache->iscached(PARAM);
-        $expected = EXPECTED_VAL;
-        $this->assertEquals($expected, $result);
-    }
-
-    function test_breakcache()
-    {
-        $result = $this->Cache->breakcache(PARAM);
-        $expected = EXPECTED_VAL;
-        $this->assertEquals($expected, $result);
-    }
-
-}
-// Running the test.
-$suite = new PHPUnit_TestSuite('CacheTest');
-$result = PHPUnit::run($suite);
-echo $result->toString();
-?>
Index: trunk/tests/VersionTest.php
===================================================================
--- trunk/tests/VersionTest.php	(revision 137)
+++ trunk/tests/VersionTest.php	(revision 137)
@@ -0,0 +1,177 @@
+<?php
+/**
+ * PHPUnit test case for Version
+ *
+ * The method skeletons below need to be filled in with
+ * real data so that the tests will run correctly. Replace
+ * all EXPECTED_VAL and PARAM strings with real data.
+ *
+ * Created with PHPUnit_Skeleton on 2005-08-09
+ */
+require_once 'PHPUnit.php';
+class VersionTest extends PHPUnit_TestCase {
+
+    var $Version;
+    var $Auth_SQL;
+
+    function VersionTest($name)
+    {
+        $this->PHPUnit_TestCase($name);
+    }
+
+    function setUp()
+    {	
+        require dirname(__FILE__) . '/_config.inc.php';
+        require_once '../lib/Version.inc.php';
+
+        require_once '../lib/Auth_SQL.inc.php';
+        $this->Auth_SQL =& new Auth_SQL('testauth');
+        $this->Auth_SQL->setParam(array(
+            'db_table'          => 'test_user_tbl',
+            'db_primary_key'    => 'user_id',
+            'db_login_table'    => 'test_login_tbl',
+            'login_url'         => '/login.php',
+            'blocking'          => true
+        ));
+
+        // Use fresh user table.
+        $this->Auth_SQL->initDB(true);
+
+        // Insert test data.
+        $db =& DB::getInstance();
+        $db->query("
+            INSERT INTO test_user_tbl (
+                username,
+                userpass,
+                first_name,
+                last_name,
+                email,
+                user_type
+            ) VALUES (
+                'testuser',
+                md5('testpass'),
+                'John',
+                'Doe',
+                'john@example.com',
+                'admin'
+            )
+        ");
+
+        $this->Auth_SQL->login('testuser', 'testpass');
+
+        $this->Version =& Version::getInstance($this->Auth_SQL);
+        $this->Version->setParam(array('db_table' => 'test_version_tbl'));
+
+        // Use fresh version table.
+        $this->Version->initDB(true);
+    }
+
+    function tearDown()
+    {
+		$db =& DB::getInstance();
+	
+        unset($this->Version);
+        unset($this->Auth_SQL);
+        $db->query("DROP TABLE IF EXISTS test_user_tbl");
+        $db->query("DROP TABLE IF EXISTS test_login_tbl");
+        $db->query("DROP TABLE IF EXISTS test_version_tbl");
+    }
+
+    function test_getinstance()
+    {
+        $result = Version::getinstance($this->Auth_SQL);
+        $this->assertTrue($result && is_a($result, 'Version'));
+    }
+
+    function test_setparam()
+    {
+        $this->Version->setparam(array('var'=>'val'));
+    }
+
+    function test_getparam()
+    {
+        $this->Version->getparam('var');
+    }
+
+    function test_create()
+    {
+        $result = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
+        $this->assertTrue($result);
+    }
+
+    function test_restore()
+    {
+        $current = $this->Version->getCurrent('test_user_tbl', 'user_id', '1');
+        $version_id = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
+        $versioned = $this->Version->getData($version_id);
+        $result = $this->Version->restore($version_id);
+        $restored = $this->Version->getCurrent('test_user_tbl', 'user_id', '1');
+        $this->assertTrue(is_array($result), 'Restore did not return array.');
+        $this->assertTrue($current === $versioned && $versioned === $restored, 'Restored version does not match original.');
+    }
+
+    function test_deleteold()
+    {
+        // Creat 3 test versions.
+        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 1', '1 version of user');
+        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 2', '2 version of user');
+        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 3', '3 version of user');
+
+        $a = $this->Version->getList('test_user_tbl', 'user_id', '1');
+
+        $this->Version->deleteold('test_user_tbl', 'user_id', '1');
+        $b = $this->Version->getList('test_user_tbl', 'user_id', '1');
+
+        $this->Version->setparam(array('max_qty'=>2));
+        $this->Version->setparam(array('min_qty'=>1));
+        $this->Version->setparam(array('min_days'=>0));
+        $this->Version->deleteold('test_user_tbl', 'user_id', '1');
+        $c = $this->Version->getList('test_user_tbl', 'user_id', '1');
+
+        $this->Version->setparam(array('max_qty'=>0));
+        $this->Version->setparam(array('min_qty'=>0));
+        $this->Version->setparam(array('min_days'=>0));
+        $this->Version->deleteold('test_user_tbl', 'user_id', '1');
+        $d = $this->Version->getList('test_user_tbl', 'user_id', '1');
+
+        $this->assertTrue(sizeof($a) == 3, 'A is wrong');
+        $this->assertTrue(sizeof($b) == 3, 'B is wrong');
+        $this->assertTrue(sizeof($c) == 1, 'C is wrong');
+        $this->assertTrue(sizeof($d) == 0, 'D is wrong');
+    }
+
+    function test_getlist()
+    {
+        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 1', '1 version of user');
+        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 2', '2 version of user');
+        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 3', '3 version of user');
+        $result = $this->Version->getList('test_user_tbl', 'user_id', '1');
+        $this->assertTrue(is_array($result) && !empty($result));
+    }
+
+    function test_getverson()
+    {
+        $version_id = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
+        $result = $this->Version->getverson($version_id);
+        $this->assertTrue(is_array($result) && !empty($result));
+    }
+
+    function test_getdata()
+    {
+        $version_id = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
+        $result = $this->Version->getdata($version_id);
+        $this->assertTrue(is_array($result) && !empty($result));
+    }
+
+    function test_getcurrent()
+    {
+        $result = $this->Version->getCurrent('test_user_tbl', 'user_id', '1');
+        $this->assertTrue(is_array($result) && !empty($result));
+    }
+
+}
+// Running the test.
+$suite = new PHPUnit_TestSuite('VersionTest');
+$result = PHPUnit::run($suite);
+echo $result->toString();
+?>
