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'); // Reset our loaded modules module::load_modules(); // Install all modules module::install("core"); $modules = array(); foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) { $module_name = basename(dirname(dirname($file))); if ($module_name == "core") { continue; } module::install($module_name); } $filter = count($_SERVER["argv"]) > 2 ? $_SERVER["argv"][2] : null; print new Unit_Test($modules, $filter); } }