diff --git a/drivers/firebird.php b/drivers/firebird.php index 295442e..e50f8fe 100644 --- a/drivers/firebird.php +++ b/drivers/firebird.php @@ -511,5 +511,37 @@ class Firebird_Result { return array(0, $code, $msg); } + + // -------------------------------------------------------------------------- + + /** + * Method to emulate PDOStatement->errorCode() + * + * @return int + */ + public function errorCode() + { + return fbird_errcode(); + } + + // -------------------------------------------------------------------------- + + /** + * Method to emulate PDOStatement->debugDumpParams + * + * @return string + */ + public function debugDumpParams() + { + $params = array(); + $num_params = fbird_num_params($this->statement); + + for($i=0; $i < $num_params; $i++) + { + $params[] = fbird_param_info($this->statement, $i); + } + + return print_r($params, TRUE); + } } // End of firebird-fbird.php \ No newline at end of file diff --git a/tests/databases/firebird-qb.php b/tests/databases/firebird-qb.php index c13e9c8..02c3ad6 100644 --- a/tests/databases/firebird-qb.php +++ b/tests/databases/firebird-qb.php @@ -119,7 +119,7 @@ class FirebirdQBTest extends QBTest { $this->assertIsA($query, 'Firebird_Result'); } - function TestOrderByRand() + function TestOrderByRandom() { $query = $this->db->select('id, key as k, val') ->from('create_test') @@ -144,6 +144,11 @@ class FirebirdQBTest extends QBTest { $this->assertIsA($query, 'Firebird_Result'); } + function TestGroupBy() + { + + } + /*function TestGroupBy() { $query = $this->db->select('id, key as k, val') diff --git a/tests/databases/firebird.php b/tests/databases/firebird.php index 8b55882..b836662 100644 --- a/tests/databases/firebird.php +++ b/tests/databases/firebird.php @@ -17,18 +17,7 @@ * * @extends UnitTestCase */ -class FirebirdTest extends UnitTestCase { - - /** - * __construct function. - * - * @access public - * @return void - */ - function __construct() - { - parent::__construct(); - } +class FirebirdTest extends DBTest { function setUp() { diff --git a/tests/databases/mysql.php b/tests/databases/mysql.php index 01d7643..be81848 100644 --- a/tests/databases/mysql.php +++ b/tests/databases/mysql.php @@ -17,12 +17,7 @@ * * @extends UnitTestCase */ -class MySQLTest extends UnitTestCase { - - function __construct() - { - parent::__construct(); - } +class MySQLTest extends DBTest { function setUp() { @@ -36,11 +31,6 @@ class MySQLTest extends UnitTestCase { } } - function tearDown() - { - unset($this->db); - } - function TestExists() { $this->assertTrue(in_array('mysql', pdo_drivers())); @@ -52,32 +42,6 @@ class MySQLTest extends UnitTestCase { $this->assertIsA($this->db, 'MySQL'); } - - function TestGetTables() - { - if (empty($this->db)) return; - - $tables = $this->db->get_tables(); - - $this->assertTrue(is_array($tables)); - } - - function TestGetSystemTables() - { - if (empty($this->db)) return; - - $tables = $this->db->get_system_tables(); - - $this->assertTrue(is_array($tables)); - } - - function TestCreateTransaction() - { - if (empty($this->db)) return; - - $res = $this->db->beginTransaction(); - $this->assertTrue($res); - } function TestCreateTable() { @@ -116,68 +80,5 @@ class MySQLTest extends UnitTestCase { $this->assertTrue(in_array('create_test', $dbs)); } - - /*function TestTruncate() - { - if (empty($this->db)) return; - - $this->db->truncate('create_test'); - $this->assertIsA($this->db->affected_rows(), 'int'); - }*/ - - 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); - } - } diff --git a/tests/databases/odbc-qb.php b/tests/databases/odbc-qb.php index a794797..c82b677 100644 --- a/tests/databases/odbc-qb.php +++ b/tests/databases/odbc-qb.php @@ -12,12 +12,7 @@ // -------------------------------------------------------------------------- -class ODBCQBTest extends UnitTestCase { - - function __construct() - { - - } +class ODBCQBTest extends QBTest { function TestExists() { diff --git a/tests/databases/pgsql.php b/tests/databases/pgsql.php index 37e2839..66eccd0 100644 --- a/tests/databases/pgsql.php +++ b/tests/databases/pgsql.php @@ -17,7 +17,7 @@ * * @extends UnitTestCase */ -class PgTest extends UnitTestCase { +class PgTest extends DBTest { function __construct() { @@ -36,11 +36,6 @@ class PgTest extends UnitTestCase { } } - function tearDown() - { - unset($this->db); - } - function TestExists() { $this->assertTrue(in_array('pgsql', pdo_drivers())); @@ -52,32 +47,6 @@ class PgTest extends UnitTestCase { $this->assertIsA($this->db, 'PgSQL'); } - - function TestGetTables() - { - if (empty($this->db)) return; - - $tables = $this->db->get_tables(); - - $this->assertTrue(is_array($tables)); - } - - function TestGetSystemTables() - { - if (empty($this->db)) return; - - $tables = $this->db->get_system_tables(); - - $this->assertTrue(is_array($tables)); - } - - function TestCreateTransaction() - { - if (empty($this->db)) return; - - $res = $this->db->beginTransaction(); - $this->assertTrue($res); - } /*function TestCreateTable() { @@ -118,67 +87,4 @@ class PgTest extends UnitTestCase { $this->assertTrue(in_array('create_test', $dbs)); }*/ - - /*function TestTruncate() - { - if (empty($this->db)) return; - - $this->db->truncate('create_test'); - $this->assertIsA($this->db->affected_rows(), 'int'); - }*/ - - 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); - } - } \ No newline at end of file diff --git a/tests/databases/sqlite.php b/tests/databases/sqlite.php index 8cf21bc..b361b62 100644 --- a/tests/databases/sqlite.php +++ b/tests/databases/sqlite.php @@ -19,11 +19,6 @@ */ class SQLiteTest extends DBTest { - function __construct() - { - //parent::__construct(); - } - function setUp() { $path = TEST_DIR.DS.'test_dbs'.DS.'test_sqlite.db'; @@ -40,25 +35,7 @@ class SQLiteTest extends DBTest { $this->assertIsA($this->db, 'SQLite'); } - function TestGetTables() - { - $tables = $this->db->get_tables(); - $this->assertTrue(is_array($tables)); - } - function TestGetSystemTables() - { - $tables = $this->db->get_system_tables(); - - $this->assertTrue(is_array($tables)); - } - - function TestCreateTransaction() - { - $res = $this->db->beginTransaction(); - $this->assertTrue($res); - } - function TestCreateTable() { //Attempt to create the table @@ -92,58 +69,13 @@ class SQLiteTest extends DBTest { $this->assertEqual($dbs['create_test'], 'CREATE TABLE "create_test" (id INTEGER PRIMARY KEY, key TEXT , val TEXT )'); } - function TestTruncate() + /*function TestTruncate() { $this->db->truncate('create_test'); $this->assertIsA($this->db->affected_rows(), 'int'); - } + }*/ - function TestPreparedStatements() - { - $sql = <<db->prepare_query($sql, array(1,"boogers", "Gross")); - - $statement->execute(); - - } - - function TestPrepareExecute() - { - $sql = <<db->prepare_execute($sql, array( - 2, "works", 'also?' - )); - - } - - function TestCommitTransaction() - { - $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() - { - $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); - } - + // This is really time intensive ! Run only when needed /*function TestDeleteTable() { diff --git a/tests/parent.php b/tests/parent.php index b6cac60..bdbbf75 100644 --- a/tests/parent.php +++ b/tests/parent.php @@ -9,9 +9,92 @@ * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ + +// -------------------------------------------------------------------------- + +/** + * Parent Database Test Class + */ +abstract class DBTest extends UnitTestCase { + + abstract function TestConnection(); + + function tearDown() + { + unset($this->db); + } + + function TestGetTables() + { + $tables = $this->db->get_tables(); + $this->assertTrue(is_array($tables)); + } + + function TestGetSystemTables() + { + $tables = $this->db->get_system_tables(); + + $this->assertTrue(is_array($tables)); + } + + function TestCreateTransaction() + { + $res = $this->db->beginTransaction(); + $this->assertTrue($res); + } + + function TestPreparedStatements() + { + $sql = <<db->prepare_query($sql, array(1,"boogers", "Gross")); + + $statement->execute(); + + } + + function TestPrepareExecute() + { + $sql = <<db->prepare_execute($sql, array( + 2, "works", 'also?' + )); + + } + + function TestCommitTransaction() + { + $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() + { + $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); + } +} // -------------------------------------------------------------------------- +/** + * Query builder parent test class + */ abstract class QBTest extends UnitTestCase { function TestGet() @@ -220,15 +303,3 @@ abstract class QBTest extends UnitTestCase { } -// -------------------------------------------------------------------------- - -abstract class DBTest extends UnitTestCase { - - abstract function TestConnection(); - - function tearDown() - { - unset($this->db); - } - -} \ No newline at end of file diff --git a/tests/test_dbs/FB_TEST_DB.FDB b/tests/test_dbs/FB_TEST_DB.FDB index 719164c..55a51de 100755 Binary files a/tests/test_dbs/FB_TEST_DB.FDB and b/tests/test_dbs/FB_TEST_DB.FDB differ