diff --git a/sys/db/dbreg.php b/sys/db/dbreg.php index 9c2f429..70f4c39 100644 --- a/sys/db/dbreg.php +++ b/sys/db/dbreg.php @@ -20,7 +20,7 @@ */ class DB_Reg { - private static $instance; + private static $instance=array(); /** * Registry access method diff --git a/sys/windows/widgets/connection_sidebar.php b/sys/windows/widgets/connection_sidebar.php index c25256c..9221cb8 100644 --- a/sys/windows/widgets/connection_sidebar.php +++ b/sys/windows/widgets/connection_sidebar.php @@ -180,7 +180,25 @@ class Connection_Sidebar extends GtkVBox { */ public function set_status_icon($col, $cell, $model, $iter) { + $col->set_reorderable(TRUE); + $info = $model->get_value($iter, 0); + list($width, $height) = Gtk::icon_size_lookup(Gtk::ICON_SIZE_SMALL_TOOLBAR); + + $conns = DB_Reg::get_connections(); + + /*if(in_array($info->name, $conns)) + { + $img = new GTKImage(); + $img->set_from_stock(GTK::STOCK_YES, Gtk::ICON_SIZE_SMALL_TOOLBAR); + $cell->set_property('pixbuf', $img->get_pixbuf()); + } + else + { + $img = new GTKImage(); + $img->set_from_stock(GTK::STOCK_NO, Gtk::ICON_SIZE_SMALL_TOOLBAR); + $cell->set_property('pixbuf', $img->get_pixbuf()); + }*/ } // -------------------------------------------------------------------------- diff --git a/tests/databases/mysql-qb.php b/tests/databases/mysql-qb.php index cc23b17..06915db 100644 --- a/tests/databases/mysql-qb.php +++ b/tests/databases/mysql-qb.php @@ -7,7 +7,7 @@ * @author Timothy J. Warren * @copyright Copyright (c) 2012 * @link https://github.com/aviat4ion/OpenSQLManager - * @license http://philsturgeon.co.uk/code/dbad-license + * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- @@ -17,34 +17,34 @@ class MySQLQBTest extends QBTest { function __construct() { parent::__construct(); - + // Attempt to connect, if there is a test config file if (is_file("../test_config.json")) { $params = json_decode(file_get_contents("../test_config.json")); $params = $params->mysql; $params->type = "mysql"; - + $this->db = new Query_Builder($params); - - // echo '
MySQL Queries
'; + + // echo '
MySQL Queries
'; } elseif (($var = getenv('CI'))) { $params = array( 'host' => '127.0.0.1', 'port' => '3306', - 'database' => 'test', + 'conn_db' => 'test', 'user' => 'root', 'pass' => NULL, 'type' => 'mysql' ); - + $this->db = new Query_Builder($params); } } - + function TestExists() { $this->assertTrue(in_array('mysql', pdo_drivers())); diff --git a/tests/databases/mysql.php b/tests/databases/mysql.php index 3c41f73..847962e 100644 --- a/tests/databases/mysql.php +++ b/tests/databases/mysql.php @@ -7,18 +7,18 @@ * @author Timothy J. Warren * @copyright Copyright (c) 2012 * @link https://github.com/aviat4ion/OpenSQLManager - * @license http://philsturgeon.co.uk/code/dbad-license + * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- /** * MySQLTest class. - * + * * @extends UnitTestCase */ class MySQLTest extends DBTest { - + function setUp() { // Attempt to connect, if there is a test config file @@ -26,52 +26,52 @@ class MySQLTest extends DBTest { { $params = json_decode(file_get_contents("../test_config.json")); $params = $params->mysql; - - $this->db = new MySQL("host={$params->host};port={$params->port};dbname={$params->database}", $params->user, $params->pass); + + $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; - + if (empty($this->db)) return; + $this->assertIsA($this->db, 'MySQL'); } function TestCreateTable() { - if (empty($this->db)) return; - + if (empty($this->db)) return; + //Attempt to create the table - $sql = $this->db->sql->create_table('create_test', + $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', + $sql = $this->db->sql->create_table('create_join', array( 'id' => 'int(10)', 'key' => 'TEXT', 'val' => 'TEXT', - ), + ), array( 'id' => 'PRIMARY KEY' ) @@ -80,9 +80,9 @@ class MySQLTest extends DBTest { //Check $dbs = $this->db->get_tables(); - + $this->assertTrue(in_array('create_test', $dbs)); - + } } - + diff --git a/tests/databases/pgsql-qb.php b/tests/databases/pgsql-qb.php index 0cdc513..d1bfb34 100644 --- a/tests/databases/pgsql-qb.php +++ b/tests/databases/pgsql-qb.php @@ -7,7 +7,7 @@ * @author Timothy J. Warren * @copyright Copyright (c) 2012 * @link https://github.com/aviat4ion/OpenSQLManager - * @license http://philsturgeon.co.uk/code/dbad-license + * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- @@ -17,34 +17,34 @@ class PgSQLQBTest extends QBTest { function __construct() { parent::__construct(); - + // Attempt to connect, if there is a test config file if (is_file("../test_config.json")) { $params = json_decode(file_get_contents("../test_config.json")); $params = $params->pgsql; $params->type = "pgsql"; - + $this->db = new Query_Builder($params); - - // echo '
Postgres Queries
'; - + + // echo '
Postgres Queries
'; + } elseif (($var = getenv('CI'))) { $params = array( 'host' => '127.0.0.1', 'port' => '5432', - 'database' => 'test', + 'conn_db' => 'test', 'user' => 'postgres', 'pass' => '', 'type' => 'pgsql' ); - + $this->db = new Query_Builder($params); } } - + function TestExists() { $this->assertTrue(in_array('pgsql', pdo_drivers())); diff --git a/tests/databases/pgsql.php b/tests/databases/pgsql.php index 57891ce..764f4f1 100644 --- a/tests/databases/pgsql.php +++ b/tests/databases/pgsql.php @@ -7,14 +7,14 @@ * @author Timothy J. Warren * @copyright Copyright (c) 2012 * @link https://github.com/aviat4ion/OpenSQLManager - * @license http://philsturgeon.co.uk/code/dbad-license + * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- /** * PgTest class. - * + * * @extends UnitTestCase */ class PgTest extends DBTest { @@ -23,7 +23,7 @@ class PgTest extends DBTest { { parent::__construct(); } - + function setUp() { // Attempt to connect, if there is a test config file @@ -31,67 +31,67 @@ class PgTest extends DBTest { { $params = json_decode(file_get_contents("../test_config.json")); $params = $params->pgsql; - - $this->db = new PgSQL("host={$params->host};port={$params->port};dbname={$params->database}", $params->user, $params->pass); + + $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; - + if (empty($this->db)) return; + $this->assertIsA($this->db, 'PgSQL'); } function TestCreateTable() { - if (empty($this->db)) return; - + 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', + $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', + $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(); @@ -99,6 +99,6 @@ class PgTest extends DBTest { //Check $dbs = $this->db->get_tables(); $this->assertTrue(in_array('create_test', $dbs)); - + } } \ No newline at end of file