diff --git a/.gitignore b/.gitignore index 35dadd9..e4c8234 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ test_config.json index.html tests/db_files/* -._* \ No newline at end of file +._* +tests/settings.json \ No newline at end of file diff --git a/tests/core/core.php b/tests/core/core.php new file mode 100644 index 0000000..af31b1d --- /dev/null +++ b/tests/core/core.php @@ -0,0 +1,69 @@ +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); + } +} \ No newline at end of file diff --git a/tests/parent.php b/tests/core/parent.php similarity index 100% rename from tests/parent.php rename to tests/core/parent.php diff --git a/tests/core/settings.php b/tests/core/settings.php new file mode 100644 index 0000000..9f0c6a0 --- /dev/null +++ b/tests/core/settings.php @@ -0,0 +1,75 @@ +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)); + } +} diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB index 00306af..9ec6109 100755 Binary files a/tests/db_files/FB_TEST_DB.FDB and b/tests/db_files/FB_TEST_DB.FDB differ diff --git a/tests/index.php b/tests/index.php index d13f8da..abd4ff0 100644 --- a/tests/index.php +++ b/tests/index.php @@ -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/';