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


PHP Exception::getComparisonFailure方法代码示例

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


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

示例1: exceptionToString

 /**
  * Returns a description for an exception.
  *
  * @param  Exception $e
  * @return string
  * @since  Method available since Release 3.2.0
  */
 public static function exceptionToString(Exception $e)
 {
     if ($e instanceof PHPUnit_Framework_SelfDescribing) {
         $buffer = $e->toString();
         if ($e instanceof PHPUnit_Framework_ExpectationFailedException && $e->getComparisonFailure()) {
             $buffer = $buffer . $e->getComparisonFailure()->getDiff();
         }
         if (!empty($buffer)) {
             $buffer = trim($buffer) . "\n";
         }
     } elseif ($e instanceof PHPUnit_Framework_Error) {
         $buffer = $e->getMessage() . "\n";
     } elseif ($e instanceof PHPUnit_Framework_ExceptionWrapper) {
         $buffer = $e->getClassname() . ': ' . $e->getMessage() . "\n";
     } else {
         $buffer = get_class($e) . ': ' . $e->getMessage() . "\n";
     }
     return $buffer;
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:26,代码来源:TestFailure.php

示例2: composeMessage

 /**
  * @param string                 $message
  * @param PHPUnit_Framework_Test $test
  * @param Exception              $e
  *
  * @return string
  */
 protected function composeMessage($message, PHPUnit_Framework_Test $test, Exception $e)
 {
     $message = "Test {$message} (" . $test->getName() . " in class " . get_class($test) . "): " . $e->getMessage();
     if ($e instanceof PHPUnit_Framework_ExpectationFailedException && $e->getComparisonFailure()) {
         $message .= "\n" . $e->getComparisonFailure()->getDiff();
     }
     return $message;
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:15,代码来源:PHPUnitTestRunner.php

示例3: onNotSuccessfulTest

 /**
  * This method is called when a test method did not execute successfully.
  *
  * @param Exception $e
  */
 protected function onNotSuccessfulTest(Exception $e)
 {
     if (!$this->serverRunning) {
         throw $e;
     }
     try {
         $this->restoreSessionStateAfterFailedTest();
         $buffer = '';
         if ($this->captureScreenshotOnFailure) {
             $buffer .= 'Current URL: ' . $this->drivers[0]->getLocation() . "\n";
             $screenshotInfo = $this->takeScreenshot();
             if ($screenshotInfo != '') {
                 $buffer .= $screenshotInfo;
             }
         }
         $this->stopSession();
     } catch (Exception $another) {
         $buffer = "Issues while capturing the screenshot:\n" . $another->getMessage();
     }
     if ($e instanceof PHPUnit_Framework_ExpectationFailedException && is_object($e->getComparisonFailure())) {
         $message = $e->getComparisonFailure()->toString();
     } else {
         $message = $e->getMessage();
     }
     $buffer .= "\n" . $message;
     // gain the screenshot path, lose the stack trace
     if ($this->captureScreenshotOnFailure) {
         throw new PHPUnit_Framework_Error($buffer, $e->getCode(), $e->getFile(), $e->getLine(), $e);
     }
     // yes to stack trace and everything
     if ($e instanceof PHPUnit_Framework_IncompleteTestError || $e instanceof PHPUnit_Framework_SkippedTestError || $e instanceof PHPUnit_Framework_AssertionFailedError) {
         throw $e;
     }
     // yes to stack trace, only for F tests
     // PHPUnit issue 471 prevents getTrace() from being useful
     throw new PHPUnit_Framework_Error($buffer, $e->getCode(), $e->getFile(), $e->getLine(), $e);
 }
开发者ID:roquebrasilia,项目名称:sgdoc-codigo,代码行数:42,代码来源:SeleniumTestCase.php

示例4: exceptionToString

 /**
  * Returns a description for an exception.
  *
  * @param  Exception $e
  * @return string
  * @since  Method available since Release 3.2.0
  */
 public static function exceptionToString(Exception $e)
 {
     if ($e instanceof PHPUnit_Framework_SelfDescribing) {
         if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
             $comparisonFailure = $e->getComparisonFailure();
             $description = $e->getDescription();
             $message = $e->getCustomMessage();
             if ($message == '') {
                 $buffer = '';
             } else {
                 $buffer = $message . "\n";
             }
             if ($comparisonFailure !== NULL) {
                 if ($comparisonFailure->identical()) {
                     if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Object) {
                         $buffer .= 'Failed asserting that two variables ' . "reference the same object.\n";
                     } else {
                         $buffer .= $comparisonFailure->toString() . "\n";
                     }
                 } else {
                     if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Scalar) {
                         $buffer .= sprintf("Failed asserting that %s matches expected %s.\n", PHPUnit_Util_Type::toString($comparisonFailure->getActual()), PHPUnit_Util_Type::toString($comparisonFailure->getExpected()));
                     } else {
                         if ($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());
                         }
                     }
                 }
             } else {
                 $buffer .= $e->toString();
                 if (!empty($buffer)) {
                     $buffer .= "\n";
                 }
                 if (strpos($buffer, $description) === FALSE) {
                     $buffer .= $description . "\n";
                 }
             }
         } else {
             $buffer = $e->toString();
             if (!empty($buffer)) {
                 $buffer .= "\n";
             }
         }
     } else {
         if ($e instanceof PHPUnit_Framework_Error) {
             $buffer = $e->getMessage() . "\n";
         } else {
             $buffer = get_class($e) . ': ' . $e->getMessage() . "\n";
         }
     }
     return $buffer;
 }
开发者ID:rmehner,项目名称:phpunit,代码行数:59,代码来源:TestFailure.php

示例5: onNotSuccessfulTest

 /**
  * This method is called when a test method did not execute successfully.
  *
  * @param Exception $e
  */
 protected function onNotSuccessfulTest(Exception $e)
 {
     if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
         $buffer = 'Current URL: ' . $this->drivers[0]->getLocation() . "\n";
         if ($this->captureScreenshotOnFailure && !empty($this->screenshotPath) && !empty($this->screenshotUrl)) {
             $filename = $this->getScreenshotPath() . $this->testId . '.png';
             $this->drivers[0]->captureEntirePageScreenshot($filename);
             $buffer .= 'Screenshot: ' . $this->screenshotUrl . '/' . $this->testId . ".png\n";
         }
     }
     $this->stopSession();
     self::$sessionId = NULL;
     if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
         if (is_object($e->getComparisonFailure())) {
             $message = $e->getComparisonFailure()->toString();
         } else {
             $message = $e->getMessage();
         }
         $buffer .= "\n" . $message;
         throw new PHPUnit_Framework_ExpectationFailedException($buffer);
     }
     throw $e;
 }
开发者ID:nbalonso,项目名称:MunkiFace,代码行数:28,代码来源:SeleniumTestCase.php


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