diff --git a/src/Testify/framework/BaseTestRunner.php b/src/Testify/framework/BaseTestRunner.php index d03e783..cd1a220 100644 --- a/src/Testify/framework/BaseTestRunner.php +++ b/src/Testify/framework/BaseTestRunner.php @@ -284,6 +284,29 @@ } } + /** + * Publishes framework errors + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * @uses ErrorStack::getWarnings() + * @uses ErrorStack::getErrors() + * @uses err() + * @uses warn() + */ + public function publishErrors() { + $warnings = ErrorStack::getWarnings(); + foreach ($warnings as $message) { + $this->warn($message); + } + + $errors = ErrorStack::getErrors(); + foreach ($errors as $message) { + $this->err($message); + } + } + /** * Called before runTests() * @@ -303,6 +326,7 @@ * @since 1.0 * @uses TestListener::beforeTestRunner() * @uses publishResults() + * @uses publishErrors() * @uses TestListener::afterTestRunner() */ public final function run() { @@ -317,6 +341,7 @@ $this->endTime = microtime(true); $this->publishResults($results); + $this->publishErrors(); foreach ($this->listeners as $listener) { $listener->afterTestRunner($this); diff --git a/src/Testify/framework/ErrorStack.php b/src/Testify/framework/ErrorStack.php new file mode 100644 index 0000000..e41d548 --- /dev/null +++ b/src/Testify/framework/ErrorStack.php @@ -0,0 +1,51 @@ +getMessage() . "\n" . $e->getTraceAsString(); + } else if (!is_string($message)) { + throw new InvalidArgumentException('1st argument must be a string or an instance of Exception'); + } + + if ($type === 'warning') { + self::$warningStack[] = $message; + } else { + self::$errorStack[] = $message; + } + } + + public static function addError($message) { + self::addToStack($message, 'error'); + } + + public static function addWarning($message) { + self::addToStack($message, 'warning'); + } + + public static function getErrors() { + return self::$errorStack; + } + + public static function getWarnings() { + return self::$warningStack; + } + + public static function getAll() { + return array_merge(self::$errorStack, self::$warningStack); + } + + public static function clear() { + self::$errorStack = array(); + self::$warningStack = array(); + } + + } + +?> \ No newline at end of file diff --git a/src/Testify/framework/listeners/ConsoleListener.php b/src/Testify/framework/listeners/ConsoleListener.php index a5e6298..033843d 100644 --- a/src/Testify/framework/listeners/ConsoleListener.php +++ b/src/Testify/framework/listeners/ConsoleListener.php @@ -425,7 +425,7 @@ * @param mixed $message */ public function onFrameworkError($message) { - $this->err('ERROR: ' . $message); + $this->err('ERROR: ' . $message . "\n"); } /** @@ -439,7 +439,7 @@ */ public function onFrameworkWarning($message) { if ($this->verbosity > self::VERBOSITY_LOW) { - $this->out('WARNING: ' . $message); + $this->out('WARNING: ' . $message . "\n"); } } diff --git a/src/Testify/framework/test/TestCase.php b/src/Testify/framework/test/TestCase.php index 0ed4605..8f6f09c 100644 --- a/src/Testify/framework/test/TestCase.php +++ b/src/Testify/framework/test/TestCase.php @@ -187,7 +187,17 @@ $method->getDeclaringClass()->getName() !== __CLASS__ && preg_match('/^[\/\*\s]*@test\s*(?:\*\/)?$/m', $method->getDocComment()) ) { - $methods[$method->getName()] = new TestMethod(Util::getClosure($this, $method->getName()), get_class($this) . '::' . $method->getName(), $this->getAutoVerify()); + $name = get_class($this) . '::' . $method->getName(); + if (!$method->isPublic()) { + ErrorStack::addWarning('The test ' . $name . ' is not a public method'); + continue; + } + if (count($method->getParameters()) > 0) { + ErrorStack::addWarning('The test ' . $name . ' has an invalid method signature'); + continue; + } + + $methods[$method->getName()] = new TestMethod(Util::getClosure($this, $method->getName()), $name, $this->getAutoVerify()); } } diff --git a/src/Testify/manifest.php b/src/Testify/manifest.php index 44f8d64..b1265b7 100644 --- a/src/Testify/manifest.php +++ b/src/Testify/manifest.php @@ -3,7 +3,7 @@ /** * Autoload manifest * - * Autogenerated by manifester.php on 2009-07-08 01:27:37 + * Autogenerated by manifester.php on 2009-07-08 02:00:33 * * @package Testify * @version 0.7.0 @@ -33,6 +33,7 @@ 'EqualConstraint' => 'Testify/framework/constraints/EqualConstraint.php', 'ErredTest' => 'Testify/framework/result/FailedTest.php', 'ErredTestResult' => 'Testify/framework/result/SingleTestResults.php', + 'ErrorStack' => 'Testify/framework/ErrorStack.php', 'FailedTest' => 'Testify/framework/result/FailedTest.php', 'FailedTestResult' => 'Testify/framework/result/SingleTestResults.php', 'FalseConstraint' => 'Testify/framework/constraints/SimpleConstraints.php',