diff --git a/Unit_testing/SimpleTestListener.php b/Unit_testing/SimpleTestListener.php new file mode 100644 index 0000000..3d48555 --- /dev/null +++ b/Unit_testing/SimpleTestListener.php @@ -0,0 +1,111 @@ +passes[ $suiteName ]; + } + + public function countFails( $suiteName ) + { + return $this->fails[ $suiteName ]; + } + + public function countErrors( $suiteName ) + { + return $this->errors[ $suiteName ]; + } + + public function countIncompletes( $suiteName ) + { + return $this->incompletes[ $suiteName ]; + } + + public function countSkips( $suiteName ) + { + return $this->skips[ $suiteName ]; + } + + public function countTests( $suiteName ) + { + return $this->tests[ $suiteName ]; + } + + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + echo "ERROR! " . $e->getMessage() . "\n"; + $this->errorCount++; + } + + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + echo "FAILED! " . $e->getMessage() . "\n"; + $this->failCount++; + } + + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + echo "INCOMPLETE: " . $e->getMessage() . "\n"; + $this->incompleteCount++; + } + + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + echo "SKIPPED: " . $e->getMessage() . "\n"; + $this->skipCount++; + } + + public function startTest(PHPUnit_Framework_Test $test) + { +// printf("Test '%s' started.\n", $test->getName()); + $this->testCount++; + } + + public function endTest(PHPUnit_Framework_Test $test, $time) + { +// printf("Test '%s' ended.\n", $test->getName()); + if ( $test->getStatus() === PHPUnit_Runner_BaseTestRunner::STATUS_PASSED ) + { + echo "OK\n"; + $this->passCount++; + } + } + + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { +// printf("TestSuite '%s' started.\n", $suite->getName()); + $this->passCount = $this->failCount = $this->errorCount = $this->incompleteCount = $this->skipCount = $this->testCount = 0; + } + + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { +// printf("TestSuite '%s' ended.\n", $suite->getName()); + $this->passes[ $suite->getName() ] = $this->passCount; + $this->fails[ $suite->getName() ] = $this->failCount; + $this->errors[ $suite->getName() ] = $this->errorCount; + $this->incompletes[ $suite->getName() ] = $this->incompleteCount; + $this->skips[ $suite->getName() ] = $this->skipCount; + $this->tests[ $suite->getName() ] = $this->testCount; + } + } +?>