Ignore:
Timestamp:
Jun 3, 2006 8:15:06 PM (18 years ago)
Author:
scdev
Message:

Q - Renamed SessionCache? to Cache, RecordVersion? to Version, and RecordLock? to Lock

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/VersionTest.php

    r136 r137  
    11<?php
    22/**
    3  * PHPUnit test case for RecordVersion
     3 * PHPUnit test case for Version
    44 *
    55 * The method skeletons below need to be filled in with
     
    1010 */
    1111require_once 'PHPUnit.php';
    12 class RecordVersionTest extends PHPUnit_TestCase {
     12class VersionTest extends PHPUnit_TestCase {
    1313
    14     var $RecordVersion;
     14    var $Version;
    1515    var $Auth_SQL;
    1616
    17     function RecordVersionTest($name)
     17    function VersionTest($name)
    1818    {
    1919        $this->PHPUnit_TestCase($name);
     
    2323    {   
    2424        require dirname(__FILE__) . '/_config.inc.php';
    25         require_once '../lib/RecordVersion.inc.php';
     25        require_once '../lib/Version.inc.php';
    2626
    2727        require_once '../lib/Auth_SQL.inc.php';
     
    6060        $this->Auth_SQL->login('testuser', 'testpass');
    6161
    62         $this->RecordVersion =& RecordVersion::getInstance($this->Auth_SQL);
    63         $this->RecordVersion->setParam(array('db_table' => 'test_version_tbl'));
     62        $this->Version =& Version::getInstance($this->Auth_SQL);
     63        $this->Version->setParam(array('db_table' => 'test_version_tbl'));
    6464
    6565        // Use fresh version table.
    66         $this->RecordVersion->initDB(true);
     66        $this->Version->initDB(true);
    6767    }
    6868
     
    7171        $db =& DB::getInstance();
    7272   
    73         unset($this->RecordVersion);
     73        unset($this->Version);
    7474        unset($this->Auth_SQL);
    7575        $db->query("DROP TABLE IF EXISTS test_user_tbl");
     
    8080    function test_getinstance()
    8181    {
    82         $result = RecordVersion::getinstance($this->Auth_SQL);
    83         $this->assertTrue($result && is_a($result, 'RecordVersion'));
     82        $result = Version::getinstance($this->Auth_SQL);
     83        $this->assertTrue($result && is_a($result, 'Version'));
    8484    }
    8585
    8686    function test_setparam()
    8787    {
    88         $this->RecordVersion->setparam(array('var'=>'val'));
     88        $this->Version->setparam(array('var'=>'val'));
    8989    }
    9090
    9191    function test_getparam()
    9292    {
    93         $this->RecordVersion->getparam('var');
     93        $this->Version->getparam('var');
    9494    }
    9595
    9696    function test_create()
    9797    {
    98         $result = $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
     98        $result = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
    9999        $this->assertTrue($result);
    100100    }
     
    102102    function test_restore()
    103103    {
    104         $current = $this->RecordVersion->getCurrent('test_user_tbl', 'user_id', '1');
    105         $version_id = $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
    106         $versioned = $this->RecordVersion->getData($version_id);
    107         $result = $this->RecordVersion->restore($version_id);
    108         $restored = $this->RecordVersion->getCurrent('test_user_tbl', 'user_id', '1');
     104        $current = $this->Version->getCurrent('test_user_tbl', 'user_id', '1');
     105        $version_id = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
     106        $versioned = $this->Version->getData($version_id);
     107        $result = $this->Version->restore($version_id);
     108        $restored = $this->Version->getCurrent('test_user_tbl', 'user_id', '1');
    109109        $this->assertTrue(is_array($result), 'Restore did not return array.');
    110110        $this->assertTrue($current === $versioned && $versioned === $restored, 'Restored version does not match original.');
     
    114114    {
    115115        // Creat 3 test versions.
    116         $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 1', '1 version of user');
    117         $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 2', '2 version of user');
    118         $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 3', '3 version of user');
     116        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 1', '1 version of user');
     117        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 2', '2 version of user');
     118        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 3', '3 version of user');
    119119
    120         $a = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
     120        $a = $this->Version->getList('test_user_tbl', 'user_id', '1');
    121121
    122         $this->RecordVersion->deleteold('test_user_tbl', 'user_id', '1');
    123         $b = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
     122        $this->Version->deleteold('test_user_tbl', 'user_id', '1');
     123        $b = $this->Version->getList('test_user_tbl', 'user_id', '1');
    124124
    125         $this->RecordVersion->setparam(array('max_qty'=>2));
    126         $this->RecordVersion->setparam(array('min_qty'=>1));
    127         $this->RecordVersion->setparam(array('min_days'=>0));
    128         $this->RecordVersion->deleteold('test_user_tbl', 'user_id', '1');
    129         $c = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
     125        $this->Version->setparam(array('max_qty'=>2));
     126        $this->Version->setparam(array('min_qty'=>1));
     127        $this->Version->setparam(array('min_days'=>0));
     128        $this->Version->deleteold('test_user_tbl', 'user_id', '1');
     129        $c = $this->Version->getList('test_user_tbl', 'user_id', '1');
    130130
    131         $this->RecordVersion->setparam(array('max_qty'=>0));
    132         $this->RecordVersion->setparam(array('min_qty'=>0));
    133         $this->RecordVersion->setparam(array('min_days'=>0));
    134         $this->RecordVersion->deleteold('test_user_tbl', 'user_id', '1');
    135         $d = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
     131        $this->Version->setparam(array('max_qty'=>0));
     132        $this->Version->setparam(array('min_qty'=>0));
     133        $this->Version->setparam(array('min_days'=>0));
     134        $this->Version->deleteold('test_user_tbl', 'user_id', '1');
     135        $d = $this->Version->getList('test_user_tbl', 'user_id', '1');
    136136
    137137        $this->assertTrue(sizeof($a) == 3, 'A is wrong');
     
    143143    function test_getlist()
    144144    {
    145         $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 1', '1 version of user');
    146         $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 2', '2 version of user');
    147         $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test 3', '3 version of user');
    148         $result = $this->RecordVersion->getList('test_user_tbl', 'user_id', '1');
     145        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 1', '1 version of user');
     146        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 2', '2 version of user');
     147        $this->Version->create('test_user_tbl', 'user_id', '1', 'Test 3', '3 version of user');
     148        $result = $this->Version->getList('test_user_tbl', 'user_id', '1');
    149149        $this->assertTrue(is_array($result) && !empty($result));
    150150    }
     
    152152    function test_getverson()
    153153    {
    154         $version_id = $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
    155         $result = $this->RecordVersion->getverson($version_id);
     154        $version_id = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
     155        $result = $this->Version->getverson($version_id);
    156156        $this->assertTrue(is_array($result) && !empty($result));
    157157    }
     
    159159    function test_getdata()
    160160    {
    161         $version_id = $this->RecordVersion->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
    162         $result = $this->RecordVersion->getdata($version_id);
     161        $version_id = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
     162        $result = $this->Version->getdata($version_id);
    163163        $this->assertTrue(is_array($result) && !empty($result));
    164164    }
     
    166166    function test_getcurrent()
    167167    {
    168         $result = $this->RecordVersion->getCurrent('test_user_tbl', 'user_id', '1');
     168        $result = $this->Version->getCurrent('test_user_tbl', 'user_id', '1');
    169169        $this->assertTrue(is_array($result) && !empty($result));
    170170    }
     
    172172}
    173173// Running the test.
    174 $suite = new PHPUnit_TestSuite('RecordVersionTest');
     174$suite = new PHPUnit_TestSuite('VersionTest');
    175175$result = PHPUnit::run($suite);
    176176echo $result->toString();
Note: See TracChangeset for help on using the changeset viewer.