From 7c0b951539638c134f2fa1275aceed44d5716fac Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 7 Feb 2014 15:43:25 -0500 Subject: [PATCH] More firebird coverage --- drivers/firebird/firebird_result.php | 11 +--- drivers/firebird/firebird_sql.php | 4 +- tests/databases/firebird/firebird.php | 82 +++++++++++++++++---------- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/drivers/firebird/firebird_result.php b/drivers/firebird/firebird_result.php index 095a53e..8e77cc1 100644 --- a/drivers/firebird/firebird_result.php +++ b/drivers/firebird/firebird_result.php @@ -148,13 +148,8 @@ class Firebird_Result extends PDOStatement { * @param mixed $offset * @return mixed */ - public function fetch($fetch_style=PDO::FETCH_ASSOC, $statement=NULL, $offset=NULL) - { - if ( ! is_null($statement)) - { - $this->statement = $statement; - } - + public function fetch($fetch_style=PDO::FETCH_ASSOC, $cursor_orientation = PDO::FETCH_ORI_NEXT, $cursor_offset=NULL) + { // If there is no result, continue if (empty($this->result)) { @@ -287,4 +282,4 @@ class Firebird_Result extends PDOStatement { return array(0, $code, $msg); } } -// End of firebird_result.php +// End of firebird_result.php \ No newline at end of file diff --git a/drivers/firebird/firebird_sql.php b/drivers/firebird/firebird_sql.php index a0b96a9..c54c12c 100644 --- a/drivers/firebird/firebird_sql.php +++ b/drivers/firebird/firebird_sql.php @@ -94,7 +94,7 @@ class Firebird_SQL implements iDB_SQL { public function table_list() { return <<db->query('SELECT "id" FROM "create_test"'); + + $val = "bar"; + + $this->assertNull($obj->bindColumn('foo', $val)); + $this->assertNull($obj->bindParam('foo', $val)); + $this->assertNull($obj->bindValue('foo', $val)); + + } + + // -------------------------------------------------------------------------- + public function TestExists() { $this->assertTrue(function_exists('ibase_connect')); @@ -88,30 +105,34 @@ class FirebirdTest extends DBTest { $this->assertTrue($res); } + // -------------------------------------------------------------------------- + // ! Create / Delete Tables // -------------------------------------------------------------------------- - /*public function TestCreateTable() + public function TestCreateTable() { //Attempt to create the table - $sql = $this->db->util->create_table('create_test', array( + $sql = $this->db->util->create_table('create_delete', 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 + $this->assertTrue(in_array('create_delete', $this->db->get_tables())); + } + + public function TestDeleteTable() + { + //Attempt to delete the table + $sql = $this->db->util->delete_table('create_delete'); + $this->db->query($sql); //Check - $table_exists = (bool)in_array('create_test', $this->tables); - - //echo "create_test exists :".(int)$table_exists.'
'; - - $this->assertTrue($table_exists); - }*/ + $table_exists = in_array('create_delete', $this->db->get_tables()); + $this->assertFalse($table_exists); + } // -------------------------------------------------------------------------- @@ -177,28 +198,31 @@ SQL; // -------------------------------------------------------------------------- + public function TestFetch() + { + $res = $this->db->query('SELECT "key","val" FROM "create_test"'); + + // Object + $fetchObj = $res->fetchObject(); + $this->assertIsA($fetchObj, 'stdClass'); + + // Associative array + $fetchAssoc = $res->fetch(PDO::FETCH_ASSOC); + $this->assertTrue(array_key_exists('key', $fetchAssoc)); + + // Numeric array + $res2 = $this->db->query('SELECT "id","key","val" FROM "create_test"'); + $fetch = $res2->fetch(PDO::FETCH_NUM); + $this->assertTrue(is_array($fetch)); + } + + // -------------------------------------------------------------------------- + public function TestPrepareQuery() { $this->assertFalse($this->db->prepare_query('', array())); } - // -------------------------------------------------------------------------- - - /*public function TestDeleteTable() - { - //Attempt to delete the table - $sql = $this->db->util->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); - }*/ - // -------------------------------------------------------------------------- public function TestGetSequences()