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(); + + ?>
= print_r($this->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.'