Rearrange tests, add Settings class tests

keep-around/97eccfd706a523136e243db5485bbc0c81bf7dd6
Timothy Warren 11 years ago
parent e745750eca
commit ebe1b1a647
  1. 3
      .gitignore
  2. 69
      tests/core/core.php
  3. 0
      tests/core/parent.php
  4. 75
      tests/core/settings.php
  5. BIN
      tests/db_files/FB_TEST_DB.FDB
  6. 6
      tests/index.php

3
.gitignore vendored

@ -1,4 +1,5 @@
test_config.json
index.html
tests/db_files/*
._*
._*
tests/settings.json

@ -0,0 +1,69 @@
<?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
*/
// --------------------------------------------------------------------------
/**
* CoreTest class - Compatibility and core functionality tests
*
* @extends UnitTestCase
*/
class CoreTest extends UnitTestCase {
/**
* __construct function.
*
* @access public
* @return void
*/
function __construct()
{
parent::__construct();
}
/**
* TestPHPVersion function.
*
* @access public
* @return void
*/
function TestPHPVersion()
{
$this->assertTrue(version_compare(PHP_VERSION, "5.2", "ge"));
}
/**
* TestHasPDO function.
*
* @access public
* @return void
*/
function TestHasPDO()
{
// PDO class exists
$this->assertTrue(class_exists('PDO'));
// Make sure at least one of the supported drivers is enabled
$supported = array(
'mysql',
'pgsql',
'odbc',
'sqlite',
);
$drivers = pdo_drivers();
$num_supported = count(array_intersect($drivers, $supported));
$this->assertTrue($num_supported > 0);
}
}

@ -0,0 +1,75 @@
<?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 {
function __construct()
{
parent::__construct();
$this->settings =& Settings::get_instance();
// Make sure to delete 'foo' if it exists
$this->settings->remove_db('foo');
}
function TestExists()
{
$this->assertIsA($this->settings, 'Settings');
}
function TestGetEmptyDBs()
{
$this->assertTrue(is_object($this->settings->get_dbs()));
}
function TestGetNull()
{
$this->assertFalse(isset($this->settings->foo));
}
function TestSet()
{
$bar = $this->settings->foo = 'bar';
$this->assertEqual('bar', $bar);
}
function TestGet()
{
$this->assertEqual('bar', $this->settings->foo);
}
function TestSetDBProperty()
{
$res = $this->settings->__set('dbs', 2);
$this->assertFalse($res);
}
function TestGetEmptyDB()
{
$this->assertFalse($this->settings->get_db('foo'));
}
function TestAddDB()
{
$this->settings->add_db('foo', array());
$db = $this->settings->get_db('foo');
$this->assertTrue(isset($db));
}
}

Binary file not shown.

@ -23,12 +23,12 @@ define('DS', DIRECTORY_SEPARATOR);
// it has to be set in your php path, or put in the tests folder
require_once('simpletest/autorun.php');
// Require base testing classes
require_once(TEST_DIR.'/parent.php');
// Include db classes
require_once(BASE_DIR.'autoload.php');
// Require base testing classes
array_map('do_include', glob(TEST_DIR . "/core/*.php"));
// Include db tests
// Load db classes based on capability
$src_path = BASE_DIR.'drivers/';

Loading…
Cancel
Save