public function writeFinalReport($duration, $summary)
{
// keep count of what the final results are
$succeededGroups = [];
$skippedGroups = [];
$failedGroups = [];
// do we have any results?
if (!isset($this->results)) {
// huh - nothing happened at all
$this->write("HUH - nothing appears to have happened. Time taken: ", $this->writer->puzzledSummaryStyle);
$this->writeDuration($duration, $this->writer->puzzledSummaryStyle);
$this->write(PHP_EOL . PHP_EOL);
return 1;
}
// this is our opportunity to tell the user how our story(ies)
// went in detail
foreach ($this->results as $result) {
// so what happened?
switch ($result->resultCode) {
case PhaseGroup_Result::OKAY:
// this is a good result
$succeededGroups[] = $result;
break;
case PhaseGroup_Result::SKIPPED:
case PhaseGroup_Result::BLACKLISTED:
// this can legitimately happen
$skippedGroups[] = $result;
break;
default:
// everything else is an error of some kind
$failedGroups[] = $result;
}
}
// what's the final tally?
$this->write(PHP_EOL);
if (empty($succeededGroups) && empty($skippedGroups) && empty($failedGroups)) {
// huh - nothing happened at all
$this->write("HUH - nothing appears to have happened. Time taken: ", $this->writer->puzzledSummaryStyle);
$this->writeDuration($duration, $this->writer->puzzledSummaryStyle);
$this->write(PHP_EOL . PHP_EOL);
return 1;
}
if (empty($failedGroups)) {
// nothing failed
$this->write("SUCCESS - " . count($succeededGroups) . ' PASSED, ' . count($skippedGroups) . ' SKIPPED. Time taken: ', $this->writer->successSummaryStyle);
$this->writeDuration($duration, $this->writer->successSummaryStyle);
$this->write(PHP_EOL . PHP_EOL);
return 0;
}
// if we get here, then at least one thing failed
$this->write("FAILURE - " . count($succeededGroups) . ' PASSED, ' . count($skippedGroups) . ' SKIPPED, ' . count($failedGroups) . ' FAILED :( Time taken: ', $this->writer->failSummaryStyle);
$this->writeDuration($duration, $this->writer->failSummaryStyle);
$this->write(PHP_EOL . PHP_EOL);
// write out a list of failed tests - someone will want to look
// at them in detail
$this->write("Here's the list of everything that failed:" . PHP_EOL . PHP_EOL);
// foreach ($skippedGroups as $skippedGroup) {
// $this->writePhaseGroupSkipped();
// $this->write(' ' . $skippedGroup->activity, $this->writer->activityStyle);
// $this->write(' ' . $skippedGroup->name . PHP_EOL, $this->writer->nameStyle);
// if (isset($skippedGroup->filename)) {
// $this->write(' (', $this->writer->punctuationStyle);
// $this->write($skippedGroup->filename, $this->writer->punctuationStyle);
// $this->write(')' . PHP_EOL, $this->writer->punctuationStyle);
// }
// }
foreach ($failedGroups as $failedGroup) {
$this->writePhaseGroupFailed();
$this->write(' ' . $failedGroup->activity, $this->writer->activityStyle);
$this->write(' ' . $failedGroup->name . PHP_EOL, $this->writer->nameStyle);
if (isset($failedGroup->filename)) {
$this->write(' (', $this->writer->punctuationStyle);
$this->write($failedGroup->filename, $this->writer->punctuationStyle);
$this->write(')' . PHP_EOL, $this->writer->punctuationStyle);
}
}
$this->write(PHP_EOL);
// do we stop here?
if (!$summary) {
// we're in dev mode, which means the error reports have
// already been shown where they happened
return 1;
}
// are we being run by hand?
if (function_exists("posix_isatty") && posix_isatty(STDOUT)) {
$this->write("See ");
$this->write("storyplayer.log", $this->writer->argStyle);
$this->write(" for details on what went wrong." . PHP_EOL . PHP_EOL);
}
// all done
return 1;
}