getFilteredStacktrace() публичный статический Метод

Filters stack frames from PHPUnit classes.
public static getFilteredStacktrace ( Exception $e, boolean $filterTests = TRUE, boolean $asString = TRUE ) : string
$e Exception
$filterTests boolean
$asString boolean
Результат string
 /**
  * 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
0
 /**
  * @return string
  */
 public function __toString()
 {
     $string = PHPUnit_Framework_TestFailure::exceptionToString($this);
     if ($trace = PHPUnit_Util_Filter::getFilteredStacktrace($this)) {
         $string .= "\n" . $trace;
     }
     return $string;
 }
Пример #3
0
 /**
  * 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
0
 /**
  * @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);
 }
 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
0
 /**
  * @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();
     }
 }
 /**
  * @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
0
 /**
  * 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
0
 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;
 }
 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
0
 /**
  * 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
0
 /**
  * @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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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);
 }
Пример #16
0
 /**
  * Skipped test.
  *
  * @param PHPUnit_Framework_Test $test
  * @param Exception              $e
  * @param float                  $time
  * @since  Method available since Release 3.0.0
  */
 public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
 {
     if ($this->logIncompleteSkipped && $this->currentTestCase !== null) {
         $error = $this->document->createElement('error', PHPUnit_Util_XML::prepareString("Skipped Test\n" . PHPUnit_Util_Filter::getFilteredStacktrace($e)));
         $error->setAttribute('type', get_class($e));
         $this->currentTestCase->appendChild($error);
         $this->testSuiteErrors[$this->testSuiteLevel]++;
     } else {
         $this->attachCurrentTestCase = false;
     }
 }
 /**
  * Skipped test.
  *
  * @param \PHPUnit_Framework_Test $test
  * @param \Exception              $e
  * @param float                   $time
  *
  * @return void
  */
 public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
 {
     $testName = $test->getName();
     $context = array('testName' => $testName, 'testDescriptionArr' => \PHPUnit_Util_Test::describe($test, false), 'testDescriptionStr' => $test->toString(), 'operation' => __FUNCTION__, 'reason' => $e->getMessage(), 'trace' => \PHPUnit_Util_Filter::getFilteredStacktrace($e, false));
     $this->logger->warning(sprintf("Test '%s' has been skipped.", $testName), $context);
 }
Пример #18
0
/**
 * Generates a suite report from given suite result object
 *
 * @param string $suite suite name
 * @param string $buffer output buffer of the suite run
 * @param object $result the results of the test suite
 * @return array the suite report array
 */
