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


PHP PHPUnit_Framework_TestResult::getCodeCoverage方法代码示例

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


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

示例1: endTestRun

 public function endTestRun()
 {
     $coverage = $this->result->getCodeCoverage();
     if (!empty($coverage)) {
         $clover = new PHP_CodeCoverage_Report_Clover();
         $contents = $clover->process($coverage);
         if ($this->out) {
             $this->out->write($contents);
             $this->out->close();
         }
     }
     parent::endTestRun();
 }
开发者ID:Ingewikkeld,项目名称:phing,代码行数:13,代码来源:CloverPHPUnitResultFormatter.php

示例2: paintFooter

 /**
  * Renders the summary of test passes and failures.
  *
  * @param PHPUnit_Framework_TestResult $result Result object
  *
  * @return void
  */
 public function paintFooter($result)
 {
     ob_end_flush();
     echo '</ul>';
     if ($result->failureCount() + $result->errorCount() > 0) {
         echo '<div class="alert-box alert radius">';
     } else {
         echo '<div class="alert-box success radius">';
     }
     echo $result->count() - $result->skippedCount() . ' of ';
     echo $result->count() . ' test methods complete: ';
     echo count($result->passed()) . ' passes, ';
     echo $result->failureCount() . ' fails, ';
     echo $this->numAssertions . ' assertions and ';
     echo $result->errorCount() . ' exceptions.';
     echo '</div>';
     echo '<p><strong>Time:</strong> ' . __('%0.5f seconds', $result->time()) . '</p>';
     echo '<p><strong>Peak Memory:</strong> ' . number_format(memory_get_peak_usage()) . ' bytes</p>';
     $this->_paintLinks();
     if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
         $coverage = $result->getCodeCoverage();
         if (method_exists($coverage, 'getSummary')) {
             $report = $coverage->getSummary();
             $this->paintCoverage($report);
         }
         if (method_exists($coverage, 'getData')) {
             $report = $coverage->getData();
             $this->paintCoverage($report);
         }
     }
     $this->paintDocumentEnd();
 }
开发者ID:hasannawaz,项目名称:pluginmirror,代码行数:39,代码来源:HtmlReporter.php

示例3: endTestRun

 public function endTestRun()
 {
     $coverage = $this->result->getCodeCoverage();
     if (!empty($coverage)) {
         if (class_exists('PHP_CodeCoverage_Report_Crap4j')) {
             $crap = new PHP_CodeCoverage_Report_Crap4j();
         } elseif (class_exists('\\SebastianBergmann\\CodeCoverage\\Report\\Crap4j')) {
             $crapClass = '\\SebastianBergmann\\CodeCoverage\\Report\\Crap4j';
             $crap = new $crapClass();
         }
         $contents = $crap->process($coverage);
         if ($this->out) {
             $this->out->write($contents);
             $this->out->close();
         }
     }
     parent::endTestRun();
 }
开发者ID:Geeklog-Japan,项目名称:geeklog-japan,代码行数:18,代码来源:Crap4jPHPUnitResultFormatter.php

示例4: processChildResult

 /**
  * Makes the processChildResult inherited method public.
  *
  * @param \PHPUnit_Framework_Test $test
  * @param \PHPUnit_Framework_TestResult $result
  * @param string $stdout
  * @param string $stderr
  * @return void
  */
 public function processChildResult(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_TestResult $result, $stdout, $stderr)
 {
     $time = 0;
     if (!empty($stderr)) {
         $result->addError($test, new \PHPUnit_Framework_Exception(trim($stderr)), $time);
     } else {
         set_error_handler(function ($errno, $errstr, $errfile, $errline) {
             throw new \ErrorException($errstr, $errno, $errno, $errfile, $errline);
         });
         try {
             if (strpos($stdout, "#!/usr/bin/env php\n") === 0) {
                 $stdout = substr($stdout, 19);
             }
             $childResult = unserialize(str_replace("#!/usr/bin/env php\n", '', $stdout));
             restore_error_handler();
         } catch (\ErrorException $e) {
             restore_error_handler();
             $childResult = false;
             $result->addError($test, new \PHPUnit_Framework_Exception(trim($stdout), 0, $e), $time);
         }
         if ($childResult !== false) {
             if (!empty($childResult['output'])) {
                 print $childResult['output'];
             }
             $test->setResult($childResult['testResult']);
             $test->addToAssertionCount($childResult['numAssertions']);
             $childResult = $childResult['result'];
             if ($result->getCollectCodeCoverageInformation()) {
                 $result->getCodeCoverage()->merge($childResult->getCodeCoverage());
             }
             $time = $childResult->time();
             $notImplemented = $childResult->notImplemented();
             $risky = $childResult->risky();
             $skipped = $childResult->skipped();
             $errors = $childResult->errors();
             $failures = $childResult->failures();
             if (!empty($notImplemented)) {
                 $result->addError($test, $this->getException($notImplemented[0]), $time);
             } elseif (!empty($risky)) {
                 $result->addError($test, $this->getException($risky[0]), $time);
             } elseif (!empty($skipped)) {
                 $result->addError($test, $this->getException($skipped[0]), $time);
             } elseif (!empty($errors)) {
                 foreach ($errors as $error) {
                     $result->addError($test, $this->getException($error), $time);
                 }
             } elseif (!empty($failures)) {
                 foreach ($failures as $failure) {
                     $result->addFailure($test, $this->getException($failure), $time);
                 }
             }
         }
     }
     $result->endTest($test, $time);
 }
