This patch gives you a full stack trace in
PHPUnit_error_handler if you're running a recent enough
version of PHP that supports it (4.3.0+, I believe).
This is very useful for tracking down errors/warnings
that occur during unit testing.
--- phpunit.inc 16 Mar 2003 06:51:17 -0000 1.1
+++ phpunit.inc 17 Mar 2003 09:15:07 -0000
@@ -48,7 +48,26 @@
if (phpversion() >= '4') {
function PHPUnit_error_handler($errno, $errstr,
$errfile, $errline) {
global $PHPUnit_testRunning;
- $PHPUnit_testRunning[0]->fail("<B>PHP
ERROR:</B> ".$errstr." <B>in</B> ".$errfile." <B>at
line</B> ".$errline);
+
+ $message = "<B>PHP ERROR:</B> ".$errstr;
+ if (function_exists('debug_backtrace')) {
+ $traceSource = debug_backtrace();
+ array_shift($traceSource);
+ foreach ($traceSource as $traceEntry) {
+ $buf = '<B>in</B> ' . $traceEntry['file'];
+ if (isset($traceEntry['class']) &&
isset($traceEntry['function'])) {
+ $buf .= "
($traceEntry[class]::$traceEntry[function]) ";
+ } else if (isset($traceEntry['class'])) {
+ $buf .= " ($traceEntry[function]) ";
+ }
+ $buf .= " <B>at line</B>
$traceEntry[line]";
+ $trace[] = $buf;
+ }
+ $message .= '<BR>' . join('<BR>', $trace);
+ } else {
+ $message .=" <B>in</B> ".$errfile." <B>at
line</B> ".$errline;
+ }
+ $PHPUnit_testRunning[0]->fail($message);
}
}
Logged In: YES
user_id=42211
Hmm, that sure is hard to read. I'm attaching the patch as
a text file which will hopefully be a lot more legible.
Add stack trace to errors
Logged In: YES
user_id=42211
Sigh, forgot to click the "attach file" checkbox in my last
comment. This UI sure needs some help.