function generateSuiteReport($suite, $buffer, $result)
{
    // create an array with failed test names to separate them from passed tests
    $failedTests = array();
    foreach (array('failures', 'errors', 'notImplemented') as $section) {
        foreach ($result->{$section}() as $test) {
            $failedTests[] = $test->failedTest()->getName();
        }
    }
    $details = $buffer;
    // passed tests
    $passedTests = array();
    foreach ($result->topTestSuite() as $test) {
        if (!in_array($test->getName(), $failedTests)) {
            $passedTests[] = array('name' => $test->getName(), 'class' => get_class($test), 'details' => $details);
        }
    }
    // skipped tests
    $skippedTests = array();
    foreach ($result->notImplemented() as $test) {
        $skippedTests[] = array('name' => $test->failedTest()->getName(), 'class' => get_class($test->failedTest()), 'details' => $details);
    }
    // failed tests
    $failedTests = array();
    foreach ($result->failures() as $test) {
        $failedTests[] = array('name' => $test->failedTest()->getName(), 'class' => get_class($test->failedTest()), 'details' => str_replace('<', '&lt;', $test->toStringVerbose(true)) . PHPUnit_Util_Filter::getFilteredStacktrace($test->thrownException(), false) . $details);
    }
    // error tests
    $errorTests = array();
    foreach ($result->errors() as $test) {
        $errorTests[] = array('name' => $test->failedTest()->getName(), 'class' => get_class($test->failedTest()), 'details' => str_replace('<', '&lt;', $test->toStringVerbose(true)) . PHPUnit_Util_Filter::getFilteredStacktrace($test->thrownException(), false) . $details);
    }
    $suiteReport = array('suite' => $suite, 'buffer' => empty($buffer) ? '' : ' ', 'testsCount' => count($result->topTestSuite()), 'passedTests' => $passedTests, 'failedTests' => $failedTests, 'errorTests' => $errorTests, 'skippedTests' => $skippedTests);
    return $suiteReport;
}
Пример #19
0
 /**
  * @param \PHPUnit_Framework_Test $test
  * @param \Exception              $e
  * @param float                   $time
  * @param string                  $failureOrError
  */
 protected function writeFailureOrError(\PHPUnit_Framework_Test $test, \Exception $e, $time, $failureOrError)
 {
     $testIsArtificial = false;
     if (!$this->testStarted) {
         $this->startTest($test);
         $testIsArtificial = true;
     }
     if ($test instanceof \PHPUnit_Framework_SelfDescribing) {
         $message = $test->toString() . "\n\n";
     } else {
         $message = '';
     }
     $message .= \PHPUnit_Framework_TestFailure::exceptionToString($e) . "\n";
     if ($test instanceof \PHPUnit_Framework_Warning) {
         $testClass = new \ReflectionClass($this->currentTestClassName);
         $file = $testClass->getFileName();
         $line = 1;
     } elseif ($test instanceof \PHPUnit_Framework_WarningTestCase && preg_match('/^No tests found in class "([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)"\\.$/', $test->getMessage(), $matches)) {
         $testClass = new \ReflectionClass($this->currentTestClassName);
         $file = $testClass->getFileName();
         $line = 1;
     } else {
         list($file, $line) = FailureTrace::findFileAndLineOfFailureOrError($this->testTargetRepository->getRequiredSuperTypes(), $e, new \ReflectionClass($test));
     }
     $trace = \PHPUnit_Util_Filter::getFilteredStacktrace($e, true);
     $this->junitXMLWriter->{'write' . $failureOrError}($message . $trace, get_class($e), $file, $line, $message);
     if ($testIsArtificial) {
         $this->endTest($test, 0);
     }
 }
Пример #20
0
    /**
     * @covers PHPUnit_Framework_Constraint_Exception
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
     */
    public function testConstraintException()
    {
        $constraint = new PHPUnit_Framework_Constraint_Exception('FoobarException');
        $exception = new DummyException('Test');
        $stackTrace = PHPUnit_Util_Filter::getFilteredStacktrace($exception);
        try {
            $constraint->evaluate($exception);
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
            $this->assertEquals(<<<EOF
Failed asserting that exception of type "DummyException" matches expected exception "FoobarException". Message was: "Test" at
{$stackTrace}.

EOF
, PHPUnit_Framework_TestFailure::exceptionToString($e));
            return;
        }
        $this->fail();
    }
Пример #21
0
    public function printException(\Exception $e)
    {

        static $limit = 10;
        $this->message("[%s] %s")->with(get_class($e), $e->getMessage())->block('error')->writeln(
            $e instanceof \PHPUnit_Framework_AssertionFailedError
                ? OutputInterface::VERBOSITY_DEBUG
                : OutputInterface::VERBOSITY_VERBOSE
        );

        if ($this->rawStackTrace) {
            $this->message($e->getTraceAsString())->writeln();
            return;
        }
        
        $trace = \PHPUnit_Util_Filter::getFilteredStacktrace($e, false);

        $i = 0;
        foreach ($trace as $step) {
            $i++;

            $message = $this->message($i)->prepend('#')->width(4);
            $message->append($step['file'] . ':' . $step['line']);
            $message->writeln();

            if ($i >= $limit) {
                break;
            }
        }

        $prev = $e->getPrevious();
        if ($prev) {
            $this->printException($prev);
        }
    }
