result publishing: the beginnings

This commit is contained in:
tmont 2009-06-13 22:41:24 +00:00
parent b519542d76
commit 035a5da679
13 changed files with 63 additions and 49 deletions

View File

@ -27,7 +27,7 @@
$results[] = $test->run($this->listeners);
} else {
foreach ($this->listeners as $listener) {
$listener->onFrameworkWarning('Unable to run test because it is not an instanceof Testable (' . gettype($test) . ')');
$listener->onFrameworkWarning('Unable to run test because it is not an instance of Testable (' . gettype($test) . ')');
}
}
}
@ -35,6 +35,16 @@
return $results;
}
public function publishResults(array $testResults) {
foreach ($testResults as $testResult) {
$testResult->publish($this->listeners);
}
}
public function runAndPublish() {
$this->publishResults($this->runTests());
}
}
?>

View File

@ -10,10 +10,6 @@
$this->actual = $actual;
}
public abstract function evaluate();
protected abstract function getFailureMessage();
public function fail($message = '') {
throw new FailedTest($this->toString($message));
}
@ -24,6 +20,10 @@
return $message;
}
public abstract function evaluate();
protected abstract function getFailureMessage();
}
?>

View File

@ -1,6 +1,6 @@
<?php
class ConsoleListener {
class ConsoleListener extends TestListener {
private $verbosity;
private $currentLineLength;

View File

@ -62,6 +62,10 @@
}
public function publishTestResult(TestResult $result) {
}
}
?>

View File

@ -53,6 +53,14 @@
return $failedTests;
}
public function publish(array $listeners) {
foreach ($this->getAllTestResults() as $result) {
foreach ($listeners as $listener) {
$listener->publishTestResult($result);
}
}
}
}
?>

View File

@ -1,14 +1,6 @@
<?php
class ErredTestResult implements TestResult {
protected $test;
protected $failure;
public function __construct(Testable $test, TestFailure $failure) {
$this->test = $test;
$this->failure = $failure;
}
class ErredTestResult extends SingleTestResult {
public function passed() {
return false;
@ -18,10 +10,6 @@
return true;
}
public function count() {
return 1;
}
}
?>

View File

@ -1,14 +1,6 @@
<?php
class FailedTestResult implements TestResult {
protected $test;
protected $failure;
public function __construct(Testable $test, TestFailure $failure) {
$this->test = $test;
$this->failure = $failure;
}
class FailedTestResult extends SingleTestResult {
public function passed() {
return false;
@ -18,10 +10,6 @@
return true;
}
public function count() {
return 1;
}
}
?>

View File

@ -1,14 +1,6 @@
<?php
class IgnoredTestResult implements TestResult {
protected $test;
protected $failure;
public function __construct(Testable $test, TestFailure $failure) {
$this->test = $test;
$this->failure = $failure;
}
class IgnoredTestResult extends SingleTestResult {
public function passed() {
return false;
@ -18,10 +10,6 @@
return false;
}
public function count() {
return 1;
}
}
?>

View File

@ -0,0 +1,25 @@
<?php
abstract class SingleTestResult implements TestResult {
protected $test;
protected $failure;
public function __construct(Testable $test, TestFailure $failure) {
$this->test = $test;
$this->failure = $failure;
}
public function count() {
return 1;
}
public function publish(array $listeners) {
foreach ($listeners as $listener) {
$listener->publishTestResult($this);
}
}
}
?>

View File

@ -6,6 +6,8 @@
public function failed();
public function publish(array $listeners);
}
?>

View File

@ -15,8 +15,8 @@
$listener->beforeTestMethod($this);
}
$result = null;
$failure = null;
$result = null;
$failure = null;
$this->testCase->setUp();
try {

View File

@ -3,7 +3,7 @@
/**
* Autoload manifest
*
* Autogenerated by manifester.php on 2009-06-13 15:28:20
* Autogenerated by manifester.php on 2009-06-13 15:40:20
*
* @package TUnit
* @version 0.1.0
@ -27,6 +27,7 @@
'IgnoredTest' => 'TUnit/framework/result/FailedTest.php',
'IgnoredTestResult' => 'TUnit/framework/result/IgnoredTestResult.php',
'PassedTestResult' => 'TUnit/framework/result/PassedTestResult.php',
'SingleTestResult' => 'TUnit/framework/result/SingleTestResult.php',
'TestCase' => 'TUnit/framework/test/TestCase.php',
'TestFailure' => 'TUnit/framework/result/FailedTest.php',
'TestListener' => 'TUnit/framework/listeners/TestListener.php',

View File

@ -45,7 +45,7 @@
$runner = new TestRunner(array(new TestSuite('Main Test Suite', $tests)), array(new ConsoleListener()));
$runner->runTests();
$runner->runAndPublish();
exit(0);
?>