Firebird updates

This commit is contained in:
Timothy Warren 2012-02-10 17:57:10 -05:00
parent 13e3c3f807
commit f6e08d8765
2 changed files with 47 additions and 9 deletions

View File

@ -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);

View File

@ -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();
?><pre><?= print_r($this->tables, TRUE) ?></pre><?php
//Check
$tables = $this->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.'<br />';
$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);
}
}