Created
December 6, 2013 12:34
-
-
Save amercier/7823046 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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