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::get_list() as $module) { if ($module->name == "core") { continue; } $installer_class = "{$module->name}_installer"; if (method_exists($installer_class, "uninstall")) { Kohana::log("debug", "method uninstall exists"); } } // 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()); } } } }