protected function setupFormatter(IndexedServiceContainer $container)
{
$container->define('formatter.formatters.progress', function (IndexedServiceContainer $c) {
return new SpecFormatter\ProgressFormatter($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
});
$container->define('formatter.formatters.pretty', function (IndexedServiceContainer $c) {
return new SpecFormatter\PrettyFormatter($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
});
$container->define('formatter.formatters.junit', function (IndexedServiceContainer $c) {
return new SpecFormatter\JUnitFormatter($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
});
$container->define('formatter.formatters.dot', function (IndexedServiceContainer $c) {
return new SpecFormatter\DotFormatter($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
});
$container->define('formatter.formatters.tap', function (IndexedServiceContainer $c) {
return new SpecFormatter\TapFormatter($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
});
$container->define('formatter.formatters.html', function (IndexedServiceContainer $c) {
$io = new SpecFormatter\Html\HtmlIO();
$template = new SpecFormatter\Html\Template($io);
$factory = new SpecFormatter\Html\ReportItemFactory($template);
$presenter = $c->get('formatter.presenter.html');
return new SpecFormatter\HtmlFormatter($factory, $presenter, $io, $c->get('event_dispatcher.listeners.stats'));
});
$container->define('formatter.formatters.h', function (IndexedServiceContainer $c) {
return $c->get('formatter.formatters.html');
});
$container->addConfigurator(function (IndexedServiceContainer $c) {
$formatterName = $c->getParam('formatter.name', 'progress');
$c->get('console.output')->setFormatter(new Formatter($c->get('console.output')->isDecorated()));
try {
$formatter = $c->get('formatter.formatters.' . $formatterName);
} catch (\InvalidArgumentException $e) {
throw new \RuntimeException(sprintf('Formatter not recognised: "%s"', $formatterName));
}
$c->set('event_dispatcher.listeners.formatter', $formatter, ['event_dispatcher.listeners']);
});
}