diff --git a/sys/db b/sys/db index 773e7b8..e745750 160000 --- a/sys/db +++ b/sys/db @@ -1 +1 @@ -Subproject commit 773e7b8b805783ccefcfae17583f077ce8672996 +Subproject commit e745750eca9bf718094c27af26873be646bf9ef6 diff --git a/tests/core/parent.php b/tests/core/parent.php deleted file mode 100644 index f664af2..0000000 --- a/tests/core/parent.php +++ /dev/null @@ -1,273 +0,0 @@ -db = NULL; - } - - 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); - } -} - -// -------------------------------------------------------------------------- - -/** - * Query builder parent test class - */ -abstract class QBTest extends UnitTestCase { - - function TestGet() - { - if (empty($this->db)) return; - - $query = $this->db->get('create_test'); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestGetLimit() - { - if (empty($this->db)) return; - - $query = $this->db->get('create_test', 2); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestGetLimitSkip() - { - if (empty($this->db)) return; - - $query = $this->db->get('create_test', 2, 1); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestSelectWhereGet() - { - if (empty($this->db)) return; - - $query = $this->db->select('id, key as k, val') - ->where('id >', 1) - ->where('id <', 900) - ->get('create_test', 2, 1); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestSelectWhereGet2() - { - if (empty($this->db)) return; - - $query = $this->db->select('id, key as k, val') - ->where('id !=', 1) - ->get('create_test', 2, 1); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestSelectGet() - { - if (empty($this->db)) return; - - $query = $this->db->select('id, key as k, val') - ->get('create_test', 2, 1); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestSelectFromGet() - { - if (empty($this->db)) return; - - $query = $this->db->select('id, key as k, val') - ->from('create_test ct') - ->where('id >', 1) - ->get(); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestSelectFromLimitGet() - { - if (empty($this->db)) return; - - $query = $this->db->select('id, key as k, val') - ->from('create_test ct') - ->where('id >', 1) - ->limit(3) - ->get(); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestOrderBy() - { - if (empty($this->db)) return; - - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where('id >', 0) - ->where('id <', 9000) - ->order_by('id', 'DESC') - ->order_by('k', 'ASC') - ->limit(5,2) - ->get(); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestOrderByRandom() - { - if (empty($this->db)) return; - - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where('id >', 0) - ->where('id <', 9000) - ->order_by('id', 'rand') - ->limit(5,2) - ->get(); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestGroupBy() - { - if (empty($this->db)) return; - - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where('id >', 0) - ->where('id <', 9000) - ->group_by('k') - ->group_by('id') - ->group_by('val') - ->order_by('id', 'DESC') - ->order_by('k', 'ASC') - ->limit(5,2) - ->get(); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestOrWhere() - { - if (empty($this->db)) return; - - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where(' id ', 1) - ->or_where('key >', 0) - ->limit(2, 1) - ->get(); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestLike() - { - if (empty($this->db)) return; - - $query = $this->db->from('create_test') - ->like('key', 'og') - ->get(); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestJoin() - { - if (empty($this->db)) return; - - $query = $this->db->from('create_test') - ->join('create_join cj', 'cj.id = create_test.id') - ->get(); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestInsert() - { - if (empty($this->db)) return; - - $query = $this->db->set('id', 4) - ->set('key', 4) - ->set('val', 5) - ->insert('create_test'); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestUpdate() - { - if (empty($this->db)) return; - - $query = $this->db->set('id', 4) - ->set('key', 'gogle') - ->set('val', 'non-word') - ->where('id', 4) - ->update('create_test'); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestDelete() - { - if (empty($this->db)) return; - - $query = $this->db->where('id', 4)->delete('create_test'); - - $this->assertIsA($query, 'PDOStatement'); - } - - function TestGetViews() - { - if (empty($this->db)) return; - - $this->assertTrue(is_array($this->db->get_views())); - } -} - -// End of parent.php \ No newline at end of file diff --git a/tests/databases/firebird/firebird-qb.php b/tests/databases/firebird/firebird-qb.php deleted file mode 100644 index 880ad75..0000000 --- a/tests/databases/firebird/firebird-qb.php +++ /dev/null @@ -1,224 +0,0 @@ -type = 'firebird'; - $params->file = $dbpath; - $params->host = 'localhost'; - $params->user = 'sysdba'; - $params->pass = 'masterkey'; - $this->db = new Query_Builder($params); - - // echo '
Firebird Queries
'; - } - - function TestGet() - { - $query = $this->db->get('create_test ct'); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestGetLimit() - { - $query = $this->db->get('create_test', 2); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestGetLimitSkip() - { - $query = $this->db->get('create_test', 2, 1); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectWhereGet() - { - $query = $this->db->select('id, key as k, val') - ->where('id >', 1) - ->where('id <', 800) - ->get('create_test', 2, 1); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectWhereGet2() - { - $query = $this->db->select('id, key as k, val') - ->where(' id ', 1) - - ->get('create_test', 2, 1); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectGet() - { - $query = $this->db->select('id, key as k, val') - ->get('create_test', 2, 1); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectFromGet() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test ct') - ->where('id >', 1) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestSelectFromLimitGet() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test ct') - ->where('id >', 1) - ->limit(3) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestOrderBy() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where('id >', 0) - ->where('id <', 9000) - ->order_by('id', 'DESC') - ->order_by('k', 'ASC') - ->limit(5,2) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestOrderByRandom() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where('id >', 0) - ->where('id <', 9000) - ->order_by('id', 'rand') - ->limit(5,2) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestOrWhere() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where(' id ', 1) - ->or_where('key >', 0) - ->limit(2, 1) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestGroupBy() - { - - } - - /*function TestGroupBy() - { - $query = $this->db->select('id, key as k, val') - ->from('create_test') - ->where('id >', 0) - ->where('id <', 9000) - ->group_by('k') - ->group_by('val') - ->order_by('id', 'DESC') - ->order_by('k', 'ASC') - ->limit(5,2) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - }*/ - - function TestLike() - { - $query = $this->db->from('create_test') - ->like('key', 'og') - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestWhereIn() - { - $query = $this->db->from('create_test') - ->where_in('key', array(12, 96, "works")) - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestJoin() - { - $query = $this->db->from('create_test') - ->join('create_join cj', 'cj.id = create_test.id') - ->get(); - - $this->assertIsA($query, 'Firebird_Result'); - } - - function TestInsert() - { - $query = $this->db->set('id', 4) - ->set('key', 4) - ->set('val', 5) - ->insert('create_test'); - - $this->assertTrue($query); - } - - function TestUpdate() - { - $query = $this->db->set('id', 4) - ->set('key', 'gogle') - ->set('val', 'non-word') - ->where('id', 4) - ->update('create_test'); - - $this->assertTrue($query); - } - - function TestDelete() - { - $query = $this->db->where('id', 4)->delete('create_test'); - - $this->assertTrue($query); - } - - -} \ No newline at end of file diff --git a/tests/databases/firebird/firebird.php b/tests/databases/firebird/firebird.php deleted file mode 100644 index 7e27b15..0000000 --- a/tests/databases/firebird/firebird.php +++ /dev/null @@ -1,191 +0,0 @@ -db = new Firebird('localhost:'.$dbpath); - $this->tables = $this->db->get_tables(); - } - - function tearDown() - { - unset($this->db); - unset($this->tables); - } - - function TestConnection() - { - $this->assertIsA($this->db, 'Firebird'); - } - - function TestGetTables() - { - $tables = $this->tables; - $this->assertTrue(is_array($tables)); - } - - function TestGetSystemTables() - { - $only_system = TRUE; - - $tables = $this->db->get_system_tables(); - - foreach($tables as $t) - { - if(stripos($t, 'rdb$') !== 0 && stripos($t, 'mon$') !== 0) - { - $only_system = FALSE; - break; - } - } - - $this->assertTrue($only_system); - } - - function TestCreateTransaction() - { - $res = $this->db->beginTransaction(); - $this->assertTrue($res); - } - - /*function TestCreateTable() - { - //Attempt to create the table - $sql = $this->db->sql->create_table('create_join', array( - 'id' => 'SMALLINT', - 'key' => 'VARCHAR(64)', - 'val' => 'BLOB SUB_TYPE TEXT' - )); - $this->db->query($sql); - - //This test fails for an unknown reason, when clearly the table exists - //Reset - $this->tearDown(); - $this->setUp(); - - //Check - $table_exists = (bool)in_array('create_test', $this->tables); - - echo "create_test exists :".(int)$table_exists.'
'; - - $this->assertTrue($table_exists); - }*/ - - - - function TestTruncate() - { - $this->db->truncate('create_test'); - - $this->assertTrue($this->db->affected_rows() > 0); - } - - 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); - } - - - - function TestPreparedStatements() - { - $sql = <<db->prepare($sql); - $query->execute(array(1,"booger's", "Gross")); - - } - - function TestPrepareExecute() - { - $sql = <<db->prepare_execute($sql, array( - 2, "works", 'also?' - )); - - } - - function TestPrepareQuery() - { - $this->assertFalse($this->db->prepare_query('', array())); - } - - /*function TestDeleteTable() - { - //Attempt to delete the table - $sql = $this->db->sql->delete_table('create_test'); - $this->db->query($sql); - - //Reset - $this->tearDown(); - $this->setUp(); - - //Check - $table_exists = in_array('create_test', $this->tables); - $this->assertFalse($table_exists); - }*/ - - function TestGetSequences() - { - $this->assertTrue(is_array($this->db->get_sequences())); - } - - function TestGetProcedures() - { - $this->assertTrue(is_array($this->db->get_procedures())); - } - - function TestGetFunctions() - { - $this->assertTrue(is_array($this->db->get_functions())); - } - - function TestGetTriggers() - { - $this->assertTrue(is_array($this->db->get_triggers())); - } - -} \ No newline at end of file diff --git a/tests/databases/mysql/mysql-qb.php b/tests/databases/mysql/mysql-qb.php deleted file mode 100644 index 06915db..0000000 --- a/tests/databases/mysql/mysql-qb.php +++ /dev/null @@ -1,52 +0,0 @@ -mysql; - $params->type = "mysql"; - - $this->db = new Query_Builder($params); - - // echo '
MySQL Queries
'; - } - elseif (($var = getenv('CI'))) - { - $params = array( - 'host' => '127.0.0.1', - 'port' => '3306', - 'conn_db' => 'test', - 'user' => 'root', - 'pass' => NULL, - 'type' => 'mysql' - ); - - $this->db = new Query_Builder($params); - } - } - - - function TestExists() - { - $this->assertTrue(in_array('mysql', pdo_drivers())); - } -} \ No newline at end of file diff --git a/tests/databases/mysql/mysql.php b/tests/databases/mysql/mysql.php deleted file mode 100644 index 1eb5a5a..0000000 --- a/tests/databases/mysql/mysql.php +++ /dev/null @@ -1,171 +0,0 @@ -mysql; - - $this->db = new MySQL("host={$params->host};port={$params->port};dbname={$params->conn_db}", $params->user, $params->pass); - } - elseif (($var = getenv('CI'))) - { - $this->db = new MySQL('host=127.0.0.1;port=3306;dbname=test', 'root'); - } - } - - function TestExists() - { - $this->assertTrue(in_array('mysql', pdo_drivers())); - } - - function TestConnection() - { - if (empty($this->db)) return; - - $this->assertIsA($this->db, 'MySQL'); - } - - function TestCreateTable() - { - if (empty($this->db)) return; - - //Attempt to create the table - $sql = $this->db->sql->create_table('create_test', - array( - 'id' => 'int(10)', - 'key' => 'TEXT', - 'val' => 'TEXT', - ), - array( - 'id' => 'PRIMARY KEY' - ) - ); - - $this->db->query($sql); - - //Attempt to create the table - $sql = $this->db->sql->create_table('create_join', - array( - 'id' => 'int(10)', - 'key' => 'TEXT', - 'val' => 'TEXT', - ), - array( - 'id' => 'PRIMARY KEY' - ) - ); - $this->db->query($sql); - - //Check - $dbs = $this->db->get_tables(); - - $this->assertTrue(in_array('create_test', $dbs)); - - } - - 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()); - } - - function TestGetsProcedures() - { - $this->assertTrue(is_array($this->db->get_procedures())); - } - - function TestGetTriggers() - { - $this->assertTrue(is_array($this->db->get_triggers())); - } - - function TestGetSequences() - { - $this->assertFalse($this->db->get_sequences()); - } -} - diff --git a/tests/databases/odbc/odbc-qb.php b/tests/databases/odbc/odbc-qb.php deleted file mode 100644 index ea35a20..0000000 --- a/tests/databases/odbc/odbc-qb.php +++ /dev/null @@ -1,21 +0,0 @@ -assertTrue(in_array('odbc', pdo_drivers())); - } -} \ No newline at end of file diff --git a/tests/databases/odbc/odbc.php b/tests/databases/odbc/odbc.php deleted file mode 100644 index 1ad4072..0000000 --- a/tests/databases/odbc/odbc.php +++ /dev/null @@ -1,26 +0,0 @@ -assertTrue(in_array('odbc', pdo_drivers())); - } -} \ No newline at end of file diff --git a/tests/databases/pgsql/pgsql-qb.php b/tests/databases/pgsql/pgsql-qb.php deleted file mode 100644 index d1bfb34..0000000 --- a/tests/databases/pgsql/pgsql-qb.php +++ /dev/null @@ -1,52 +0,0 @@ -pgsql; - $params->type = "pgsql"; - - $this->db = new Query_Builder($params); - - // echo '
Postgres Queries
'; - - } - elseif (($var = getenv('CI'))) - { - $params = array( - 'host' => '127.0.0.1', - 'port' => '5432', - 'conn_db' => 'test', - 'user' => 'postgres', - 'pass' => '', - 'type' => 'pgsql' - ); - - $this->db = new Query_Builder($params); - } - } - - function TestExists() - { - $this->assertTrue(in_array('pgsql', pdo_drivers())); - } -} \ No newline at end of file diff --git a/tests/databases/pgsql/pgsql.php b/tests/databases/pgsql/pgsql.php deleted file mode 100644 index 470c34a..0000000 --- a/tests/databases/pgsql/pgsql.php +++ /dev/null @@ -1,187 +0,0 @@ -pgsql; - - $this->db = new PgSQL("host={$params->host};port={$params->port};dbname={$params->conn_db}", $params->user, $params->pass); - } - elseif (($var = getenv('CI'))) - { - $this->db = new PgSQL('host=127.0.0.1;port=5432;dbname=test', 'postgres'); - } - } - - function TestExists() - { - $this->assertTrue(in_array('pgsql', pdo_drivers())); - } - - function TestConnection() - { - if (empty($this->db)) return; - - $this->assertIsA($this->db, 'PgSQL'); - } - - function TestCreateTable() - { - if (empty($this->db)) return; - - // Drop the table(s) if they exist - $sql = 'DROP TABLE IF EXISTS "create_test"'; - $this->db->query($sql); - $sql = 'DROP TABLE IF EXISTS "create_join"'; - $this->db->query($sql); - - - //Attempt to create the table - $sql = $this->db->sql->create_table('create_test', - array( - 'id' => 'integer', - 'key' => 'TEXT', - 'val' => 'TEXT', - ), - array( - 'id' => 'PRIMARY KEY' - ) - ); - - $this->db->query($sql); - - //Attempt to create the table - $sql = $this->db->sql->create_table('create_join', - array( - 'id' => 'integer', - 'key' => 'TEXT', - 'val' => 'TEXT', - ), - array( - 'id' => 'PRIMARY KEY' - ) - ); - $this->db->query($sql); - - //echo $sql.'
'; - - //Reset - unset($this->db); - $this->setUp(); - - //Check - $dbs = $this->db->get_tables(); - $this->assertTrue(in_array('create_test', $dbs)); - - } - - 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())); - } - - function TestGetSequences() - { - $this->assertTrue(is_array($this->db->get_sequences())); - } - - function TestGetsProcedures() - { - $this->assertTrue(is_array($this->db->get_procedures())); - } - - function TestGetTriggers() - { - $this->assertTrue(is_array($this->db->get_triggers())); - } -} \ No newline at end of file diff --git a/tests/databases/sqlite/sqlite-qb.php b/tests/databases/sqlite/sqlite-qb.php deleted file mode 100644 index ad62c12..0000000 --- a/tests/databases/sqlite/sqlite-qb.php +++ /dev/null @@ -1,33 +0,0 @@ -type = 'sqlite'; - $params->file = $path; - $params->host = 'localhost'; - $this->db = new Query_Builder($params); - - // echo '
SQLite Queries
'; - } -} \ No newline at end of file diff --git a/tests/databases/sqlite/sqlite.php b/tests/databases/sqlite/sqlite.php deleted file mode 100644 index e2ffdfa..0000000 --- a/tests/databases/sqlite/sqlite.php +++ /dev/null @@ -1,173 +0,0 @@ -db = new SQLite($path); - } - - function tearDown() - { - unset($this->db); - } - - function TestConnection() - { - $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 - $sql = $this->db->sql->create_table('create_test', - array( - 'id' => 'INTEGER', - 'key' => 'TEXT', - 'val' => 'TEXT', - ), - array( - 'id' => 'PRIMARY KEY' - ) - ); - $this->db->query($sql); - - //Attempt to create the table - $sql = $this->db->sql->create_table('create_join', - array( - 'id' => 'INTEGER', - 'key' => 'TEXT', - 'val' => 'TEXT', - ), - array( - 'id' => 'PRIMARY KEY' - ) - ); - $this->db->query($sql); - - //Check - $dbs = $this->db->get_tables(); - - $this->assertTrue(in_array('create_test', $dbs)); - } - - 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() - { - //Make sure the table exists to delete - $dbs = $this->db->get_tables(); - $this->assertTrue(isset($dbs['create_test'])); - - //Attempt to delete the table - $sql = $this->db->sql->delete_table('create_test'); - $this->db->query($sql); - - //Check - $dbs = $this->db->get_tables(); - $this->assertFalse(in_array('create_test', $dbs)); - }*/ - - function TestGetDBs() - { - $this->assertFalse($this->db->get_dbs()); - } - - function TestGetSchemas() - { - $this->assertFalse($this->db->get_schemas()); - } -} \ No newline at end of file diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB deleted file mode 100755 index 4f72903..0000000 Binary files a/tests/db_files/FB_TEST_DB.FDB and /dev/null differ diff --git a/tests/index.php b/tests/index.php index a5cbe85..a37460f 100644 --- a/tests/index.php +++ b/tests/index.php @@ -15,53 +15,21 @@ /** * Unit test bootstrap - Using php simpletest */ -define('TEST_DIR', dirname(__FILE__).'/'); -define('BASE_DIR', str_replace(basename(TEST_DIR).'/', '', TEST_DIR).'sys/'); -define('DS', DIRECTORY_SEPARATOR); +define('OSL_TEST_DIR', dirname(__FILE__).'/'); +define('OSL_BASE_DIR', str_replace(basename(OSL_TEST_DIR).'/', '', OSL_TEST_DIR).'sys/'); // -------------------------------------------------------------------------- // Include simpletest // it has to be set in your php path, or put in the tests folder require_once('simpletest/autorun.php'); - -// Include db_drivers -require_once(BASE_DIR . 'db/autoload.php'); +require_once(OSL_BASE_DIR . 'db/autoload.php'); // Include core tests -array_map('do_include', glob(TEST_DIR . 'core/*.php')); +array_map('do_include', glob(OSL_TEST_DIR . 'core/*.php')); // Include required methods -array_map('do_include', glob(BASE_DIR . 'common/*.php')); +array_map('do_include', glob(OSL_BASE_DIR . 'common/*.php')); // Include db tests -// Load db classes based on capability -$src_path = BASE_DIR.'db/drivers/'; -$test_path = TEST_DIR.'databases/'; - -foreach(pdo_drivers() as $d) -{ - // PDO firebird isn't stable enough to - // bother, so skip it. - if ($d === 'firebird') - { - continue; - } - - // Load by driver folder - $src_dir = "{$src_path}{$d}"; - - if(is_dir($src_dir)) - { - require_once("{$test_path}{$d}/{$d}.php"); - require_once("{$test_path}{$d}/{$d}-qb.php"); - } -} - -// Load Firebird if there is support -if(function_exists('fbird_connect')) -{ - array_map('do_include', glob($src_path.'firebird/*.php')); - require_once("{$test_path}firebird/firebird.php"); - require_once("{$test_path}firebird/firebird-qb.php"); -} \ No newline at end of file +require_once(OSL_BASE_DIR . 'db/tests/index.php');