开发者ID:Mohitsahu123,项目名称:mtf,代码行数:64,代码来源:PHPUnitUtils.php

示例5: endTestRun

 public function endTestRun()
 {
     if (version_compare($this->version, '3.5.0') >= 0) {
         require_once 'PHP/CodeCoverage/Report/Clover.php';
         $coverage = $this->result->getCodeCoverage();
         $clover = new PHP_CodeCoverage_Report_Clover();
         $contents = $clover->process($coverage);
     } else {
         require_once 'PHPUnit/Util/Log/CodeCoverage/XML/Clover.php';
         $clover = new PHPUnit_Util_Log_CodeCoverage_XML_Clover(null);
         ob_start();
         $clover->process($this->result);
         $contents = ob_get_contents();
         ob_end_clean();
     }
     if ($this->out) {
         $this->out->write($contents);
         $this->out->close();
     }
     parent::endTestRun();
 }
开发者ID:hkilter,项目名称:OpenSupplyChains,代码行数:21,代码来源:CloverPHPUnitResultFormatter.php

示例6: paintFooter

 /**
  * Paints the end of the test with a summary of
  * the passes and failures.
  *
  * @param PHPUnit_Framework_TestResult $result Result object
  * @return void
  */
 public function paintFooter($result)
 {
     if ($result->failureCount() + $result->errorCount()) {
         echo "FAILURES!!!\n";
     } else {
         echo "\nOK\n";
     }
     echo "Test cases run: " . $result->count() . "/" . ($result->count() - $result->skippedCount()) . ', Passes: ' . $this->numAssertions . ', Failures: ' . $result->failureCount() . ', Exceptions: ' . $result->errorCount() . "\n";
     echo 'Time: ' . $result->time() . " seconds\n";
     echo 'Peak memory: ' . number_format(memory_get_peak_usage()) . " bytes\n";
     if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
         $coverage = $result->getCodeCoverage()->getSummary();
         echo $this->paintCoverage($coverage);
     }
 }
开发者ID:yuuicchan0912,项目名称:sample2,代码行数:22,代码来源:CakeTextReporter.php

示例7: run

 /**
  * Runs the tests and collects their result in a TestResult.
  *
  * @param  PHPUnit_Framework_TestResult $result
  * @param  mixed                        $filter
  * @param  array                        $groups
  * @param  array                        $excludeGroups
  * @param  boolean                      $processIsolation
  * @return PHPUnit_Framework_TestResult
  * @throws InvalidArgumentException
  */
 public function run(PHPUnit_Framework_TestResult $result = NULL, $filter = FALSE, array $groups = array(), array $excludeGroups = array(), $processIsolation = FALSE)
 {
     // Get the code coverage filter from the suite's result object
     $coverage = $result->getCodeCoverage();
     if ($coverage) {
         $coverage_filter = $coverage->filter();
         // Apply the white and blacklisting
         foreach ($this->_filter_calls as $method => $args) {
             foreach ($args as $arg) {
                 $coverage_filter->{$method}($arg);
             }
         }
     }
     return parent::run($result, $filter, $groups, $excludeGroups, $processIsolation);
 }
开发者ID:robert-kampas,项目名称:games-collection-manager,代码行数:26,代码来源:TestSuite.php

