2012-04-13 13:48:38 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* OpenSQLManager
|
|
|
|
*
|
|
|
|
* Free Database manager for Open Source Databases
|
|
|
|
*
|
|
|
|
* @author Timothy J. Warren
|
|
|
|
* @copyright Copyright (c) 2012
|
|
|
|
* @link https://github.com/aviat4ion/OpenSQLManager
|
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Settings Class Test Class
|
|
|
|
*/
|
|
|
|
class SettingsTest extends UnitTestCase {
|
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
public function __construct()
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->settings =& Settings::get_instance();
|
|
|
|
|
|
|
|
// Make sure to delete 'foo' if it exists
|
|
|
|
$this->settings->remove_db('foo');
|
|
|
|
}
|
2012-04-24 14:00:44 -04:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
2012-04-13 13:48:38 -04:00
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
public function TestExists()
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
$this->assertIsA($this->settings, 'Settings');
|
|
|
|
}
|
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function TestGetEmptyDBs()
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
$this->assertTrue(is_object($this->settings->get_dbs()));
|
|
|
|
}
|
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function TestGetNull()
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
$this->assertFalse(isset($this->settings->foo));
|
|
|
|
}
|
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function TestSet()
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
$bar = $this->settings->foo = 'bar';
|
|
|
|
|
|
|
|
$this->assertEqual('bar', $bar);
|
|
|
|
}
|
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function TestGet()
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
$this->assertEqual('bar', $this->settings->foo);
|
|
|
|
}
|
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function TestSetDBProperty()
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
$res = $this->settings->__set('dbs', 2);
|
|
|
|
$this->assertFalse($res);
|
|
|
|
}
|
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function TestGetEmptyDB()
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
$this->assertFalse($this->settings->get_db('foo'));
|
|
|
|
}
|
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function TestAddDB()
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
$this->settings->add_db('foo', array());
|
|
|
|
|
|
|
|
$db = $this->settings->get_db('foo');
|
|
|
|
|
|
|
|
$this->assertTrue(isset($db));
|
|
|
|
}
|
|
|
|
}
|