More sqlite tests

This commit is contained in:
Timothy Warren 2012-03-06 16:57:43 -05:00
parent 9d2ceb49e6
commit 4ee3c3ea43
2 changed files with 37 additions and 1 deletions

View File

@ -22,10 +22,18 @@ class SQLiteTest extends UnitTestCase {
function __construct()
{
parent::__construct();
}
function setUp()
{
$path = dirname(__FILE__)."/../test_dbs/test_sqlite.db";
$this->db = new SQLite($path);
}
function tearDown()
{
unset($this->db);
}
function TestConnection()
{
@ -44,6 +52,12 @@ class SQLiteTest extends UnitTestCase {
$this->assertTrue(is_array($tables));
}
function TestCreateTransaction()
{
$res = $this->db->beginTransaction();
$this->assertTrue($res);
}
function TestCreateTable()
{
@ -89,6 +103,28 @@ SQL;
}
function TestCommitTransaction()
{
$this->TestCreateTransaction();
$sql = 'INSERT INTO "create_test" ("id", "key", "val") VALUES (10, 12, 14)';
$this->db->query($sql);
$res = $this->db->commit();
$this->assertTrue($res);
}
function TestRollbackTransaction()
{
$this->TestCreateTransaction();
$sql = 'INSERT INTO "create_test" ("id", "key", "val") VALUES (182, 96, 43)';
$this->db->query($sql);
$res = $this->db->rollback();
$this->assertTrue($res);
}
function TestDeleteTable()
{
//Make sure the table exists to delete

Binary file not shown.