示例8: processChildResult

 /**
  * Processes the TestResult object from an isolated process.
  *
  * @param PHPUnit_Framework_TestCase   $test
  * @param PHPUnit_Framework_TestResult $result
  * @param string                       $stdout
  * @param string                       $stderr
  * @since Method available since Release 3.5.0
  */
 protected function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr)
 {
     if (!empty($stderr)) {
         $time = 0;
         $result->addError($test, new RuntimeException(trim($stderr)), $time);
     } else {
         $childResult = @unserialize($stdout);
         if ($childResult !== FALSE) {
             if (!empty($childResult['output'])) {
                 print $childResult['output'];
             }
             $test->setResult($childResult['testResult']);
             $test->addToAssertionCount($childResult['numAssertions']);
             $childResult = $childResult['result'];
             if ($result->getCollectCodeCoverageInformation()) {
                 $codeCoverageInformation = $childResult->getRawCodeCoverageInformation();
                 if (isset($codeCoverageInformation[0]) && is_array($codeCoverageInformation[0])) {
                     $result->getCodeCoverage()->append($codeCoverageInformation[0], $test);
                 }
             }
             $time = $childResult->time();
             $notImplemented = $childResult->notImplemented();
             $skipped = $childResult->skipped();
             $errors = $childResult->errors();
             $failures = $childResult->failures();
             if (!empty($notImplemented)) {
                 $result->addError($test, $notImplemented[0]->thrownException(), $time);
             } else {
                 if (!empty($skipped)) {
                     $result->addError($test, $skipped[0]->thrownException(), $time);
                 } else {
                     if (!empty($errors)) {
                         $result->addError($test, $errors[0]->thrownException(), $time);
                     } else {
                         if (!empty($failures)) {
                             $result->addFailure($test, $failures[0]->thrownException(), $time);
                         }
                     }
                 }
             }
         } else {
             $time = 0;
             $result->addError($test, new RuntimeException(trim($stdout)), $time);
         }
     }
     $result->endTest($test, $time);
 }
开发者ID:qcodo,项目名称:qcodo,代码行数:56,代码来源:PHP.php

示例9: run

 /**
  * Runs a test and collects its result in a TestResult instance.
  *
  * @param  PHPUnit_Framework_TestResult $result
  * @param  array                        $options
  * @return PHPUnit_Framework_TestResult
  */
 public function run(PHPUnit_Framework_TestResult $result = NULL, array $options = array())
 {
     if (!class_exists('PEAR_RunTest', FALSE)) {
         throw new PHPUnit_Framework_Exception('Class PEAR_RunTest not found.');
     }
     if (isset($GLOBALS['_PEAR_destructor_object_list']) && is_array($GLOBALS['_PEAR_destructor_object_list']) && !empty($GLOBALS['_PEAR_destructor_object_list'])) {
         $pearDestructorObjectListCount = count($GLOBALS['_PEAR_destructor_object_list']);
     } else {
         $pearDestructorObjectListCount = 0;
     }
     if ($result === NULL) {
         $result = new PHPUnit_Framework_TestResult();
     }
     $coverage = $result->getCollectCodeCoverageInformation();
     $options = array_merge($options, $this->options);
     if (!isset($options['include_path'])) {
         $options['include_path'] = get_include_path();
     }
     if ($coverage) {
         $options['coverage'] = TRUE;
     } else {
         $options['coverage'] = FALSE;
     }
     $currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE);
     $runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger(), $options);
     if ($coverage) {
         $runner->xdebug_loaded = TRUE;
     } else {
         $runner->xdebug_loaded = FALSE;
     }
     $result->startTest($this);
     PHP_Timer::start();
     $buffer = $runner->run($this->filename, $options);
     $time = PHP_Timer::stop();
     error_reporting($currentErrorReporting);
     $base = basename($this->filename);
     $path = dirname($this->filename);
     $coverageFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.xdebug', $base);
     $diffFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.diff', $base);
     $expFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.exp', $base);
     $logFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.log', $base);
     $outFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.out', $base);
     $phpFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.php', $base);
     if (is_object($buffer) && $buffer instanceof PEAR_Error) {
         $result->addError($this, new PHPUnit_Framework_Exception($buffer->getMessage()), $time);
     } else {
         if ($buffer == 'SKIPPED') {
             $result->addFailure($this, new PHPUnit_Framework_SkippedTestError(), 0);
         } else {
             if ($buffer != 'PASSED') {
                 $expContent = file_get_contents($expFile);
                 $outContent = file_get_contents($outFile);
                 $result->addFailure($this, new PHPUnit_Framework_ComparisonFailure($expContent, $outContent, $expContent, $outContent), $time);
             }
         }
     }
     foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) {
         if (file_exists($file)) {
             unlink($file);
         }
     }
     if ($coverage && file_exists($coverageFile)) {
         eval('$coverageData = ' . file_get_contents($coverageFile) . ';');
         unset($coverageData[$phpFile]);
         $result->getCodeCoverage()->append($coverageData, $this);
         unlink($coverageFile);
     }
     $result->endTest($this, $time);
     // Do not invoke PEAR's destructor mechanism for PHP 4
     // as it raises an E_STRICT.
     if ($pearDestructorObjectListCount == 0) {
         unset($GLOBALS['_PEAR_destructor_object_list']);
     } else {
         $count = count($GLOBALS['_PEAR_destructor_object_list']) - $pearDestructorObjectListCount;
         for ($i = 0; $i < $count; $i++) {
             array_pop($GLOBALS['_PEAR_destructor_object_list']);
         }
     }
     return $result;
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:87,代码来源:PhptTestCase.php

