Skip to content

Commit

Permalink
CiderMode™ (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 20, 2019
1 parent 1ffb7b5 commit 025d1ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/Runner/CliTester.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private function loadOptions(): CommandLine
'--temp' => [CommandLine::REALPATH => true], '--temp' => [CommandLine::REALPATH => true],
'paths' => [CommandLine::REPEATABLE => true, CommandLine::VALUE => getcwd()], 'paths' => [CommandLine::REPEATABLE => true, CommandLine::VALUE => getcwd()],
'--debug' => [], '--debug' => [],
'--cider' => [],
'--coverage-src' => [CommandLine::REALPATH => true, CommandLine::REPEATABLE => true], '--coverage-src' => [CommandLine::REALPATH => true, CommandLine::REPEATABLE => true],
]); ]);


Expand Down Expand Up @@ -204,7 +205,12 @@ private function createRunner(): Runner
$runner->outputHandlers[] = new Output\JUnitPrinter; $runner->outputHandlers[] = new Output\JUnitPrinter;
break; break;
default: 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']
);
} }
} }


Expand Down
17 changes: 10 additions & 7 deletions src/Runner/Output/ConsolePrinter.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,12 +44,20 @@ class ConsolePrinter implements Tester\Runner\OutputHandler
/** @var string */ /** @var string */
private $baseDir; 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->runner = $runner;
$this->displaySkipped = $displaySkipped; $this->displaySkipped = $displaySkipped;
$this->file = fopen($file, 'w'); $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'),
];
} }




Expand Down Expand Up @@ -95,12 +103,7 @@ public function prepare(Test $test): void
public function finish(Test $test): void public function finish(Test $test): void
{ {
$this->results[$test->getResult()]++; $this->results[$test->getResult()]++;
$outputs = [ fwrite($this->file, $this->symbols[$test->getResult()]);
Test::PASSED => '.',
Test::SKIPPED => 's',
Test::FAILED => Dumper::color('white/red', 'F'),
];
fwrite($this->file, $outputs[$test->getResult()]);


$title = ($test->title ? "$test->title | " : '') . substr($test->getSignature(), strlen($this->baseDir)); $title = ($test->title ? "$test->title | " : '') . substr($test->getSignature(), strlen($this->baseDir));
$message = ' ' . str_replace("\n", "\n ", trim((string) $test->message)) . "\n\n"; $message = ' ' . str_replace("\n", "\n ", trim((string) $test->message)) . "\n\n";
Expand Down

0 comments on commit 025d1ce

Please sign in to comment.