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); // Clean out the database foreach ($db->list_tables() as $table) { $db->query("DROP TABLE $table"); } // Clean out the filesystem @system("rm -rf test/var"); @system('mkdir -p test/var/logs'); // Install all modules core_installer::install(); foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) { $module_name = basename(dirname(dirname($file))); if ($module_name == "core") { continue; } $modules = Kohana::config('core.modules'); $modules[] = MODPATH . $module_name; Kohana::config_set('core.modules', $modules); require_once(DOCROOT . "modules/${module_name}/helpers/${module_name}_installer.php"); $installer_class = "{$module_name}_installer"; if (method_exists($installer_class, "install")) { call_user_func_array(array($installer_class, "install"), array()); } } print new Unit_Test(); } }