From 6f959deed90750d3f87f26e64fc44beb3f7ba903 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 3 Dec 2008 03:23:30 +0000 Subject: Rename generic test.php to gallery_unit_test.php to make navigation to this file a little easier --- .../controllers/gallery_unit_test.php | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 modules/gallery_unit_test/controllers/gallery_unit_test.php (limited to 'modules/gallery_unit_test/controllers/gallery_unit_test.php') diff --git a/modules/gallery_unit_test/controllers/gallery_unit_test.php b/modules/gallery_unit_test/controllers/gallery_unit_test.php new file mode 100644 index 00000000..2046e323 --- /dev/null +++ b/modules/gallery_unit_test/controllers/gallery_unit_test.php @@ -0,0 +1,105 @@ +connect(); + + // Make this the default database for the rest of this run + Database::$instances = array('default' => $db); + } catch (Exception $e) { + print "{$e->getMessage()}\n"; + return; + } + } + + // Find all tests, excluding sample tests that come with the unit_test module. + $paths = array(APPPATH . "tests"); + foreach (glob(MODPATH . "*/tests") as $path) { + if ($path != MODPATH . "unit_test/tests") { + $paths[] = $path; + } + } + Kohana::config_set('unit_test.paths', $paths); + + // We probably don't want to uninstall and reinstall the core every time, but let's start off + // this way. Uninstall modules first and core last. Ignore errors during uninstall. + try { + $this->_uninstall_modules(); + } catch (Exception $e) { + } + + $this->_install_modules(); + + print new Unit_Test(); + } + + private function _uninstall_modules() { + foreach (module::installed() as $module) { + if ($module->name == "core") { + continue; + } + + $installer_class = "{$module->name}_installer"; + Kohana::log("debug", "$installer_class"); + if (method_exists($installer_class, "uninstall")) { + call_user_func_array(array($installer_class, "uninstall"), array()); + } + } + + // Always uninstall core last. + core_installer::uninstall(); + } + + private function _install_modules() { + core_installer::install(); + + foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) { + $module_name = basename(dirname(dirname($file))); + if ($module_name == "core") { + continue; + } + + $installer_class = "{$module_name}_installer"; + if (method_exists($installer_class, "install")) { + call_user_func_array(array($installer_class, "install"), array()); + } + } + } +} -- cgit v1.2.3