Skip to content
Permalink
Browse files

CiderMode™ (#394)

  • Loading branch information...
dg committed Feb 20, 2019
1 parent 1ffb7b5 commit 025d1ce3b5845a862dc0ef29dc5e770ecba25d9c
Showing with 17 additions and 8 deletions.
  1. +7 −1 src/Runner/CliTester.php
  2. +10 −7 src/Runner/Output/ConsolePrinter.php
@@ -130,6 +130,7 @@ private function loadOptions(): CommandLine
'--temp' => [CommandLine::REALPATH => true],
'paths' => [CommandLine::REPEATABLE => true, CommandLine::VALUE => getcwd()],
'--debug' => [],
'--cider' => [],
'--coverage-src' => [CommandLine::REALPATH => true, CommandLine::REPEATABLE => true],
]);
@@ -204,7 +205,12 @@ private function createRunner(): Runner
$runner->outputHandlers[] = new Output\JUnitPrinter;
break;
default:
$runner->outputHandlers[] = new Output\ConsolePrinter($runner, (bool) $this->options['-s']);
$runner->outputHandlers[] = new Output\ConsolePrinter(
$runner,
(bool) $this->options['-s'],
'php://output',
(bool) $this->options['--cider']
);
}
}
@@ -44,12 +44,20 @@ class ConsolePrinter implements Tester\Runner\OutputHandler
/** @var string */
private $baseDir;
/** @var array */
private $symbols;
public function __construct(Runner $runner, bool $displaySkipped = false, string $file = 'php://output')
public function __construct(Runner $runner, bool $displaySkipped = false, string $file = 'php://output', bool $ciderMode = false)
{
$this->runner = $runner;
$this->displaySkipped = $displaySkipped;
$this->file = fopen($file, 'w');
$this->symbols = [
Test::PASSED => $ciderMode ? Dumper::color('green', '🍎') : '.',
Test::SKIPPED => 's',
Test::FAILED => $ciderMode ? Dumper::color('red', '🍎') : Dumper::color('white/red', 'F'),
];
}
@@ -95,12 +103,7 @@ public function prepare(Test $test): void
public function finish(Test $test): void
{
$this->results[$test->getResult()]++;
$outputs = [
Test::PASSED => '.',
Test::SKIPPED => 's',
Test::FAILED => Dumper::color('white/red', 'F'),
];
fwrite($this->file, $outputs[$test->getResult()]);
fwrite($this->file, $this->symbols[$test->getResult()]);
$title = ($test->title ? "$test->title | " : '') . substr($test->getSignature(), strlen($this->baseDir));
$message = ' ' . str_replace("\n", "\n ", trim((string) $test->message)) . "\n\n";

0 comments on commit 025d1ce

Please sign in to comment.
You can’t perform that action at this time.