From ebe1b1a6474db00791e5c328e4fb2e88d051eb01 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 13 Apr 2012 13:48:38 -0400 Subject: [PATCH] Rearrange tests, add Settings class tests --- .gitignore | 3 +- tests/core/core.php | 69 +++++++++++++++++++++++++++++++ tests/{ => core}/parent.php | 0 tests/core/settings.php | 75 ++++++++++++++++++++++++++++++++++ tests/db_files/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes tests/index.php | 6 +-- 6 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 tests/core/core.php rename tests/{ => core}/parent.php (100%) create mode 100644 tests/core/settings.php 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 00306affdf06ee2c184b22d26dfa63d0ff082791..9ec6109fc6bc833f7b8cf5b709adf5ea063a40f5 100755 GIT binary patch delta 606 zcmYk2&r2Io5Xa|jvcEEDUr`}YBN|;}1t9@JdMaW;P_Q5pJQeXD5CktpWcBb4p1cj> zMZtU2RTnMxq&*cp>p`NRi7{1s^P)Jran)V+z3*psXFlw6-JI*@Mg)AxKDEHxCDDz& zP_X+cfPH=dG_i6DFxGdRNhNC^NYMD62tn}br@Xd_tq%)QNui{sWK7AplDd+HlBSZD zlJ>4l#HIM<>#d2OrazlW%v&m(*v(>m^ZaME=aNeP{YaHm0ngdmEz!BHvZ!ClNQ(vL*UM3zM z3*=N-R-l;*%L;+4jZQ1r&6#DxVw3)txHNr(>CaJf{6!XVC~t<>;W0Y6!5!Ma!z3+M Xv6ueb;wL((VvdHcFzKiN;o0ajR{xEv delta 605 zcmYk1O-LJ25P;`xvc_hz$*Up+sTyNKv>;XxiXw<8^dKmTnEFaV4=T!xz9Cfo$0%m<-nSY{q)o(LtOzx0OJDH`w}?Qd5&Qt_U6oS)9M z0HLP^(b+8yaj3b&J`TJ8u#sl(@FV9Ze{n#3r{Mx$Rpl_=>lJe;?=RCH`yAH5(hSYySeBu)9Lq8#S%O;cF~vE{5_Ejc`6{j7V_&aVtU1lNxZKQ@zp^a-pX>qa ztxP->ElTEDX3|sw 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/';