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


PHP PHPUnit_Framework_TestCase::getTestResultObject方法代码示例

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


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

示例1: assertFile

 /**
  * Validate code examples in $file
  *
  * @param  \SplFileObject $file
  * @param  string         $formatIdentifier
  * @return void
  */
 public function assertFile(\SplFileObject $file, $formatIdentifier = '')
 {
     $format = $this->formatFactory->createFormat($formatIdentifier ?: $file->getExtension());
     $result = $this->testCase->getTestResultObject();
     foreach ($this->tester->test($file, $format) as $example => $returnObj) {
         $this->testCase->addToAssertionCount(1);
         if ($returnObj->isFailure()) {
             $result->addFailure($this->testCase, new \PHPUnit_Framework_AssertionFailedError("Example {$example}: {$returnObj->getMessage()}"), 0.0);
         }
     }
 }
开发者ID:hanneskod,项目名称:readme-tester,代码行数:18,代码来源:AssertReadme.php

示例2: log

 /**
  * This is the publically accessible API for notifying the system that a
  * deprecated feature has been used.
  *
  * If it is run via a TestRunner and the test extends
  * PHPUnit_Framework_TestCase, then this will inject the result into the
  * test runner for display, if not, it will throw the notice to STDERR.
  *
  * @param string $message
  * @param int|bool $backtraceDepth
  */
 public static function log($message, $backtraceDepth = 2)
 {
     if ($backtraceDepth !== FALSE) {
         $trace = debug_backtrace(FALSE);
         if (is_int($backtraceDepth)) {
             $traceItem = $trace[$backtraceDepth];
         }
         if (!isset($traceItem['file'])) {
             $reflectionClass = new ReflectionClass($traceItem['class']);
             $traceItem['file'] = $reflectionClass->getFileName();
         }
         if (!isset($traceItem['line']) && isset($traceItem['class']) && isset($traceItem['function'])) {
             if (!isset($reflectionClass)) {
                 $reflectionClass = new ReflectionClass($traceItem['class']);
             }
             $method = $reflectionClass->getMethod($traceItem['function']);
             $traceItem['line'] = '(between ' . $method->getStartLine() . ' and ' . $method->getEndLine() . ')';
         }
     }
     $deprecatedFeature = new PHPUnit_Util_DeprecatedFeature($message, $traceItem);
     if (self::$currentTest instanceof PHPUnit_Framework_TestCase) {
         $result = self::$currentTest->getTestResultObject();
         $result->addDeprecatedFeature($deprecatedFeature);
     } else {
         file_put_contents('php://stderr', $deprecatedFeature);
     }
 }
开发者ID:DieguinhoHR,项目名称:kratos_store,代码行数:38,代码来源:Logger.php

示例3: checkValidCoversForTest

 /**
  * Check an individual test run for valid @covers annotation.
  *
  * This method is called from $this::endTest().
  *
  * @param \PHPUnit_Framework_TestCase $test
  *   The test to examine.
  */
 public function checkValidCoversForTest(\PHPUnit_Framework_TestCase $test)
 {
     // If we're generating a coverage report already, don't do anything here.
     if ($test->getTestResultObject() && $test->getTestResultObject()->getCollectCodeCoverageInformation()) {
         return;
     }
     // Gather our annotations.
     $annotations = $test->getAnnotations();
     // Glean the @coversDefaultClass annotation.
     $default_class = '';
     $valid_default_class = FALSE;
     if (isset($annotations['class']['coversDefaultClass'])) {
         if (count($annotations['class']['coversDefaultClass']) > 1) {
             $this->fail($test, '@coversDefaultClass has too many values');
         }
         // Grab the first one.
         $default_class = reset($annotations['class']['coversDefaultClass']);
         // Check whether the default class exists.
         $valid_default_class = $this->classExists($default_class);
         if (!$valid_default_class) {
             $this->fail($test, "@coversDefaultClass does not exist '{$default_class}'");
         }
     }
     // Glean @covers annotation.
     if (isset($annotations['method']['covers'])) {
         // Drupal allows multiple @covers per test method, so we have to check
         // them all.
         foreach ($annotations['method']['covers'] as $covers) {
             // Ensure the annotation isn't empty.
             if (trim($covers) === '') {
                 $this->fail($test, '@covers should not be empty');
                 // If @covers is empty, we can't proceed.
                 return;
             }
             // Ensure we don't have ().
             if (strpos($covers, '()') !== FALSE) {
                 $this->fail($test, "@covers invalid syntax: Do not use '()'");
             }
             // Glean the class and method from @covers.
             $class = $covers;
             $method = '';
             if (strpos($covers, '::') !== FALSE) {
                 list($class, $method) = explode('::', $covers);
             }
             // Check for the existence of the class if it's specified by @covers.
             if (!empty($class)) {
                 // If the class doesn't exist we have either a bad classname or
                 // are missing the :: for a method. Either way we can't proceed.
                 if (!$this->classExists($class)) {
                     if (empty($method)) {
                         $this->fail($test, "@covers invalid syntax: Needs '::' or class does not exist in {$covers}");
                         return;
                     } else {
                         $this->fail($test, '@covers class does not exist ' . $class);
                         return;
                     }
                 }
             } else {
                 // The class isn't specified and we have the ::, so therefore this
                 // test either covers a function, or relies on a default class.
                 if (empty($default_class)) {
                     // If there's no default class, then we need to check if the global
                     // function exists. Since this listener should always be listening
                     // for endTest(), the function should have already been loaded from
                     // its .module or .inc file.
                     if (!function_exists($method)) {
                         $this->fail($test, '@covers global method does not exist ' . $method);
                     }
                 } else {
                     // We have a default class and this annotation doesn't act like a
                     // global function, so we should use the default class if it's
                     // valid.
                     if ($valid_default_class) {
                         $class = $default_class;
                     }
                 }
             }
             // Finally, after all that, let's see if the method exists.
             if (!empty($class) && !empty($method)) {
                 $ref_class = new \ReflectionClass($class);
                 if (!$ref_class->hasMethod($method)) {
                     $this->fail($test, '@covers method does not exist ' . $class . '::' . $method);
                 }
             }
         }
     }
 }
开发者ID:dev981,项目名称:gaptest,代码行数:95,代码来源:DrupalStandardsListener.php


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