本文整理汇总了PHP中PHPUnit_Framework_TestFailure::thrownException方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestFailure::thrownException方法的具体用法?PHP PHPUnit_Framework_TestFailure::thrownException怎么用?PHP PHPUnit_Framework_TestFailure::thrownException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestFailure
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestFailure::thrownException方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printDefectTrace
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();
}
}
示例2: printDefectTrace
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());
}
}
示例3: printDefectTrace
/**
* @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();
}
}
示例4: _askForRetry
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;
}
示例5: getException
/**
* 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;
}
示例6: printDefectTrace
/**
* @param PHPUnit_Framework_TestFailure $defect
*/
protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
{
$this->write($defect->getExceptionAsString() . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException(), FALSE));
}
示例7: printDefectTrace
/**
* @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);
}
}
示例8: printDefectTrace
/**
* @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));
}
示例9: printDefectTrace
/**
* @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();
}
}
示例10: printDefectTrace
/**
* @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));
}
}
示例11: printDefectTrace
/**
* @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>');
}
示例12: printDefectTrace
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);
}
示例13: printDefectTrace
/**
* @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());
}