当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Framework_TestFailure类代码示例

本文整理汇总了PHP中PHPUnit_Framework_TestFailure的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestFailure类的具体用法?PHP PHPUnit_Framework_TestFailure怎么用?PHP PHPUnit_Framework_TestFailure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PHPUnit_Framework_TestFailure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testToString

 /**
  * @covers PHPUnit_Framework_TestFailure::toString
  */
 public function testToString()
 {
     $test = new self(__FUNCTION__);
     $exception = new PHPUnit_Framework_Exception('message');
     $failure = new PHPUnit_Framework_TestFailure($test, $exception);
     $this->assertEquals(__METHOD__ . ': message', $failure->toString());
 }
开发者ID:ppwalks33,项目名称:cleansure,代码行数:10,代码来源:TestFailureTest.php

示例2: printDefect

 protected function printDefect(\PHPUnit_Framework_TestFailure $defect, $count)
 {
     $failedTest = $defect->failedTest();
     if (!$failedTest instanceof \Codeception\TestCase) {
         return parent::printDefect($defect, $count);
     }
     $this->dispatcher->dispatch('fail.print', new \Codeception\Event\Fail($defect->failedTest(), $defect->thrownException()));
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:8,代码来源:UI.php

示例3: 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());
     }
 }
开发者ID:atk4,项目名称:core,代码行数:12,代码来源:PHPUnit_AgileResultPrinter.php

示例4: 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();
     }
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:16,代码来源:UI.php

示例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();
     }
 }
开发者ID:diablomedia,项目名称:phpunit-pretty-printer,代码行数:13,代码来源:PrettyPrinter.php

示例6: addFailure

 public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
 {
     $class = get_class($test);
     $message = $this->escape(PHPUnit_Framework_TestFailure::exceptionToString($e));
     $trace = $this->escape($e->getTraceAsString());
     echo "##teamcity[testFailed type='failure' name='{$class}.{$test->getName()}' message='{$message}'" . " details='{$trace}']\n";
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:7,代码来源:TeamCityListener.php

示例7: __toString

 /**
  * @return string
  */
 public function __toString()
 {
     $string = PHPUnit_Framework_TestFailure::exceptionToString($this);
     if ($trace = PHPUnit_Util_Filter::getFilteredStacktrace($this)) {
         $string .= "\n" . $trace;
     }
     return $string;
 }
开发者ID:ronaldbao,项目名称:phpunit,代码行数:11,代码来源:Exception.php

示例8: _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;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:38,代码来源:TestResult.php

示例9: 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->writeNotOk($test, 'Failure');
     $message = explode("\n", PHPUnit_Framework_TestFailure::exceptionToString($e));
     $diagnostic = array('message' => $message[0], 'severity' => 'fail');
     if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
         $cf = $e->getComparisonFailure();
         if ($cf !== null) {
             $diagnostic['data'] = array('got' => $cf->getActual(), 'expected' => $cf->getExpected());
         }
     }
     $yaml = new Symfony\Component\Yaml\Dumper();
     $this->write(sprintf("  ---\n%s  ...\n", $yaml->dump($diagnostic, 2, 2)));
 }
开发者ID:Zarbisi,项目名称:todo,代码行数:21,代码来源:TAP.php

示例10: assertFailOrPassWith

 /**
  * @Then /^It should (fail|pass) with:$/
  */
 public function assertFailOrPassWith($success, PyStringNode $data)
 {
     if ('fail' === $success) {
         assertNotEquals(0, $this->return);
     } else {
         assertEquals(0, $this->return);
     }
     $realData = preg_replace('/\\# \\/.*BehatBundle\\//', '# ', (string) $this->output);
     try {
         assertEquals((string) $data, $realData);
     } catch (\Exception $e) {
         $diff = \PHPUnit_Framework_TestFailure::exceptionToString($e);
         throw new \Exception($diff, $e->getCode(), $e);
     }
 }
开发者ID:derek-cr,项目名称:BehatBundle,代码行数:18,代码来源:FeatureContext.php

示例11: __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;
 }
开发者ID:Tekill,项目名称:facebook-php-ads-sdk,代码行数:19,代码来源:PHPUnitRequestExceptionWrapper.php

示例12: 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;
 }
开发者ID:aoemedia,项目名称:menta,代码行数:48,代码来源:HtmlResultView.php

示例13: 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;
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:20,代码来源:PHP.php

示例14: testConstraintException

    /**
     * @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 = $exception->getTraceAsString();
        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();
    }
开发者ID:ProgrammingPeter,项目名称:nba-schedule-api,代码行数:22,代码来源:ConstraintTest.php

示例15: printScenarioFail

 protected function printScenarioFail(ScenarioDriven $failedTest, $fail)
 {
     $failToString = \PHPUnit_Framework_TestFailure::exceptionToString($fail);
     $failedStep = "";
     foreach ($failedTest->getScenario()->getSteps() as $step) {
         if ($step->hasFailed()) {
             $failedStep = (string) $step;
             break;
         }
     }
     $this->printException($fail, $failedStep);
     $this->printScenarioTrace($failedTest, $failToString);
     if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_DEBUG) {
         $this->printExceptionTrace($fail);
         return;
     }
     if (!$fail instanceof \PHPUnit_Framework_AssertionFailedError) {
         $this->printExceptionTrace($fail);
         return;
     }
 }
开发者ID:janhenkgerritsen,项目名称:Codeception,代码行数:21,代码来源:Console.php


注:本文中的PHPUnit_Framework_TestFailure类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。