Fix tests

This commit is contained in:
Timothy Warren 2012-04-10 11:24:35 -04:00
parent 3643d3066f
commit 05ec65091f
4 changed files with 127 additions and 54 deletions

View File

@ -48,60 +48,6 @@ abstract class DBTest extends UnitTestCase {
$res = $this->db->beginTransaction(); $res = $this->db->beginTransaction();
$this->assertTrue($res); $this->assertTrue($res);
} }
function TestPreparedStatements()
{
if (empty($this->db)) return;
$sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val")
VALUES (?,?,?)
SQL;
$statement = $this->db->prepare_query($sql, array(1,"boogers", "Gross"));
$statement->execute();
}
function TestPrepareExecute()
{
if (empty($this->db)) return;
$sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val")
VALUES (?,?,?)
SQL;
$this->db->prepare_execute($sql, array(
2, "works", 'also?'
));
}
function TestCommitTransaction()
{
if (empty($this->db)) return;
$res = $this->db->beginTransaction();
$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()
{
if (empty($this->db)) return;
$res = $this->db->beginTransaction();
$sql = 'INSERT INTO "create_test" ("id", "key", "val") VALUES (182, 96, 43)';
$this->db->query($sql);
$res = $this->db->rollback();
$this->assertTrue($res);
}
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -236,6 +182,7 @@ abstract class QBTest extends UnitTestCase {
->where('id >', 0) ->where('id >', 0)
->where('id <', 9000) ->where('id <', 9000)
->group_by('k') ->group_by('k')
->group_by('id')
->group_by('val') ->group_by('val')
->order_by('id', 'DESC') ->order_by('id', 'DESC')
->order_by('k', 'ASC') ->order_by('k', 'ASC')

View File

@ -85,6 +85,69 @@ class MySQLTest extends DBTest {
} }
function TestTruncate()
{
$this->db->truncate('create_test');
$this->db->truncate('create_join');
$ct_query = $this->db->query('SELECT * FROM create_test');
$cj_query = $this->db->query('SELECT * FROM create_join');
}
function TestPreparedStatements()
{
if (empty($this->db)) return;
$sql = <<<SQL
INSERT INTO `create_test` (`id`, `key`, `val`)
VALUES (?,?,?)
SQL;
$statement = $this->db->prepare_query($sql, array(1,"boogers", "Gross"));
$statement->execute();
}
function TestPrepareExecute()
{
if (empty($this->db)) return;
$sql = <<<SQL
INSERT INTO `create_test` (`id`, `key`, `val`)
VALUES (?,?,?)
SQL;
$this->db->prepare_execute($sql, array(
2, "works", 'also?'
));
}
function TestCommitTransaction()
{
if (empty($this->db)) return;
$res = $this->db->beginTransaction();
$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()
{
if (empty($this->db)) return;
$res = $this->db->beginTransaction();
$sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (182, 96, 43)';
$this->db->query($sql);
$res = $this->db->rollback();
$this->assertTrue($res);
}
function TestGetSchemas() function TestGetSchemas()
{ {
$this->assertFalse($this->db->get_schemas()); $this->assertFalse($this->db->get_schemas());

View File

@ -102,6 +102,69 @@ class PgTest extends DBTest {
} }
function TestTruncate()
{
$this->db->truncate('create_test');
$this->db->truncate('create_join');
$ct_query = $this->db->query('SELECT * FROM create_test');
$cj_query = $this->db->query('SELECT * FROM create_join');
}
function TestPreparedStatements()
{
if (empty($this->db)) return;
$sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val")
VALUES (?,?,?)
SQL;
$statement = $this->db->prepare_query($sql, array(1,"boogers", "Gross"));
$statement->execute();
}
function TestPrepareExecute()
{
if (empty($this->db)) return;
$sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val")
VALUES (?,?,?)
SQL;
$this->db->prepare_execute($sql, array(
2, "works", 'also?'
));
}
function TestCommitTransaction()
{
if (empty($this->db)) return;
$res = $this->db->beginTransaction();
$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()
{
if (empty($this->db)) return;
$res = $this->db->beginTransaction();
$sql = 'INSERT INTO "create_test" ("id", "key", "val") VALUES (182, 96, 43)';
$this->db->query($sql);
$res = $this->db->rollback();
$this->assertTrue($res);
}
function TestGetSchemas() function TestGetSchemas()
{ {
$this->assertTrue(is_array($this->db->get_schemas())); $this->assertTrue(is_array($this->db->get_schemas()));

Binary file not shown.