From e56fa884ed3242c0383f131850c5ba53e5850c95 Mon Sep 17 00:00:00 2001 From: tmont Date: Sun, 28 Jun 2009 01:01:46 +0000 Subject: [PATCH] comments, and combined single test results into one file --- .../framework/result/CombinedTestResult.php | 147 ++++++++++- .../framework/result/ErredTestResult.php | 15 -- src/TUnit/framework/result/FailedTest.php | 65 +++++ .../framework/result/FailedTestResult.php | 15 -- .../framework/result/IgnoredTestResult.php | 15 -- .../framework/result/PassedTestResult.php | 15 -- .../framework/result/SingleTestResult.php | 27 -- .../framework/result/SingleTestResults.php | 241 ++++++++++++++++++ src/TUnit/framework/result/TestResult.php | 31 +++ src/TUnit/manifest.php | 12 +- 10 files changed, 481 insertions(+), 102 deletions(-) delete mode 100644 src/TUnit/framework/result/ErredTestResult.php delete mode 100644 src/TUnit/framework/result/FailedTestResult.php delete mode 100644 src/TUnit/framework/result/IgnoredTestResult.php delete mode 100644 src/TUnit/framework/result/PassedTestResult.php delete mode 100644 src/TUnit/framework/result/SingleTestResult.php create mode 100644 src/TUnit/framework/result/SingleTestResults.php diff --git a/src/TUnit/framework/result/CombinedTestResult.php b/src/TUnit/framework/result/CombinedTestResult.php index 38f266b..6079d96 100644 --- a/src/TUnit/framework/result/CombinedTestResult.php +++ b/src/TUnit/framework/result/CombinedTestResult.php @@ -1,41 +1,140 @@ testResults = $results; } + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * @uses getFailedTestResults() + * + * @return bool + */ public function passed() { return count($this->getFailedTestResults()) === 0; } + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * @uses getFailedTestResults() + * + * @return bool + */ public function failed() { return count($this->getFailedTestResults()) > 0; } + /** + * gets the number of tests + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * @uses getAllTestResults() + * + * @return int + */ public function count() { return count($this->getAllTestResults()); } - public function addTestResult(TestResult $result) { + /** + * Adds a test result + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @param TestResult $result + */ + public final function addTestResult(TestResult $result) { $this->testResults[] = $result; } - public function getTestResults() { + /** + * Gets the test results + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return array + */ + public final function getTestResults() { return $this->testResults; } - public function getAllTestResults() { + /** + * Flattens out combined results into single test results and + * returns a single-dimensional array of all of them + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * @uses RecursiveTestIterator + * + * @return array + */ + public final function getAllTestResults() { $tests = array(); foreach (new RecursiveIteratorIterator(new RecursiveTestIterator($this->testResults)) as $test) { $tests[] = $test; } + return $tests; } + /** + * Gets all passed test results + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * @uses getAllTestResults() + * + * @return array + */ public function getPassedTestResults() { $passedTests = array(); foreach ($this->getAllTestResults() as $testResult) { @@ -47,6 +146,16 @@ return $passedTests; } + /** + * Gets all failed test results + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * @uses getAllTestResults() + * + * @return array + */ public function getFailedTestResults() { $failedTests = array(); foreach ($this->getAllTestResults() as $testResult) { @@ -58,26 +167,46 @@ return $failedTests; } + /** + * Gets all ignored test results + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * @uses getAllTestResults() + * + * @return array + */ public function getIgnoredTestResults() { - $failedTests = array(); + $ignoredTests = array(); foreach ($this->getAllTestResults() as $testResult) { if ($testResult instanceof IgnoredTestResult) { - $failedTests[] = $testResult; + $ignoredTests[] = $testResult; } } - return $failedTests; + return $ignoredTests; } + /** + * Gets all erred test results + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * @uses getAllTestResults() + * + * @return array + */ public function getErredTestResults() { - $failedTests = array(); + $erredTests = array(); foreach ($this->getAllTestResults() as $testResult) { if ($testResult instanceof ErredTestResult) { - $failedTests[] = $testResult; + $erredTests[] = $testResult; } } - return $failedTests; + return $erredTests; } } diff --git a/src/TUnit/framework/result/ErredTestResult.php b/src/TUnit/framework/result/ErredTestResult.php deleted file mode 100644 index a051f95..0000000 --- a/src/TUnit/framework/result/ErredTestResult.php +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/src/TUnit/framework/result/FailedTest.php b/src/TUnit/framework/result/FailedTest.php index ef75de2..908f4ce 100644 --- a/src/TUnit/framework/result/FailedTest.php +++ b/src/TUnit/framework/result/FailedTest.php @@ -1,15 +1,54 @@ innerException = $innerException; } + /** + * Gets the stack trace for the test failure + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return string + */ public function getStackTrace() { $trace = ($this->innerException !== null) ? $this->innerException->getTrace() : $this->getTrace(); $count = 1; @@ -48,8 +87,34 @@ } + /** + * A failed test + * + * @package TUnit + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + */ class FailedTest extends TestFailure {} + + /** + * An erred test + * + * @package TUnit + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + */ class ErredTest extends FailedTest {} + + /** + * An ignored test + * + * @package TUnit + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + */ class IgnoredTest extends TestFailure {} ?> \ No newline at end of file diff --git a/src/TUnit/framework/result/FailedTestResult.php b/src/TUnit/framework/result/FailedTestResult.php deleted file mode 100644 index 3d4a8e3..0000000 --- a/src/TUnit/framework/result/FailedTestResult.php +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/src/TUnit/framework/result/IgnoredTestResult.php b/src/TUnit/framework/result/IgnoredTestResult.php deleted file mode 100644 index a288dff..0000000 --- a/src/TUnit/framework/result/IgnoredTestResult.php +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/src/TUnit/framework/result/PassedTestResult.php b/src/TUnit/framework/result/PassedTestResult.php deleted file mode 100644 index ddfe0b8..0000000 --- a/src/TUnit/framework/result/PassedTestResult.php +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/src/TUnit/framework/result/SingleTestResult.php b/src/TUnit/framework/result/SingleTestResult.php deleted file mode 100644 index 7eb643d..0000000 --- a/src/TUnit/framework/result/SingleTestResult.php +++ /dev/null @@ -1,27 +0,0 @@ -test = $test; - $this->failure = $failure; - } - - public function getTest() { - return $this->test; - } - - public function getFailure() { - return $this->failure; - } - - public function count() { - return 1; - } - - } - -?> \ No newline at end of file diff --git a/src/TUnit/framework/result/SingleTestResults.php b/src/TUnit/framework/result/SingleTestResults.php new file mode 100644 index 0000000..549fcb3 --- /dev/null +++ b/src/TUnit/framework/result/SingleTestResults.php @@ -0,0 +1,241 @@ +test = $test; + $this->failure = $failure; + } + + /** + * Gets the test + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return Testable + */ + public function getTest() { + return $this->test; + } + + /** + * Gets the failure, or null if the test did not fail + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return TestFailure|null + */ + public function getFailure() { + return $this->failure; + } + + /** + * Gets the number of tests + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return int Always returns one + */ + public function count() { + return 1; + } + + } + + /** + * The test erred + * + * @package TUnit + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + */ + class ErredTestResult extends SingleTestResult { + + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return bool + */ + public function passed() { + return false; + } + + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return bool + */ + public function failed() { + return true; + } + + } + + /** + * The test passed + * + * @package TUnit + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + */ + class PassedTestResult extends SingleTestResult { + + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return bool + */ + public function passed() { + return true; + } + + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return bool + */ + public function failed() { + return false; + } + + } + + /** + * The test was ignored + * + * @package TUnit + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + */ + class IgnoredTestResult extends SingleTestResult { + + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return bool + */ + public function passed() { + return false; + } + + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return bool + */ + public function failed() { + return false; + } + + } + + /** + * The test failed + * + * @package TUnit + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + */ + class FailedTestResult extends SingleTestResult { + + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return bool + */ + public function passed() { + return false; + } + + /** + * {@inheritdoc} + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return bool + */ + public function failed() { + return true; + } + + } + + +?> \ No newline at end of file diff --git a/src/TUnit/framework/result/TestResult.php b/src/TUnit/framework/result/TestResult.php index 93fa0c6..e46ddda 100644 --- a/src/TUnit/framework/result/TestResult.php +++ b/src/TUnit/framework/result/TestResult.php @@ -1,9 +1,40 @@ 'TUnit/framework/constraints/SimpleConstraints.php', 'EqualConstraint' => 'TUnit/framework/constraints/EqualConstraint.php', 'ErredTest' => 'TUnit/framework/result/FailedTest.php', - 'ErredTestResult' => 'TUnit/framework/result/ErredTestResult.php', + 'ErredTestResult' => 'TUnit/framework/result/SingleTestResults.php', 'FailedTest' => 'TUnit/framework/result/FailedTest.php', - 'FailedTestResult' => 'TUnit/framework/result/FailedTestResult.php', + 'FailedTestResult' => 'TUnit/framework/result/SingleTestResults.php', 'FalseConstraint' => 'TUnit/framework/constraints/SimpleConstraints.php', 'IdenticalConstraint' => 'TUnit/framework/constraints/IdenticalConstraint.php', 'IgnoredTest' => 'TUnit/framework/result/FailedTest.php', - 'IgnoredTestResult' => 'TUnit/framework/result/IgnoredTestResult.php', + 'IgnoredTestResult' => 'TUnit/framework/result/SingleTestResults.php', 'InvalidOptionException' => 'TUnit/framework/exceptions/Exceptions.php', 'InvocationExpectation' => 'TUnit/framework/mock/InvocationExpectation.php', 'InvocationTracker' => 'TUnit/framework/mock/InvocationTracker.php', @@ -44,14 +44,14 @@ 'MockRegistry' => 'TUnit/framework/mock/MockRegistry.php', 'NotConstraint' => 'TUnit/framework/constraints/NotConstraint.php', 'NullConstraint' => 'TUnit/framework/constraints/SimpleConstraints.php', - 'PassedTestResult' => 'TUnit/framework/result/PassedTestResult.php', + 'PassedTestResult' => 'TUnit/framework/result/SingleTestResults.php', 'PhpFileIterator' => 'TUnit/util/PhpFileIterator.php', 'Product' => 'TUnit/util/Product.php', 'RecursivePhpFileIterator' => 'TUnit/util/PhpFileIterator.php', 'RecursiveTestIterator' => 'TUnit/util/RecursiveTestIterator.php', 'RecursivelyCountable' => 'TUnit/framework/test/Testable.php', 'SimpleConstraint' => 'TUnit/framework/constraints/SimpleConstraints.php', - 'SingleTestResult' => 'TUnit/framework/result/SingleTestResult.php', + 'SingleTestResult' => 'TUnit/framework/result/SingleTestResults.php', 'TUnitException' => 'TUnit/framework/exceptions/Exceptions.php', 'TestAccumulator' => 'TUnit/util/TestAccumulator.php', 'TestCase' => 'TUnit/framework/test/TestCase.php',