/** * 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) { restore_exception_handler(); restore_error_handler(); spl_autoload_register(array('Unittest_tests', 'autoload')); Unittest_tests::$cache = ($cache = Kohana::cache('unittest_whitelist_cache')) === NULL ? array() : $cache; }
/** * 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('Unittest_tests', 'autoload')); // As of PHPUnit v3.5 there are slight differences in the way files are black|whitelisted self::$phpunit_v35 = function_exists('phpunit_autoload'); Unittest_tests::$cache = ($cache = Kohana::cache('unittest_whitelist_cache')) === NULL ? array() : $cache; $config = Kohana::config('unittest'); if ($do_whitelist and $config->use_whitelist) { self::whitelist(); } if ($do_blacklist and count($config['blacklist'])) { Unittest_tests::blacklist($config->blacklist); } }
/** * 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) { restore_exception_handler(); restore_error_handler(); spl_autoload_register(array('Unittest_tests', 'autoload')); // As of PHPUnit v3.5 there are slight differences in the way files are black|whitelisted self::$phpunit_v35 = function_exists('phpunit_autoload'); Unittest_tests::$cache = ($cache = Kohana::cache('unittest_whitelist_cache')) === NULL ? array() : $cache; }
/** * Whitelists a specified set of modules specified by the user * * @param array $modules */ protected function whitelist(array $modules) { $k_modules = Kohana::modules(); $whitelist = array(); // Make sure our whitelist is valid foreach ($modules as $item) { if (isset($k_modules[$item])) { $whitelist[$item] = $k_modules[$item]; } elseif ($item === 'k_app') { $whitelist[$item] = APPPATH; } elseif ($item === 'k_sys') { $whitelist[$item] = SYSPATH; } } if (count($whitelist)) { Unittest_tests::whitelist($whitelist); } return $whitelist; }