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


PHP PHPUnit_Framework_TestFailure::exceptionToString方法代码示例

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


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

示例1: 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

示例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;
 }
开发者ID:ronaldbao,项目名称:phpunit,代码行数:11,代码来源:Exception.php

示例3: 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

示例4: 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

示例5: testInvalidMediaType

    public function testInvalidMediaType()
    {
        $mediaType = 'application/pdf';
        self::assertFalse($this->constraint->evaluate($mediaType, '', true));
        try {
            $this->constraint->evaluate($mediaType);
            self::fail('Expected ExpectationFailedException to be thrown');
        } catch (ExpectationFailedException $e) {
            self::assertEquals(<<<EOF
Failed asserting that 'application/pdf' is an allowed media type (application/json, application/xml, text/xml, text/html).

EOF
, TestFailure::exceptionToString($e));
        }
    }
开发者ID:Beanhunter,项目名称:SwaggerAssertions,代码行数:15,代码来源:ResponseMediaTypeConstraintTest.php

示例6: 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

示例7: testInvalidHeaderType

    public function testInvalidHeaderType()
    {
        $headers = ['Content-Type' => 'application/json'];
        self::assertFalse($this->constraint->evaluate($headers, '', true));
        try {
            $this->constraint->evaluate($headers);
            self::fail('Expected ExpectationFailedException to be thrown');
        } catch (ExpectationFailedException $e) {
            self::assertEquals(<<<EOF
Failed asserting that {"Content-Type":"application\\/json"} is valid.
[etag] The property etag is required

EOF
, TestFailure::exceptionToString($e));
        }
    }
开发者ID:Beanhunter,项目名称:SwaggerAssertions,代码行数:16,代码来源:ResponseHeadersConstraintTest.php

示例8: __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

示例9: 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

示例10: testInvalidSchema

    public function testInvalidSchema()
    {
        $response = <<<JSON
[
  {
    "id": 123456789
  }
]
JSON;
        $response = json_decode($response);
        self::assertFalse($this->constraint->evaluate($response, '', true));
        try {
            $this->constraint->evaluate($response);
            self::fail('Expected ExpectationFailedException to be thrown');
        } catch (ExpectationFailedException $e) {
            self::assertEquals(<<<EOF
Failed asserting that [{"id":123456789}] is valid.
[name] The property name is required

EOF
, TestFailure::exceptionToString($e));
        }
    }
开发者ID:Beanhunter,项目名称:SwaggerAssertions,代码行数:23,代码来源:ResponseBodyConstraintTest.php

示例11: 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);
 }
开发者ID:ronaldbao,项目名称:phpunit,代码行数:23,代码来源:JUnit.php

示例12: printScenarioFail

 protected function printScenarioFail(ScenarioDriven $failedTest, $fail)
 {
     $feature = $failedTest->getFeature();
     $failToString = \PHPUnit_Framework_TestFailure::exceptionToString($fail);
     $failMessage = $this->message($failedTest->getSignature())->style('bold')->append(' (')->append(codecept_relative_path($failedTest->getFileName()))->append(')');
     if ($fail instanceof \PHPUnit_Framework_SkippedTest || $fail instanceof \PHPUnit_Framework_IncompleteTest) {
         $this->printSkippedTest($feature, $failedTest->getFileName(), $failToString);
         return;
     }
     if ($feature) {
         $failMessage->prepend("Failed to {$feature} in ");
     }
     $failMessage->writeln();
     $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:vladislavl-hyuna,项目名称:crmapp,代码行数:31,代码来源:Console.php

示例13: 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)
 {
     if ($this->currentTestCase !== null) {
         if (!$test instanceof PHPUnit_Framework_Warning) {
             if ($test instanceof PHPUnit_Framework_SelfDescribing) {
                 $buffer = $test->toString() . "\n";
             } else {
                 $buffer = '';
             }
             $buffer .= PHPUnit_Framework_TestFailure::exceptionToString($e) . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($e);
             $failure = $this->document->createElement('failure', PHPUnit_Util_XML::prepareString($buffer));
             $failure->setAttribute('type', get_class($e));
             $this->currentTestCase->appendChild($failure);
             $this->testSuiteFailures[$this->testSuiteLevel]++;
         }
     }
 }
