/** * Configures the environment for testing * * Does the following: * * * Loads the phpunit framework (for the web ui) * * Restores exception phpunit error handlers (for cli) * * registeres an autoloader to load test files */ public static function configure_environment($do_whitelist = TRUE, $do_blacklist = TRUE) { // During a webui request we need to manually load PHPUnit if (!class_exists('PHPUnit_Util_Filter', FALSE) and !function_exists('phpunit_autoload')) { try { include_once 'PHPUnit/Autoload.php'; } catch (ErrorException $e) { include_once 'PHPUnit/Framework.php'; } } // Allow PHPUnit to handle exceptions and errors if (Kohana::$is_cli) { restore_exception_handler(); restore_error_handler(); } spl_autoload_register(array('Kohana_Tests', 'autoload')); Kohana_Tests::$cache = ($cache = Kohana::cache('unittest_whitelist_cache')) === NULL ? array() : $cache; // As of PHPUnit v3.5 there are slight differences in the way files are black|whitelisted self::$phpunit_v35 = function_exists('phpunit_autoload'); $config = Kohana::config('unittest'); if ($do_whitelist and $config->use_whitelist) { self::whitelist(); } if ($do_blacklist and count($config['blacklist'])) { Kohana_Tests::blacklist($config->blacklist); } }