public function run() : bool
{
// Filters tests
foreach (array_keys($this->tests) as $ident) {
if (!$this->includeTest($ident)) {
unset($this->tests[$ident]);
}
}
// Shuffles them
$idents = array_keys($this->tests);
shuffle($idents);
// Performs tests and gathers results
$order = 1;
$allSucceeded = true;
foreach ($idents as $ident) {
// Runs a test
$data = $this->runTest($ident);
// Saves the overall status
$allSucceeded = $allSucceeded && $data['result']->isSuccess();
// Adds the text into the output
$data['order'] = $order++;
$this->testsData[] = $data;
}
// Sorts tests according to their identifiers
$idents = [];
foreach ($this->testsData as $key => $data) {
$idents[$key] = $data['ident'];
}
array_multisort($idents, SORT_ASC, $this->testsData);
if ($this->output === self::OUTPUT_NOTHING) {
return $allSucceeded;
}
// Outputs the header
if ($allSucceeded) {
header('HTTP/1.1 200 OK');
} else {
header('HTTP/1.1 500 Internal Server Error');
}
// Outputs the output :)
switch ($this->output) {
// Plaintext
case self::OUTPUT_TEXT:
$this->writeText($allSucceeded);
break;
// HTML
// HTML
case self::OUTPUT_HTML:
default:
$this->writeHtml($allSucceeded);
break;
}
return $allSucceeded;
}