开发者ID:ppwalks33,项目名称:cleansure,代码行数:24,代码来源:JUnit.php

示例14: verify

 /**
  * @throws PHPUnit_Framework_Exception
  * @throws PHPUnit_Framework_ExpectationFailedException
  */
 public function verify()
 {
     if ($this->invocationMatcher === null) {
         throw new PHPUnit_Framework_Exception('No invocation matcher is set');
     }
     if ($this->methodNameMatcher === null) {
         throw new PHPUnit_Framework_Exception('No method matcher is set');
     }
     try {
         $this->invocationMatcher->verify();
         if ($this->parametersMatcher === null) {
             $this->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_AnyParameters();
         }
         $invocationIsAny = get_class($this->invocationMatcher) === 'PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount';
         $invocationIsNever = get_class($this->invocationMatcher) === 'PHPUnit_Framework_MockObject_Matcher_InvokedCount' && $this->invocationMatcher->isNever();
         if (!$invocationIsAny && !$invocationIsNever) {
             $this->parametersMatcher->verify();
         }
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         throw new PHPUnit_Framework_ExpectationFailedException(sprintf("Expectation failed for %s when %s.\n%s", $this->methodNameMatcher->toString(), $this->invocationMatcher->toString(), PHPUnit_Framework_TestFailure::exceptionToString($e)));
     }
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:26,代码来源:Matcher.php

示例15: printFail

 public function printFail(\Codeception\Event\Fail $e)
 {
     $failedTest = $e->getTest();
     $fail = $e->getFail();
     if ($fail instanceof \PHPUnit_Framework_SelfDescribing) {
         $failToString = \PHPUnit_Framework_TestFailure::exceptionToString($fail);
     } else {
         $failToString = sprintf("[%s]\n%s", get_class($fail), $fail->getMessage());
     }
     $feature = $failedTest->getScenario()->getFeature();
     if ($e->getCount()) {
         $this->output->put($e->getCount() . ") ");
     }
     // skip test
     // Sample Message: create user in CreateUserCept.php is not ready for release
     if ($fail instanceof \PHPUnit_Framework_SkippedTest or $fail instanceof \PHPUnit_Framework_IncompleteTest) {
         if ($feature) {
             $this->output->put("[[{$feature}]] in ");
         }
         $this->output->put($failedTest->getFilename());
         if ($failToString) {
             $this->output->put(" is " . $failToString);
         }
         $this->output->writeln("\n");
         return;
     }
     if ($feature) {
         $this->output->put("Couldn't [[{$feature}]] in ");
     }
     $this->output->writeln('((' . $failedTest->getFilename() . '))');
     $trace = array_reverse($failedTest->getTrace());
     $length = $i = count($trace);
     $last = array_shift($trace);
     if (!method_exists($last, 'getHumanizedAction')) {
         $this->printException($fail);
         return;
     }
     $action = $last->getHumanizedAction();
     if (strpos($action, "am") === 0) {
         $action = 'become' . substr($action, 2);
     }
     // it's exception
     if (!$fail instanceof \PHPUnit_Framework_AssertionFailedError) {
         $this->printException($fail);
         return;
     }
     // it's assertion
     if (strpos($action, "don't") === 0) {
         $action = substr($action, 6);
         $this->output->writeln("Guy unexpectedly managed to {$action}:\n{$failToString}");
     } else {
         $this->output->writeln("Guy couldn't {$action}: {$failToString}");
     }
     $this->output->writeln("Scenario Steps:");
     $this->output->writeln("{$i}. (!{$last}!)");
     foreach ($trace as $step) {
         $i--;
         $this->output->writeln("{$i}. " . $step);
         if ($length - $i - 1 >= $this->traceLength) {
             break;
         }
     }
     if ($this->debug) {
         $this->printException($fail);
     }
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:66,代码来源:Console.php


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