Fix some tests

This commit is contained in:
Timothy Warren 2012-04-02 10:52:46 -04:00
parent fdc37f8819
commit 96ada089ee
6 changed files with 78 additions and 60 deletions

View File

@ -20,7 +20,7 @@
*/
class DB_Reg {
private static $instance;
private static $instance=array();
/**
* Registry access method

View File

@ -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());
}*/
}
// --------------------------------------------------------------------------

View File

@ -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 '<hr /> MySQL Queries <hr />';
// echo '<hr /> MySQL Queries <hr />';
}
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()));

View File

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

View File

@ -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 '<hr /> Postgres Queries <hr />';
// echo '<hr /> Postgres Queries <hr />';
}
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()));

View File

@ -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.'<br />';
//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));
}
}