From f6e08d876536cf666f874f481447b56ab9a81c62 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 10 Feb 2012 17:57:10 -0500 Subject: [PATCH] Firebird updates --- src/databases/firebird.php | 6 ++--- tests/databases/firebird.php | 50 +++++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/databases/firebird.php b/src/databases/firebird.php index c0b37f2..ed7d01f 100644 --- a/src/databases/firebird.php +++ b/src/databases/firebird.php @@ -158,9 +158,9 @@ class firebird { */ function get_system_tables() { - $sql='SELECT RDB$RELATION_NAME as "rn" FROM "RDB$RELATIONS" - WHERE "rn" LIKE \'RDB$\' - OR "rn" LIKE \'RDB$\''; + $sql='SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" + WHERE "RDB$RELATION_NAME" LIKE \'RDB$%\' + OR "RDB$RELATION_NAME" LIKE \'MON$%\''; $this->statement = $this->query($sql); diff --git a/tests/databases/firebird.php b/tests/databases/firebird.php index e412db2..ced0c10 100644 --- a/tests/databases/firebird.php +++ b/tests/databases/firebird.php @@ -28,8 +28,18 @@ class FirebirdTest extends UnitTestCase { function __construct() { parent::__construct(); - + } + + function setUp() + { $this->db = new Firebird(dirname(__FILE__)."/../test_dbs/FB_TEST_DB.FDB"); + $this->tables = $this->db->get_tables(); + } + + function tearDown() + { + unset($this->db); + unset($this->tables); } function TestConnection() @@ -39,7 +49,24 @@ class FirebirdTest extends UnitTestCase { function TestGetTables() { - $tables = $this->db->get_tables(); + $tables = $this->tables; + $this->assertTrue(is_array($tables)); + } + + function TestGetSystemTables() + { + $only_system = TRUE; + + foreach($this->tables as $t) + { + if(stripos($t, 'rdb$') !== 0 && stripos($t, 'mon$') !== 0) + { + $only_system = FALSE; + break; + } + } + + $this->assertTrue($only_system); } function TestCreateDatabase() @@ -48,9 +75,17 @@ class FirebirdTest extends UnitTestCase { $sql = $this->db->manip->create_table('create_test', array('id' => 'SMALLINT')); $this->db->query($sql); + //Reset + $this->tearDown(); + $this->setUp(); + + ?>
tables, TRUE) ?>
db->get_tables(); - $table_exists = in_array('create_test', $tables); + $table_exists = (bool)in_array('create_test', $this->tables); + + echo "create_test exists :".(int)$table_exists.'
'; + $this->assertTrue($table_exists); } @@ -60,9 +95,12 @@ class FirebirdTest extends UnitTestCase { $sql = $this->db->manip->delete_table('create_test'); $this->db->query($sql); + //Reset + $this->tearDown(); + $this->setUp(); + //Check - $tables = $this->db->get_tables(); - $table_exists = in_array('create_test', $tables); + $table_exists = in_array('create_test', $this->tables); $this->assertFalse($table_exists); } } \ No newline at end of file