result publishing: the beginnings
This commit is contained in:
parent
b519542d76
commit
035a5da679
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class ConsoleListener {
|
||||
class ConsoleListener extends TestListener {
|
||||
|
||||
private $verbosity;
|
||||
private $currentLineLength;
|
||||
|
@ -62,6 +62,10 @@
|
||||
|
||||
}
|
||||
|
||||
public function publishTestResult(TestResult $result) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -53,6 +53,14 @@
|
||||
return $failedTests;
|
||||
}
|
||||
|
||||
public function publish(array $listeners) {
|
||||
foreach ($this->getAllTestResults() as $result) {
|
||||
foreach ($listeners as $listener) {
|
||||
$listener->publishTestResult($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
25
src/TUnit/framework/result/SingleTestResult.php
Normal file
25
src/TUnit/framework/result/SingleTestResult.php
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -6,6 +6,8 @@
|
||||
|
||||
public function failed();
|
||||
|
||||
public function publish(array $listeners);
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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',
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
|
||||
$runner = new TestRunner(array(new TestSuite('Main Test Suite', $tests)), array(new ConsoleListener()));
|
||||
$runner->runTests();
|
||||
$runner->runAndPublish();
|
||||
exit(0);
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user