Пример #22
0
 /**
  * @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));
     }
 }
Пример #23
0
 /**
  * Skipped test.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  Exception              $e
  * @param  float                  $time
  * @access public
  * @since  Method available since Release 3.0.0
  */
 public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
 {
     $error = $this->document->createElement('error', PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE));
     $error->setAttribute('message', 'Skipped Test');
     $error->setAttribute('type', get_class($e));
     $this->currentTestCase->appendChild($error);
     $this->testSuiteErrors[$this->testSuiteLevel]++;
 }
Пример #24
0
 /**
  * @param Exception $e
  *
  * @return string
  */
 private static function getDetails(Exception $e)
 {
     $stackTrace = PHPUnit_Util_Filter::getFilteredStacktrace($e);
     $previous = $e->getPrevious();
     while ($previous) {
         $stackTrace .= "\nCaused by\n" . PHPUnit_Framework_TestFailure::exceptionToString($previous) . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($previous);
         $previous = $previous->getPrevious();
     }
     return ' ' . str_replace("\n", "\n ", $stackTrace);
 }
Пример #25
0
 /**
  * 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->writeCase('fail', $time, PHPUnit_Util_Filter::getFilteredStacktrace($e, TRUE, FALSE), $e->getMessage());
     $this->currentTestPass = FALSE;
 }
Пример #26
0
 /**
  * Skipped test.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  Exception              $e
  * @param  float                  $time
  * @since  Method available since Release 3.0.0
  */
 public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
 {
     if ($this->logIncompleteSkipped) {
         $error = $this->document->createElement('error');
         $error->setAttribute('type', get_class($e));
         $error->appendChild($this->document->createCDATASection(PHPUnit_Util_XML::convertToUtf8("Skipped Test\n" . PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE))));
         $this->currentTestCase->appendChild($error);
         $this->testSuiteErrors[$this->testSuiteLevel]++;
     } else {
         $this->attachCurrentTestCase = FALSE;
     }
 }
Пример #27
0
 public function printExceptionTrace(\Exception $e)
 {
     static $limit = 10;
     if ($e instanceof \PHPUnit_Framework_SkippedTestError or $e instanceof \PHPUnit_Framework_IncompleteTestError) {
         return;
     }
     if ($this->rawStackTrace) {
         $this->message(\PHPUnit_Util_Filter::getFilteredStacktrace($e, true, false))->writeln();
         return;
     }
     $trace = \PHPUnit_Util_Filter::getFilteredStacktrace($e, false);
     $i = 0;
     foreach ($trace as $step) {
         if ($i >= $limit) {
             break;
         }
         $i++;
         $message = $this->message($i)->prepend('#')->width(4);
         if (!isset($step['file'])) {
             foreach (['class', 'type', 'function'] as $info) {
                 if (!isset($step[$info])) {
                     continue;
                 }
                 $message->append($step[$info]);
             }
             $message->writeln();
             continue;
         }
         $message->append($step['file'] . ':' . $step['line']);
         $message->writeln();
     }
     $prev = $e->getPrevious();
     if ($prev) {
         $this->printExceptionTrace($prev);
     }
 }
Пример #28
0
 /**
  * @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();
     }
 }
Пример #29
0
 /**
  * @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));
 }
Пример #30
0
</div>
  <div class="desc"><span class="assertions">Assertions: <b><?php 
echo (int) $test['assertions'];
?>
</b>,</span><span class="problems">Problems: <b><?php 
echo count($test['deprecated']) + count($test['errors']);
?>
</b>,</span><span class="time">Executed in <?php 
printf('%06f', $test['time']);
?>
 seconds.</span></div>
  
  <div class="expand-button"></div>
  <div class="more">
    <div class="result"><pre><?php 
echo isset($test['result']['e']) ? htmlentities(PHPUnit_Framework_TestFailure::exceptionToString($test['result']['e']) . PHPUnit_Util_Filter::getFilteredStacktrace($test['result']['e'], FALSE)) : '';
?>
</pre></div>
    <?php 
if ($test['errors'] !== null) {
    foreach ($test['errors'] as $error) {
        $e = $error['e'];
        include 'exception.php';
    }
}
?>
    <?php 
if ($test['deprecated'] !== null) {
    foreach ($test['deprecated'] as $deprecated) {
        include 'deprecated.php';
    }