public function testIgnoredFunctionArgs() { $bt = array(array('type' => '->', 'file' => 'MyFile.php', 'line' => 99, 'function' => 'myIgnoredGlobalFunction', 'args' => array('password' => 'secred')), array('class' => 'MyClass', 'type' => '->', 'file' => 'MyFile.php', 'line' => 99, 'function' => 'myIgnoredClassFunction', 'args' => array('password' => 'secred')), array('class' => 'MyClass', 'type' => '->', 'file' => 'MyFile.php', 'line' => 99, 'function' => 'myFunction', 'args' => array('myarg' => 'myval'))); Backtrace::config()->update('ignore_function_args', array(array('MyClass', 'myIgnoredClassFunction'), 'myIgnoredGlobalFunction')); $filtered = Backtrace::filter_backtrace($bt); $this->assertEquals('<filtered>', $filtered[0]['args']['password'], 'Filters global functions'); $this->assertEquals('<filtered>', $filtered[1]['args']['password'], 'Filters class functions'); $this->assertEquals('myval', $filtered[2]['args']['myarg'], 'Doesnt filter other functions'); }
protected function writeTest($test) { if ($test['status'] != TEST_SUCCESS) { $filteredTrace = array(); foreach ($test['trace'] as $item) { if (isset($item['file']) && strpos($item['file'], 'PHPUnit/Framework') === false && !isset($item['class'])) { $filteredTrace[] = $item; } if (isset($item['class']) && isset($item['function']) && $item['class'] == 'PHPUnit_Framework_TestSuite' && $item['function'] == 'run') { break; } } $color = $test['status'] == 2 ? 'yellow' : 'red'; echo "\n" . CLI::text($test['name'] . "\n" . $test['message'] . "\n", $color, null); echo Backtrace::get_rendered_backtrace($filteredTrace, true); echo "--------------------\n"; } }
/** * Write a backtrace * * @param array $trace * @return string */ public function renderTrace($trace = null) { $output = "Trace\n=====\n"; $output .= Backtrace::get_rendered_backtrace($trace ? $trace : debug_backtrace(), true); return $output; }
/** * Writes a status message to the output stream in a user readable HTML format * @param string $name Name of the object that generated the error * @param string $message Message of the error * @param array $trace Stacktrace */ protected function writeResultError($name, $message, $trace) { echo "<div class=\"failure\"><h2 class=\"test-case\">⊗ " . $this->testNameToPhrase($name) . "</h2>"; echo "<pre>" . htmlentities($message, ENT_COMPAT, 'UTF-8') . "</pre>"; echo Backtrace::get_rendered_backtrace($trace); echo "</div>"; }
/** * Render a call track * * @param array $trace The debug_backtrace() array * @return string */ public function renderTrace($trace) { $output = '<h3>Trace</h3>'; $output .= Backtrace::get_rendered_backtrace($trace); $output .= '</div>'; return $output; }