This page runs all the phpUnit self-tests, and produces nice HTML output.
Unlike typical test run, expect many test cases to
fail. Exactly those with pass in their name
should succeed.
For each test we display both the test result -- ok, FAIL, or
ERROR -- and also a meta-result --
as expected, UNEXPECTED, or unknown -- that indicates whether the
expected test result occurred. Although many test results will
be 'FAIL' here, all meta-results should be 'as expected', except
for a few 'unknown' meta-results (because of errors) when running
in PHP3.
Tests
testcase = &$testcase;
}
function curMethod($method)
{
$this->method = $method;
}
function pushExpect($message, $priority, $errarray)
{
unset($errarray['time']);
unset($errarray['context']);
array_push($this->expect, array($message, $priority, $errarray));
}
function clearExpect()
{
$this->expect = array();
}
function log($message, $priority, $errarray)
{
$this->testcase->wasLogged = true;
if (!is_a($this->testcase, 'PHPUnit_TestCase')) {
trigger_error('ERROR: burflog never set up', E_USER_ERROR);
return;
}
if (!isset($this->method)) {
$this->testcase->assertFalse(true, 'ERROR: burflog never set up');
return;
}
if (!count($this->expect)) {
$this->testcase->assertFalse(true, "method $this->method: logged, but no log expected");
$this->testcase->assertFalse(true, "method $this->method: log message = $message");
$this->testcase->assertFalse(true, "method $this->method: log priority = $priority");
return;
}
unset($errarray['time']);
unset($errarray['context']);
$expect = array_pop($this->expect);
$this->testcase->assertEquals($expect[0], $message, "method $this->method: wrong message");
$this->testcase->assertEquals($expect[1], $priority, "method $this->method: wrong priority");
$this->testcase->assertEquals($expect[2], $errarray, "method $this->method: wrong errarray");
}
}
$suite = new PHPUnit_TestSuite();
foreach ($testcases as $testcase) {
include_once $testcase . '.php';
$suite->addTestSuite($testcase);
}
$listener = new HTML_TestListener();
$finalresult = TestUnit::run($suite, $listener);
$results = include_once dirname(__FILE__) . '/base_regression.php';
$num = $results['number'];
$failed = $results['failed'];
$passed = $results['passed'];
for ($i = 1; $i <= $num; $i++) {
$bla = new Mock_PHPUnit;
$bla->name = $i;
$listener->startTest($bla);
if (isset($failed[$i])) {
$listener->addFailure($bla, $failed[$i]);
$finalresult->addFailure($bla, $a = 'context had additional ' . serialize($failed[$i]));
}
$listener->endTest($bla);
}
$finalresult->removeListener($listener);
// hack in the base regression test count
$finalresult->_runTests += count($results['failed']) + count($results['passed']);
$finalresult->report();
?>