本文整理汇总了PHP中PHPUnit_Util_Filter::getFilteredStacktrace方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Filter::getFilteredStacktrace方法的具体用法?PHP PHPUnit_Util_Filter::getFilteredStacktrace怎么用?PHP PHPUnit_Util_Filter::getFilteredStacktrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Util_Filter
的用法示例。
在下文中一共展示了PHPUnit_Util_Filter::getFilteredStacktrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFailure
/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->write('fail: ' . $e->getMessage());
$trace = current(PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE));
$this->write('trace: ' . print_r($trace, 1));
$this->currentTestPass = FALSE;
}
示例2: __toString
/**
* @return string
*/
public function __toString()
{
$string = PHPUnit_Framework_TestFailure::exceptionToString($this);
if ($trace = PHPUnit_Util_Filter::getFilteredStacktrace($this)) {
$string .= "\n" . $trace;
}
return $string;
}
示例3: failureDescription
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
*/
protected function failureDescription($other)
{
if ($other !== null) {
$message = '';
if ($other instanceof Throwable) {
$message = '. Message was: "' . $other->getMessage() . '" at' . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($other);
}
return sprintf('exception of type "%s" matches expected exception "%s"%s', get_class($other), $this->className, $message);
}
return sprintf('exception of type "%s" is thrown', $this->className);
}
示例4: prepareMessage
/**
* @param \Exception $exception
* @param string $dataSetName
* @param mixed $dataSet
* @return string
*/
protected function prepareMessage(\Exception $exception, $dataSetName, $dataSet)
{
if (!is_string($dataSetName)) {
$dataSetName = var_export($dataSet, true);
}
if ($exception instanceof \PHPUnit_Framework_AssertionFailedError && !$exception instanceof \PHPUnit_Framework_IncompleteTestError && !$exception instanceof \PHPUnit_Framework_SkippedTestError || $this->_options['verbose']) {
$dataSetName = 'Data set: ' . $dataSetName . PHP_EOL;
} else {
$dataSetName = '';
}
return $dataSetName . $exception->getMessage() . PHP_EOL . \PHPUnit_Util_Filter::getFilteredStacktrace($exception);
}
示例5: 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();
}
}
示例6: 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();
}
}
示例7: __toString
/**
* @return string
*/
public function __toString()
{
$string = \PHPUnit_Framework_TestFailure::exceptionToString($this);
$e = $this->getWrappedException();
$string .= "\n Request: " . $this->requestToString($e) . "\n" . " HTTP status Code: " . $e->getHttpStatusCode() . "\n" . " Is transient: " . ($e->isTransient() ? 'true' : 'false') . "\n" . " Code: " . $e->getCode() . "\n" . " Error Subcode: " . $e->getErrorSubcode() . "\n" . " Error User Title: " . $e->getErrorUserTitle() . "\n" . " Error User Message: " . $e->getErrorUserMessage() . "\n";
if ($e->getErrorBlameFieldSpecs()) {
$string .= " Error Blame Fields: " . $this->blameFieldSpecsToString() . "\n";
}
if ($trace = \PHPUnit_Util_Filter::getFilteredStacktrace($this)) {
$string .= "\n" . $trace;
}
if ($this->previous) {
$string .= "\nCaused by\n" . $this->previous;
}
return $string;
}
示例8: printTest
/**
* Print test
*
* @param array $test
* @param null $name
* @return string
*/
public function printTest(array $test, $name = NULL)
{
$testName = $name ? $name : $test['testName'];
$roundPrecision = $test['time'] < 10 ? 2 : 0;
$result = '';
$result .= '<div class="test ' . $this->getStatusName($test['status']) . '">';
$result .= '<div class="duration">' . round($test['time'], $roundPrecision) . 's</div>';
$result .= '<h2>' . $this->shorten($testName) . '</h2>';
$result .= '<div class="description">';
if (!empty($test['description'])) {
$result .= '<p>' . nl2br($test['description']) . '</p>';
}
$result .= '</div><!-- description -->';
if (isset($test['loggedTestSteps'])) {
$result .= $this->renderTestSteps($test['loggedTestSteps']);
}
if (is_array($test['info'])) {
$result .= '<ul class="info">';
foreach ($test['info'] as $info) {
$result .= '<li>' . $info . '</li>';
}
$result .= '</ul>';
}
$result .= '<div class="content">';
if ($test['exception'] instanceof Exception) {
$e = $test['exception'];
/* @var $e Exception */
$result .= '<div class="exception">';
$result .= '<i>' . nl2br($this->escape(PHPUnit_Util_Filter::getFilteredStacktrace($e))) . '</i>' . "<br />\n";
$result .= '<pre>' . $this->escape(PHPUnit_Framework_TestFailure::exceptionToString($e)) . '</pre>';
$result .= '</div><!-- exception -->';
}
if (isset($test['screenshots'])) {
$result .= '<div class="screenshots">';
$result .= $this->printScreenshots($test['screenshots']);
$result .= '</div><!-- screenshots -->';
}
$result .= '</div><!-- content -->';
$result .= '</div><!-- test -->';
return $result;
}
示例9: _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;
}
示例10: printResult
public function printResult(PHPUnit_Framework_TestResult $result)
{
echo '<h1>QCubed ' . QCUBED_VERSION_NUMBER_ONLY . ' Unit Tests - PHPUnit ' . PHPUnit_Runner_Version::id() . '</h1>';
foreach ($this->results as $suiteName => $suite) {
$strHtml = "<b>{$suiteName}</b><br />";
foreach ($suite as $testName => $test) {
$status = $test['status'];
$status = ucfirst($status);
if ($test['status'] !== 'passed') {
$status = '<span style="color:red">' . $status . '</span>';
} else {
$status = '<span style="color:green">' . $status . '</span>';
}
$strHtml .= "{$status}: {$testName}";
$strHtml = "{$strHtml}<br />";
if (isset($test['errors'])) {
foreach ($test['errors'] as $error) {
$strHtml .= nl2br(htmlentities($error['e']->__toString())) . '<br />';
}
}
if (isset($test['results'])) {
foreach ($test['results'] as $error) {
$strMessage = $error['e']->toString() . "\n";
// get first line
$lines = explode("\n", PHPUnit_Util_Filter::getFilteredStacktrace($error['e']));
$strMessage .= $lines[0] . "\n";
$strHtml .= nl2br(htmlentities($strMessage)) . '<br />';
}
}
}
echo $strHtml;
}
$str = "\nRan " . $result->count() . " tests in " . $result->time() . " seconds.\n";
$str .= $result->failureCount() . " assertions failed.\n";
$str .= $result->errorCount() . " exceptions were thrown.\n";
echo nl2br($str);
}
示例11: fromPHPUnitTestResult
/**
* Creates a Streamwide_PHPUnit_Runner_TestCaseResult from a PHPUnit_Framework_TestResult.
*
* @param Streamwide_PHPUnit_Runner_TestCase $testCase test case
* @param PHPUnit_Framework_TestResult $testResult test result
* @return Streamwide_PHPUnit_Runner_TestCaseResult test case result
*/
public static function fromPHPUnitTestResult(Streamwide_PHPUnit_Runner_TestCase $testCase, PHPUnit_Framework_TestResult $testResult)
{
$passed = $testResult->passed();
$skipped = $testResult->skipped();
$errors = $testResult->errors();
$failures = $testResult->failures();
$notImplemented = $testResult->notImplemented();
$time = $testResult->time();
$statusMessage = null;
$codeCoverage = null;
if (!empty($passed)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::PASSED;
$codeCoverage = $testResult->getCodeCoverageInformation();
} else {
if (!empty($skipped)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::SKIPPED;
$statusMessage = $skipped[0]->toStringVerbose(true);
} else {
if (!empty($notImplemented)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::NOT_IMPLEMENTED;
$statusMessage = $notImplemented[0]->toStringVerbose(true);
} else {
if (!empty($errors)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::ERROR;
$statusMessage = $errors[0]->toStringVerbose(true) . PHPUnit_Util_Filter::getFilteredStacktrace($errors[0]->thrownException());
} else {
if (!empty($failures)) {
$status = Streamwide_PHPUnit_Runner_TestCaseResult::FAILED;
$statusMessage = $failures[0]->toStringVerbose(true) . PHPUnit_Util_Filter::getFilteredStacktrace($failures[0]->thrownException());
}
}
}
}
}
$testCaseResult = new Streamwide_PHPUnit_Runner_TestCaseResult($testCase, $status, $statusMessage, null, $time, $codeCoverage);
return $testCaseResult;
}
示例12: 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));
}
示例13: addSkippedTest
/**
* Skipped test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
*/
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
$message = PHPUnit_Framework_TestFailure::exceptionToString($e) . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE);
$this->storeResult(PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED, $time, $message);
$this->currentTestSuccess = FALSE;
}
示例14: addSkippedTest
/**
* Skipped test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
*/
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
$this->writeCase('error', $time, PHPUnit_Util_Filter::getFilteredStacktrace($e, false), 'Skipped Test: ' . $e->getMessage(), $test);
$this->currentTestPass = false;
}
示例15: doAddFault
/**
* Method which generalizes addError() and addFailure()
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @param string $type
*/
private function doAddFault(PHPUnit_Framework_Test $test, Exception $e, $time, $type)
{
if ($this->currentTestCase === null) {
return;
}
if ($test instanceof PHPUnit_Framework_SelfDescribing) {
$buffer = $test->toString() . "\n";
} else {
$buffer = '';
}
$buffer .= PHPUnit_Framework_TestFailure::exceptionToString($e) . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($e);
$fault = $this->document->createElement($type, PHPUnit_Util_XML::prepareString($buffer));
$fault->setAttribute('type', get_class($e));
$this->currentTestCase->appendChild($fault);
}