Exemple #1
0
 /**
  * Trys to get the original exception thrown by the test on failure/error 
  * to enable us to give a bit more detail about the failure/error
  * 
  * @access private
  * @param obj PHPUnit2_Framework_Test, current test that is being run
  * @param obj PHPUnit2_Framework_AssertationFailedError, PHPUnit2 error
  * @return array
  */
 private function getTestException(PHPUnit2_Framework_Test $test, Exception $e)
 {
     // get the name of the testFile from the test
     $testName = ereg_replace('(.*)\\((.*[^)])\\)', '\\2', $test->toString());
     $trace = $e->getTrace();
     // loop through the exception trace to find the original exception
     for ($i = 0; $i < count($trace); $i++) {
         if (array_key_exists('file', $trace[$i])) {
             if (stristr($trace[$i]['file'], $testName . '.php') != false) {
                 return $trace[$i];
             }
         }
         if (array_key_exists('file:protected', $trace[$i])) {
             if (stristr($trace[$i]['file:protected'], $testName . '.php') != false) {
                 return $trace[$i];
             }
         }
     }
 }