public function run($path = null)
{
if (!($path = $this->_path($path))) {
return false;
}
if (!preg_match('/(tests|Test\\.php)/', $path)) {
if (!($path = Unit::get($path))) {
$this->error('Cannot map path to test path.');
return static::EXIT_NO_TEST;
}
}
$handlers = $this->_handlers;
if (!isset($handlers[$this->format]) || !is_callable($handlers[$this->format])) {
$this->error(sprintf('No handler for format `%s`... ', $this->format));
return false;
}
$filters = $this->filters ? array_map('trim', explode(',', $this->filters)) : array();
$params = compact('filters') + array('format' => $this->format);
$runner = function ($options = array()) use($path, $params) {
return Dispatcher::run($path, $params + $options);
};
$report = $handlers[$this->format]($runner, $path);
$stats = $report->stats();
return $stats['success'];
}