Extends
lithium\core\Object
Runs the test methods in this test case, with the given options.
Parameter
- array $options The options to use when running the test. Available options are: - 'methods': An arbitrary array of method names to execute. If unspecified, all methods starting with 'test' are run. - 'reporter': A closure which gets called after each test result, which may modify the results presented.
Gibt zurück
arraySource
public function run(array $options = array()) {
$defaults = array('methods' => array(), 'reporter' => null, 'handler' => null);
$options += $defaults;
$this->_results = array();
$self = $this;
try {
$this->skip();
} catch (Exception $e) {
$this->_handleException($e);
return $this->_results;
}
$h = function($code, $message, $file, $line = 0, $context = array()) use ($self) {
$trace = debug_backtrace();
$trace = array_slice($trace, 1, count($trace));
$self->invokeMethod('_reportException', array(
compact('code', 'message', 'file', 'line', 'trace', 'context')
));
};
$options['handler'] = $options['handler'] ?: $h;
set_error_handler($options['handler']);
$methods = $options['methods'] ?: $this->methods();
$this->_reporter = $options['reporter'] ?: $this->_reporter;
foreach ($methods as $method) {
if ($this->_runTestMethod($method, $options) === false) {
break;
}
}
restore_error_handler();
return $this->_results;
}