Skip to content

Instantly share code, notes, and snippets.

@amercier
Created December 6, 2013 12:34
Show Gist options
  • Save amercier/7823046 to your computer and use it in GitHub Desktop.
Save amercier/7823046 to your computer and use it in GitHub Desktop.
<?php
try {
throw new \RuntimeException('Tu peux pas test');
}
catch (\RuntimeException $e) {
// var_dump($e->getTrace());
$trace = $e->getTrace();
$found = false;
foreach ($trace as $i => $info) {
if (array_key_exists('class', $info)
&& preg_match('/^Test\\\\VCloud\\\\Helpers\\\\Unit\\\\/', $info['class'])
) {
$found = true;
break;
}
}
// => $i = index of our test case in the trace
if ($found) {
print_r(array(
'class' => $trace[$i]['class'],
'function' => $trace[$i]['function'],
'line' => $trace[$i-1]['line'],
'method' => $subject->getMethod(),
'url' => $url->__toString(),
'stub' => $filename . '.json',
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment