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; } } try { // Find all tests, excluding sample tests that come with the unit_test module. 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 if ($tables = $db->list_tables()) { foreach ($db->list_tables() as $table) { $db->query("DROP TABLE $table"); } } // Clean out the filesystem @system("rm -rf test/var"); @mkdir('test/var/logs', 0777, true); // Reset our caches module::$modules = array(); module::$active = array(); module::$var_cache = array(); $db->clear_cache(); // Rest the cascading class path Kohana::config_set("core", Kohana::config_load("core")); // Install all modules // Force gallery and user to be installed first to resolve dependencies. gallery_installer::install(true); module::load_modules(); module::install("user"); module::activate("user"); $modules = array(); foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) { $module_name = basename(dirname(dirname($file))); if (in_array($module_name, array("gallery", "user"))) { continue; } module::install($module_name); module::activate($module_name); } // Trigger late-binding install actions (defined in gallery_event::user_login) graphics::choose_default_toolkit(); $filter = count($_SERVER["argv"]) > 2 ? $_SERVER["argv"][2] : null; print new Unit_Test($modules, $filter); } catch (Exception $e) { print "Exception: {$e->getMessage()}\n"; print $e->getTraceAsString() . "\n"; } } }