2008-08-13 03:47:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test reporter optimised for CLI (ie, plain-text) output
|
|
|
|
*/
|
|
|
|
class CliTestReporter extends SapphireTestReporter {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display error bar if it exists
|
|
|
|
*/
|
|
|
|
public function writeResults() {
|
|
|
|
$passCount = 0;
|
|
|
|
$failCount = 0;
|
|
|
|
$testCount = 0;
|
|
|
|
$errorCount = 0;
|
|
|
|
|
|
|
|
foreach($this->suiteResults['suites'] as $suite) {
|
|
|
|
foreach($suite['tests'] as $test) {
|
|
|
|
$testCount++;
|
|
|
|
($test['status'] == 1) ? $passCount++ : $failCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$result = ($failCount > 0) ? 'fail' : 'pass';
|
2008-09-23 05:22:13 +02:00
|
|
|
echo "\n\n$testCount tests run: $passCount passes, $failCount fails, and 0 exceptions\n\n";
|
2008-08-13 03:47:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function endTest( PHPUnit_Framework_Test $test, $time) {
|
2008-09-23 05:22:13 +02:00
|
|
|
// Status indicator, a la PHPUnit
|
|
|
|
switch($this->currentTest['status']) {
|
|
|
|
case TEST_FAILURE: echo "F"; break;
|
|
|
|
case TEST_ERROR: echo "E"; break;
|
|
|
|
case TEST_INCOMPLETE: echo "I"; break;
|
|
|
|
case TEST_SUCCESS: echo "."; break;
|
|
|
|
default: echo "?"; break;
|
|
|
|
}
|
|
|
|
|
2008-08-13 03:47:05 +02:00
|
|
|
parent::endTest($test, $time);
|
|
|
|
$this->writeTest($this->currentTest);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected function writeTest($test) {
|
|
|
|
if ($test['status'] != 1) {
|
|
|
|
echo $this->testNameToPhrase($test['name']) . "\n". $test['message'] . "\n";
|
|
|
|
echo "In line {$test['exception']['line']} of {$test['exception']['file']}" . "\n\n";
|
2008-08-13 05:42:45 +02:00
|
|
|
echo Debug::get_rendered_backtrace($test['trace'], true);
|
|
|
|
echo "\n--------------------\n";
|
2008-08-13 03:47:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|