Captures a stack trace if none given.
public traceMethod ( array $stack = false ) : string | ||
$stack | array | List of stack frames. |
return | string | Snippet of test report with line number and file. |
/** * Uses a stack trace to find the line of an assertion. * @access public * @static */ function getExpectationLine() { $trace = new SimpleStackTrace(array('expect')); return $trace->traceMethod(); }
/** * Uses a stack trace to find the line of an assertion. * @return string Line number of first assert* * method embedded in format string. */ public function getAssertionLine() { $trace = new SimpleStackTrace(array('assert', 'expect', 'pass', 'fail', 'skip')); return $trace->traceMethod(); }
/** * Uses a stack trace to find the line of an assertion. * @return string Line number of first assert* * method embedded in format string. * @access public */ function getAssertionLine() { $trace = new SimpleStackTrace(array('assert', 'click', 'pass', 'fail')); return $trace->traceMethod(); }
function testCanFindAssertInTrace() { $trace = new SimpleStackTrace(array('assert')); $this->assertEqual($trace->traceMethod(array(array('file' => '/my_test.php', 'line' => 24, 'function' => 'assertSomething'))), ' at [/my_test.php line 24]'); }