* @license PHP License
* @package WB
* @subpackage unittest
*/
WBClass::load('WBClock');
/**
* Helper class reporer
*
* @version 0.1.0
* @package WB
* @subpackage unittest
*/
class WBUnitTest_Reporter extends SimpleReporter
{
/**
* referernce counter
* @var int
*/
static protected $rev = 0;
/**
* float
* @var timestampt
*/
protected $timestamp;
/**
* constructor
*/
public function __construct()
{
// call parent contrstrutor
self::paintHead();
}
/**
* destructor
*/
public function __destruct()
{
self::paintFoot();
}
/**
* paint HTML header only once
*/
static protected function paintHead()
{
++self::$rev;
if (self::$rev > 1) {
return;
}
$html = array();
$html[] = '';
$html[] = '';
$html[] = '
';
$html[] = sprintf('%sms
%d/%d test cases complete:', $class, $time, $this->getTestCaseProgress(), $this->getTestCaseCount());
$html[] = "\n";
$html[] = sprintf('
%s %s', $cntPass, 'passes');
$html[] = sprintf('
%s %s', $cntFail, 'failed and');
$html[] = sprintf('
%s %s', $cntExcep, 'exceptions.');
$html[] = "\n";
$html[] = '
';
echo implode(' ', $html) . "\n";
flush();
}
/**
* display failure
*
* @param string message
* @see lib/simpletest/SimpleReporter#paintFail($message)
*/
public function paintFail($message)
{
parent::paintFail($message);
$this->paintBox('fail', 'Fail', $message);
}
/**
* Display Error
*
* @param string $message
* @see lib/simpletest/SimpleReporter#paintException($message)
*/
public function paintError($message)
{
parent::paintError($message);
$this->paintBox('fail', 'Error', $message);
}
/**
* display Exception
*
* @param string $message
* @see lib/simpletest/SimpleReporter#paintException($message)
*/
public function paintException($message)
{
parent::paintException($message);
$this->paintBox('fail', 'Exception', $message);
}
/**
* paint generic box
*
* Auxiliary method that displays div
*
* @param string $class
* @param string $title
* @param strring $message
*/
protected function paintBox($class, $title, $message)
{
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
$html = array();
$html[] = '