示例10: paintFooter

 /**
  * Paints the end of the test with a summary of
  * the passes and failures.
  *
  * @param PHPUnit_Framework_TestResult $result Result object
  * @return void
  */
 public function paintFooter($result)
 {
     if (ob_get_contents()) {
         ob_end_flush();
     }
     $colour = $result->failureCount() + $result->errorCount() > 0 ? "red" : "green";
     echo "</ul>\n";
     echo "<div style=\"";
     echo "padding: 8px; margin: 1em 0; background-color: {$colour}; color: white;";
     echo "\">";
     echo $result->count() - $result->skippedCount() . "/" . $result->count();
     echo " test methods complete:\n";
     echo "<strong>" . count($result->passed()) . "</strong> passes, ";
     echo "<strong>" . $result->failureCount() . "</strong> fails, ";
     echo "<strong>" . $this->numAssertions . "</strong> assertions and ";
     echo "<strong>" . $result->errorCount() . "</strong> exceptions.";
     echo "</div>\n";
     echo '<div style="padding:0 0 5px;">';
     echo '<p><strong>Time:</strong> ' . $result->time() . ' seconds</p>';
     echo '<p><strong>Peak memory:</strong> ' . number_format(memory_get_peak_usage()) . ' bytes</p>';
     echo $this->_paintLinks();
     echo '</div>';
     if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
         $coverage = $result->getCodeCoverage();
         if (method_exists($coverage, 'getSummary')) {
             $report = $coverage->getSummary();
             echo $this->paintCoverage($report);
         }
         if (method_exists($coverage, 'getData')) {
             $report = $coverage->getData();
             echo $this->paintCoverage($report);
         }
     }
     $this->paintDocumentEnd();
 }
开发者ID:coder-d,项目名称:payment_library,代码行数:42,代码来源:CakeHtmlReporter.php

示例11: processChildResult

 /**
  * Processes the TestResult object from an isolated process.
  *
  * @param PHPUnit_Framework_TestCase   $test
  * @param PHPUnit_Framework_TestResult $result
  * @param string                       $stdout
  * @param string                       $stderr
  * @since Method available since Release 3.5.0
  */
 protected function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr)
 {
     $time = 0;
     if (!empty($stderr)) {
         $result->addError($test, new PHPUnit_Framework_Exception(trim($stderr)), $time);
     } else {
         set_error_handler(function ($errno, $errstr, $errfile, $errline) {
             throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
         });
         try {
             $childResult = unserialize($stdout);
             restore_error_handler();
         } catch (ErrorException $e) {
             restore_error_handler();
             $childResult = FALSE;
             $result->addError($test, new PHPUnit_Framework_Exception(trim($stdout), 0, $e), $time);
         }
         if ($childResult !== FALSE) {
             if (!empty($childResult['output'])) {
                 print $childResult['output'];
             }
             $test->setResult($childResult['testResult']);
             $test->addToAssertionCount($childResult['numAssertions']);
             $childResult = $childResult['result'];
             if ($result->getCollectCodeCoverageInformation()) {
                 $result->getCodeCoverage()->merge($childResult->getCodeCoverage());
             }
             $time = $childResult->time();
             $notImplemented = $childResult->notImplemented();
             $skipped = $childResult->skipped();
             $errors = $childResult->errors();
             $failures = $childResult->failures();
             if (!empty($notImplemented)) {
                 $result->addError($test, $this->getException($notImplemented[0]), $time);
             } else {
                 if (!empty($skipped)) {
                     $result->addError($test, $this->getException($skipped[0]), $time);
                 } else {
                     if (!empty($errors)) {
                         $result->addError($test, $this->getException($errors[0]), $time);
                     } else {
                         if (!empty($failures)) {
                             $result->addFailure($test, $this->getException($failures[0]), $time);
                         }
                     }
                 }
             }
         }
     }
     $result->endTest($test, $time);
 }
开发者ID:samurailens,项目名称:sop,代码行数:60,代码来源:PHP.php


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