From b8f9f791792fa94ad8c71bc460c43a34483e292b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 28 Mar 2012 12:20:18 -0400 Subject: [PATCH] Start of unit tests for settings class --- sys/common/settings.php | 5 +++++ tests/index.php | 8 +++++--- tests/settings.php | 30 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 tests/settings.php diff --git a/sys/common/settings.php b/sys/common/settings.php index 5dee746..4b2ee8b 100644 --- a/sys/common/settings.php +++ b/sys/common/settings.php @@ -39,6 +39,11 @@ class Settings { */ private function __construct() { + if ( ! defined('SETTINGS_DIR')) + { + define('SETTINGS_DIR', '.'); + } + $path = SETTINGS_DIR.'/settings.json'; if( ! is_file($path)) diff --git a/tests/index.php b/tests/index.php index 63c2f09..b045773 100644 --- a/tests/index.php +++ b/tests/index.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 */ // -------------------------------------------------------------------------- @@ -26,6 +26,7 @@ require_once('simpletest/autorun.php'); // Require base testing classes require_once(TEST_DIR.'/parent.php'); +require_once(TEST_DIR.'/settings.php'); // Bulk loading wrapper workaround for PHP < 5.4 function do_include($path) @@ -35,6 +36,7 @@ function do_include($path) // Include core tests require_once("core.php"); +require_once(BASE_DIR.'common/settings.php'); require_once(BASE_DIR.'db/db_pdo.php'); require_once(BASE_DIR.'db/query_builder.php'); @@ -46,7 +48,7 @@ $test_path = TEST_DIR.'/databases/'; foreach(pdo_drivers() as $d) { - // PDO firebird isn't stable enough to + // PDO firebird isn't stable enough to // bother, so skip it. if ($d === 'firebird') { @@ -54,7 +56,7 @@ foreach(pdo_drivers() as $d) } $src_file = "{$src_path}{$d}.php"; - + if(is_file($src_file)) { require_once("{$src_path}{$d}.php"); diff --git a/tests/settings.php b/tests/settings.php new file mode 100644 index 0000000..000d109 --- /dev/null +++ b/tests/settings.php @@ -0,0 +1,30 @@ +settings =& Settings::get_instance(); + } + + function TestExists() + { + $this->assertIsA($this->settings, 'Settings'); + } +}