From 05ec65091f868bb4e968f043132acadc057dea9a Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 10 Apr 2012 11:24:35 -0400 Subject: [PATCH] Fix tests --- tests/core/parent.php | 55 +---------------------------- tests/databases/mysql.php | 63 ++++++++++++++++++++++++++++++++++ tests/databases/pgsql.php | 63 ++++++++++++++++++++++++++++++++++ tests/test_dbs/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes 4 files changed, 127 insertions(+), 54 deletions(-) diff --git a/tests/core/parent.php b/tests/core/parent.php index 908680d..f664af2 100644 --- a/tests/core/parent.php +++ b/tests/core/parent.php @@ -48,60 +48,6 @@ abstract class DBTest extends UnitTestCase { $res = $this->db->beginTransaction(); $this->assertTrue($res); } - - function TestPreparedStatements() - { - if (empty($this->db)) return; - - $sql = <<db->prepare_query($sql, array(1,"boogers", "Gross")); - - $statement->execute(); - - } - - function TestPrepareExecute() - { - if (empty($this->db)) return; - - $sql = <<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 <', 9000) ->group_by('k') + ->group_by('id') ->group_by('val') ->order_by('id', 'DESC') ->order_by('k', 'ASC') diff --git a/tests/databases/mysql.php b/tests/databases/mysql.php index 9cb249b..1eb5a5a 100644 --- a/tests/databases/mysql.php +++ b/tests/databases/mysql.php @@ -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 = <<db->prepare_query($sql, array(1,"boogers", "Gross")); + + $statement->execute(); + + } + + function TestPrepareExecute() + { + if (empty($this->db)) return; + + $sql = <<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() { $this->assertFalse($this->db->get_schemas()); diff --git a/tests/databases/pgsql.php b/tests/databases/pgsql.php index dabd0e8..470c34a 100644 --- a/tests/databases/pgsql.php +++ b/tests/databases/pgsql.php @@ -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 = <<db->prepare_query($sql, array(1,"boogers", "Gross")); + + $statement->execute(); + + } + + function TestPrepareExecute() + { + if (empty($this->db)) return; + + $sql = <<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() { $this->assertTrue(is_array($this->db->get_schemas())); diff --git a/tests/test_dbs/FB_TEST_DB.FDB b/tests/test_dbs/FB_TEST_DB.FDB index d78e6c1e74984c9c6a2105c876a75bdeef998794..2cc7d4760160ce13d19590d603ef3b9d56d97790 100755 GIT binary patch delta 762 zcmZ9J!D|yi6vp4%Z0x#^jnkqa73@a4ZLtVhXp!PY&|45J7H>ii^&m(KLMd1ei-&22 zR$5wkNWdb97qL_*T~GZFRJ^Gt!$xya^cawUGqahbbcT5|-_CwN-n^G2agxM05vD5t z%Fr8vl0rx6eK!P1)dFy^_6=a>%BRu&L9GDX3P*~9 z6s{CSDNabyCxs`)$phiL0^g^_&>#1fCr_EaHBK^q1s#Oek~Z;oQ`-kqqDffFEc9h#|E87;6Fd;48Gvs84dG? z?=*@vo@&r}UT#tpKMw&872E+-a}uo93bEC;8uEKw=g&>5;u`li74BL{T&tb(-HgKFA^lH2&^Y1=?dYvZ zc&9rM@v}OO;GQmh72oQrmv0x^*6SFrFg~Z_cOag46CP=aI$LdCUUa)Ue+Ix#w~$A= RZR%O;)sqvI`Rl)Q>pvt}rxySK delta 694 zcmZ9JKWG#|6o=p2-7}YcMn@3~qqn<>mqbOl#S1E_)XpF%h=o{OVFEVUkQAm#TrCD6 z2w4zbAreWzLJK3BTo({QBu&K9Y8S1%KU%67aAuRy#2IF0KW6ymH*e!OjN|YU!r98J z0RA;WvAsol9rXbsH2^Gp^aGl4pLz)2uSgP0ZZ&dSWJ)0|ddz0G3dqN77!ji(4 z!jYmN#V#p2q$odAT|*ak+vS{p zTU~I&@!^cq0|%U5Xxant-tL7bYQJjtC0CAEiyqIUbd*bN>a!L+UQ6ksHSh7ki~fQ`G!bzKg`t>jLtH>WRa`2tLZW!O{7nJyUgUaEX z?fI3}aGoE3Y#83kkIOp$FuvYake6C_A$+mJ1Yp>h3>(wpj!GACB>(^b