public static function PHPUnit_Util_Filter::getFilteredStacktrace

Filters stack frames from PHPUnit classes.

Parameters

Exception $e:

boolean $asString:

Return value

string

9 calls to PHPUnit_Util_Filter::getFilteredStacktrace()
PHPUnit_TextUI_ResultPrinter::printDefectTrace in drupal/core/vendor/phpunit/phpunit/PHPUnit/TextUI/ResultPrinter.php
PHPUnit_Util_Log_JSON::addError in drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/Log/JSON.php
An error occurred.
PHPUnit_Util_Log_JSON::addFailure in drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/Log/JSON.php
A failure occurred.
PHPUnit_Util_Log_JSON::addIncompleteTest in drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/Log/JSON.php
Incomplete test.
PHPUnit_Util_Log_JSON::addSkippedTest in drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/Log/JSON.php
Skipped test.

... See full list

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/Filter.php, line 66

Class

PHPUnit_Util_Filter
Utility class for code filtering.

Code

public static function getFilteredStacktrace(Exception $e, $asString = TRUE) {
  $prefix = FALSE;
  $script = realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);
  if (defined('__PHPUNIT_PHAR__')) {
    $prefix = 'phar://' . __PHPUNIT_PHAR__ . '/';
  }
  if (!defined('PHPUNIT_TESTSUITE')) {
    $blacklist = PHPUnit_Util_GlobalState::phpunitFiles();
  }
  else {
    $blacklist = array();
  }
  if ($asString === TRUE) {
    $filteredStacktrace = '';
  }
  else {
    $filteredStacktrace = array();
  }
  if ($e instanceof PHPUnit_Framework_SyntheticError) {
    $eTrace = $e
      ->getSyntheticTrace();
    $eFile = $e
      ->getSyntheticFile();
    $eLine = $e
      ->getSyntheticLine();
  }
  else {
    if ($e
      ->getPrevious()) {
      $eTrace = $e
        ->getPrevious()
        ->getTrace();
    }
    else {
      $eTrace = $e
        ->getTrace();
    }
    $eFile = $e
      ->getFile();
    $eLine = $e
      ->getLine();
  }
  if (!self::frameExists($eTrace, $eFile, $eLine)) {
    array_unshift($eTrace, array(
      'file' => $eFile,
      'line' => $eLine,
    ));
  }
  foreach ($eTrace as $frame) {
    if (isset($frame['file']) && is_file($frame['file']) && !isset($blacklist[$frame['file']]) && strpos($frame['file'], $prefix) !== 0 && $frame['file'] !== $script) {
      if ($asString === TRUE) {
        $filteredStacktrace .= sprintf("%s:%s\n", $frame['file'], isset($frame['line']) ? $frame['line'] : '?');
      }
      else {
        $filteredStacktrace[] = $frame;
      }
    }
  }
  return $filteredStacktrace;
}