/**
* @param \PHPUnit_Framework_TestResult $result
*/
public function printResult(\PHPUnit_Framework_TestResult $result)
{
if ($this->runner->shouldNotify()) {
ob_start();
}
$testDox = trim(TestDox::get(spl_object_hash($result)));
if (strlen($testDox)) {
$this->write(PHP_EOL . PHP_EOL . $testDox);
}
parent::printResult($result);
if ($this->runner->shouldNotify()) {
$output = ob_get_contents();
ob_end_clean();
echo $output;
if ($result->failureCount() + $result->errorCount() + $result->skippedCount() + $result->notImplementedCount() == 0) {
$notificationResult = Notification::RESULT_PASSED;
} else {
$notificationResult = Notification::RESULT_FAILED;
}
if (preg_match('/^(?:\\x1b\\[30;42m\\x1b\\[2K)?(OK .+)/m', $output, $matches)) {
$notificationMessage = $matches[1];
} elseif (preg_match('/^(?:\\x1b\\[37;41m\\x1b\\[2K)?(FAILURES!)\\s^(?:\\x1b\\[0m\\x1b\\[37;41m\\x1b\\[2K)?(.+)/m', $output, $matches)) {
$notificationMessage = $matches[1] . PHP_EOL . $matches[2];
} elseif (preg_match('/^(?:\\x1b\\[30;43m\\x1b\\[2K)?(OK, but incomplete or skipped tests!)\\s^(?:\\x1b\\[0m\\x1b\\[30;43m\\x1b\\[2K)?(.+)/m', $output, $matches)) {
$notificationMessage = $matches[1] . PHP_EOL . $matches[2];
} elseif (preg_match('/^(?:\\x1b\\[30;43m\\x1b\\[2K)?(No tests executed!)/m', $output, $matches)) {
$notificationMessage = $matches[1];
}
$this->notification = new Notification($notificationResult, $notificationMessage);
}
}