Gets the thrown exception.
public thrownException ( ) : Exception | ||
return | Exception |
protected function printDefectTrace(\PHPUnit_Framework_TestFailure $defect) { $this->write($this->formatExceptionMsg($defect->getExceptionAsString())); $trace = \PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException()); if (!empty($trace)) { $this->write("\n" . $trace); } $exception = $defect->thrownException()->getPrevious(); while ($exception) { $this->write("\nCaused by\n" . \PHPUnit_Framework_TestFailure::exceptionToString($e) . "\n" . \PHPUnit_Util_Filter::getFilteredStacktrace($e)); $exception = $exception->getPrevious(); } }
protected function printDefectTrace(\PHPUnit_Framework_TestFailure $defect) { $e = $defect->thrownException(); if (!$e instanceof \atk4\core\PHPUnit_AgileExceptionWrapper) { return parent::printDefectTrace($defect); } $this->write((string) $e); $p = $e->getPrevious(); if ($p instanceof \atk4\core\Exception or $p instanceof \atk4\dsql\Exception) { $this->write($p->getColorfulText()); } }
/** * @param \PHPUnit_Framework_TestFailure $defect */ protected function printDefectTrace(\PHPUnit_Framework_TestFailure $defect) { $this->write($defect->getExceptionAsString()); $this->writeNewLine(); $stackTrace = \PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException(), false); foreach ($stackTrace as $i => $frame) { if (!isset($frame['file'])) { continue; } $this->write(sprintf("#%d %s(%s)", $i + 1, $frame['file'], isset($frame['line']) ? $frame['line'] : '?')); $this->writeNewLine(); } }
private function _askForRetry(PHPUnit_Framework_Test $test, Exception $e, $time) { if ($e instanceof PHPUnit_Framework_IncompleteTest) { return false; } if ($e instanceof PHPUnit_Framework_SkippedTest) { return false; } if (file_exists("/www/testtimes")) { $app = Kwf_Registry::get('config')->application->id; file_put_contents("/www/testtimes/failure_{$app}/" . get_class($test), time()); } if (!$this->_retryOnError) { return false; } $error = new PHPUnit_Framework_TestFailure($test, $e); if ($test instanceof PHPUnit_Framework_SelfDescribing) { echo $test->toString(); } else { echo get_class($test); } echo "\n"; echo $error->getExceptionAsString() . PHPUnit_Util_Filter::getFilteredStacktrace($error->thrownException(), FALSE); echo "\nTest failed. Try again? [Y/n]"; if (isset($_SERVER['USER']) && $_SERVER['USER'] == 'niko') { $msg = Kwf_Registry::get('config')->application->name . ' Test failed. Try again?'; $msg = str_replace(" ", "\\ ", utf8_decode($msg)); system("ssh niko \"export DISPLAY=:0 && /usr/bin/kdialog --passivepopup {$msg} 2\""); } $stdin = fopen('php://stdin', 'r'); $input = strtolower(trim(fgets($stdin, 2))); fclose($stdin); if ($input == 'j' || $input == 'y' || $input == '') { $this->run($test); return true; } return false; }
/** * Gets the thrown exception from a PHPUnit_Framework_TestFailure. * * @param PHPUnit_Framework_TestFailure $error * @since Method available since Release 3.6.0 * @see https://github.com/sebastianbergmann/phpunit/issues/74 */ protected function getException(PHPUnit_Framework_TestFailure $error) { $exception = $error->thrownException(); if ($exception instanceof __PHP_Incomplete_Class) { $exceptionArray = array(); foreach ((array) $exception as $key => $value) { $key = substr($key, strrpos($key, "") + 1); $exceptionArray[$key] = $value; } $exception = new PHPUnit_Framework_SyntheticError(sprintf('%s: %s', $exceptionArray['_PHP_Incomplete_Class_Name'], $exceptionArray['message']), $exceptionArray['code'], $exceptionArray['file'], $exceptionArray['line'], $exceptionArray['trace']); } return $exception; }
/** * @param PHPUnit_Framework_TestFailure $defect */ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) { $this->write($defect->getExceptionAsString() . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException(), FALSE)); }
/** * @param PHPUnit_Framework_TestFailure $defect */ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) { $e = $defect->thrownException(); $this->write((string) $e); while ($e = $e->getPrevious()) { $this->write("\nCaused by\n" . $e); } }
/** * @param PHPUnit_Framework_TestFailure $defect * @access protected */ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) { $e = $defect->thrownException(); if ($e instanceof PHPUnit_Framework_SelfDescribing) { $buffer = $e->toString(); if (!empty($buffer)) { $buffer .= "\n"; } if ($e instanceof PHPUnit_Framework_ExpectationFailedException) { $comparisonFailure = $e->getComparisonFailure(); if ($comparisonFailure !== NULL) { if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Scalar) { $buffer .= sprintf("Failed asserting that %s matches expected value %s.\n", PHPUnit_Util_Type::toString($comparisonFailure->getActual()), PHPUnit_Util_Type::toString($comparisonFailure->getExpected())); } else { if (PHPUnit_Framework_ComparisonFailure::hasDiff() && ($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()); } } if ($this->verbose && !$comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Array && !$comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Object && !$comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_String) { $buffer .= $comparisonFailure->toString() . "\n"; } } else { $buffer .= $e->getDescription() . "\n"; } } } else { if ($e instanceof PHPUnit_Framework_Error) { $buffer = $e->getMessage() . "\n"; } else { $buffer = get_class($e) . ': ' . $e->getMessage() . "\n"; } } $this->write($buffer . PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException(), FALSE)); }
/** * @param PHPUnit_Framework_TestFailure $defect */ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) { $this->write($defect->getExceptionAsString() . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException())); $e = $defect->thrownException()->getPrevious(); while ($e) { $this->write("\nCaused by\n" . PHPUnit_Framework_TestFailure::exceptionToString($e) . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($e)); $e = $e->getPrevious(); } }
/** * @param PHPUnit_Framework_TestFailure $defect * @param string $padding */ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect, $padding = 0) { $trace = trim(PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException())); if (!empty($trace)) { $trace = explode("\n", $trace); $trace = "\n" . $padding . '# ' . implode("\n{$padding}# ", $trace); $this->write($this->cyan($trace)); } }
/** * @param PHPUnit_Framework_TestFailure $defect * @access protected */ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) { $this->write('<description>'); $e = $defect->thrownException(); if ($e instanceof PHPUnit_Framework_SelfDescribing) { $this->write($e->toString(), true); if ($e instanceof PHPUnit_Framework_ExpectationFailedException) { $comparisonFailure = $e->getComparisonFailure(); if ($comparisonFailure !== NULL && $comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_String) { $this->write($comparisonFailure->toString(), true); } } } elseif ($e instanceof PHPUnit_Framework_Error) { $this->write($e->getMessage(), true); } else { $this->write(get_class($e) . ': ' . $e->getMessage(), true); } $this->write(PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException(), FALSE), true); $this->write('</description>'); }
protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) { $stacktrace = PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException()); $stacktrace = str_replace([$this->backtrace, rex_path::base()], '', $stacktrace); $this->write($defect->getExceptionAsString() . "\n" . $stacktrace); }
/** * @param PHPUnit_Framework_TestFailure $defect * @access protected */ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) { print $defect->thrownException()->toString() . "\n"; print PHPUnit_Runner_BaseTestRunner::getFilteredStack($defect->thrownException()); }