// Written by Fred Yankowski <fred@ontosys.com>\r
// OntoSys, Inc <http://www.OntoSys.com>\r
//\r
-// $Id: phpunit.php,v 1.1 2002/03/30 19:32:17 bmatzelle Exp $\r
+// $Id$\r
\r
// Copyright (c) 2000 Fred Yankowski\r
\r
// SOFTWARE.\r
//\r
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE |\r
- E_CORE_ERROR | E_CORE_WARNING);\r
+ E_CORE_ERROR | E_CORE_WARNING);\r
\r
/*\r
interface Test {\r
}\r
\r
\r
-class Exception {\r
+class phpUnitException {\r
/* Emulate a Java exception, sort of... */\r
var $message;\r
- function Exception($message) {\r
+ var $type;\r
+ function phpUnitException($message, $type = 'FAILURE') {\r
$this->message = $message;\r
+ $this->type = $type;\r
}\r
function getMessage() {\r
return $this->message;\r
$htmlExpected = htmlspecialchars($expected);\r
$htmlActual = htmlspecialchars($actual);\r
$str .= sprintf("<pre>%s\n--------\n%s</pre>",\r
- $htmlExpected, $htmlActual);\r
+ $htmlExpected, $htmlActual);\r
$this->fail($str);\r
}\r
}\r
// get matched below and then treated (incorrectly) as a test\r
// method. So don't name any TestCase subclasses as "Test..."!\r
if (floor(phpversion()) >= 4) {\r
- // PHP4 introspection, submitted by Dylan Kuhn\r
- $names = get_class_methods($classname);\r
- while (list($key, $method) = each($names)) {\r
- if (preg_match('/^test/', $method) && $method != "testcase") { \r
- $this->addTest(new $classname($method));\r
- }\r
- }\r
+ // PHP4 introspection, submitted by Dylan Kuhn\r
+ $names = get_class_methods($classname);\r
+ while (list($key, $method) = each($names)) {\r
+ if (preg_match('/^test/', $method) && $method != "testcase") {\r
+ $this->addTest(new $classname($method));\r
+ }\r
+ }\r
}\r
else {\r
- $dummy = new $classname("dummy");\r
- $names = (array) $dummy;\r
- while (list($key, $value) = each($names)) {\r
- $type = gettype($value);\r
- if ($type == "user function" && preg_match('/^test/', $key)\r
- && $key != "testcase") { \r
- $this->addTest(new $classname($key));\r
- }\r
- }\r
+ $dummy = new $classname("dummy");\r
+ $names = (array) $dummy;\r
+ while (list($key, $value) = each($names)) {\r
+ $type = gettype($value);\r
+ if ($type == "user function" && preg_match('/^test/', $key)\r
+ && $key != "testcase") {\r
+ $this->addTest(new $classname($key));\r
+ }\r
+ }\r
}\r
}\r
}\r
reset($this->fTests);\r
while (list($na, $test) = each($this->fTests)) {\r
if ($testResult->shouldStop())\r
- break;\r
+ break;\r
$test->run(&$testResult);\r
}\r
}\r
\r
function _endTest($test) /* protected */ {\r
/* specialize this for end-of-test action, such as progress\r
- reports */\r
+ reports */\r
}\r
\r
function getFailures() {\r
function TextTestResult() {\r
$this->TestResult(); // call superclass constructor\r
}\r
- \r
+\r
function report() {\r
/* report result of test run */\r
$nRun = $this->countTests();\r
$exceptions = $failure->getExceptions();\r
print("<ul>");\r
while (list($na, $exception) = each($exceptions))\r
- printf("<li>%s\n", $exception->getMessage());\r
+ printf("<li>%s\n", $exception->getMessage());\r
print("</ul>");\r
}\r
print("</ol>\n");\r