/** * Returns a description for an exception. * * @param Exception $e * @return string * @since Method available since Release 3.2.0 */ public static function exceptionToString(Exception $e) { if ($e instanceof PHPUnit_Framework_SelfDescribing) { $buffer = $e->toString(); if ($e instanceof PHPUnit_Framework_ExpectationFailedException && $e->getComparisonFailure()) { $buffer = $buffer . $e->getComparisonFailure()->getDiff(); } if (!empty($buffer)) { $buffer = trim($buffer) . "\n"; } } elseif ($e instanceof PHPUnit_Framework_Error) { $buffer = $e->getMessage() . "\n"; } elseif ($e instanceof PHPUnit_Framework_ExceptionWrapper) { $buffer = $e->getClassname() . ': ' . $e->getMessage() . "\n"; } else { $buffer = get_class($e) . ': ' . $e->getMessage() . "\n"; } return $buffer; }
/** * Adds the test incomplete detail to the current test and increases the incomplete * count for the current suite * * @access public * @param obj PHPUnit_Framework_Test, current test that is being run * @param obj PHPUnit_Framework_AssertationFailedError, PHPUnit error * @return void */ public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) { $this->currentSuite['incomplete']++; $this->currentTest['status'] = TEST_INCOMPLETE; $this->currentTest['message'] = $e->toString(); $this->currentTest['exception'] = $this->getTestException($test, $e); $this->currentTest['trace'] = $e->getTrace(); }
/** * Adds the test incomplete detail to the current test and increases the incomplete * count for the current suite * * @access public * @param obj PHPUnit_Framework_Test, current test that is being run * @param obj PHPUnit_Framework_AssertationFailedError, PHPUnit error * @return void */ public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) { $this->currentSuite['incomplete']++; $this->addStatus(TEST_INCOMPLETE, $e->toString(), $this->getTestException($test, $e), $e->getTrace()); }
/** * Returns a description for an exception. * * @param Exception $e * @return string * @since Method available since Release 3.2.0 */ public static function exceptionToString(Exception $e) { if ($e instanceof PHPUnit_Framework_SelfDescribing) { if ($e instanceof PHPUnit_Framework_ExpectationFailedException) { $comparisonFailure = $e->getComparisonFailure(); $description = $e->getDescription(); $message = $e->getCustomMessage(); if ($message == '') { $buffer = ''; } else { $buffer = $message . "\n"; } if ($comparisonFailure !== NULL) { if ($comparisonFailure->identical()) { if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Object) { $buffer .= 'Failed asserting that two variables ' . "reference the same object.\n"; } else { $buffer .= $comparisonFailure->toString() . "\n"; } } else { if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Scalar) { $buffer .= sprintf("Failed asserting that %s matches expected %s.\n", PHPUnit_Util_Type::toString($comparisonFailure->getActual()), PHPUnit_Util_Type::toString($comparisonFailure->getExpected())); } else { if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Array || $comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Object || $comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_String) { $buffer .= sprintf("Failed asserting that two %ss are equal.\n%s\n", strtolower(substr(get_class($comparisonFailure), 36)), $comparisonFailure->toString()); } } } } else { $buffer .= $e->toString(); if (!empty($buffer)) { $buffer .= "\n"; } if (strpos($buffer, $description) === FALSE) { $buffer .= $description . "\n"; } } } else { $buffer = $e->toString(); if (!empty($buffer)) { $buffer .= "\n"; } } } else { if ($e instanceof PHPUnit_Framework_Error) { $buffer = $e->getMessage() . "\n"; } else { $buffer = get_class($e) . ': ' . $e->getMessage() . "\n"; } } return $buffer; }
/** * @return string */ public function __toString() { return Exception::toString($this->toException()); }
/** * Format proxied Throwable as string. * * @return string */ public function __toString() { return Exception::toString($this->toThrowable()); }
/** * Renders an exception * * @param Exception $e */ protected function renderException(Exception $e) { $hasColors = $this->detectColors(); // excerpt? if ($e instanceof ILess_Exception) { printf("%s: %s\n", $this->scriptName, $hasColors && !$this->getOption('no_color') ? ILess_ANSIColor::colorize($e->toString(false), 'red') : $e->toString(false)); if ($excerpt = $e->getExcerpt()) { $hasColors ? printf("%s\n", $excerpt->toTerminal()) : printf("%s\n", $excerpt->toText()); } } else { printf("%s: %s\n", $this->scriptName, $hasColors && !$this->getOption('no_color') ? ILess_ANSIColor::colorize($e->getMessage(), 'red') : $e->getMessage()); } }