Skip to content

Commit

Permalink
Inject exception file and line number frame into stack trace in case …
Browse files Browse the repository at this point in the history
…it is missing (#4491)
  • Loading branch information
rhl-jfm authored and DavertMik committed Sep 11, 2017
1 parent 90236dd commit 0e6814c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Codeception/PHPUnit/Overrides/Filter.php
Expand Up @@ -19,6 +19,16 @@ public static function getFilteredStackTrace($e, $asString = true, $filter = tru
$trace = $e->getSerializableTrace();
}

$eFile = $e->getFile();
$eLine = $e->getLine();

if (!self::frameExists($trace, $eFile, $eLine)) {
array_unshift(
$trace,
['file' => $eFile, 'line' => $eLine]
);
}

foreach ($trace as $step) {
if (self::classIsFiltered($step) and $filter) {
continue;
Expand Down Expand Up @@ -85,4 +95,23 @@ protected static function fileIsFiltered($step)

return false;
}

/**
* @param array $trace
* @param string $file
* @param int $line
*
* @return bool
*/
private static function frameExists(array $trace, $file, $line)
{
foreach ($trace as $frame) {
if (isset($frame['file']) && $frame['file'] == $file &&
isset($frame['line']) && $frame['line'] == $line) {
return true;
}
}

return false;
}
}

0 comments on commit 0e6814c

Please sign in to comment.