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


PHP PHP_CodeCoverage::getReport方法代码示例

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


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

示例1: process

 /**
  * @param PHP_CodeCoverage $coverage
  * @param string           $target
  */
 public function process(PHP_CodeCoverage $coverage, $target)
 {
     $target = $this->getDirectory($target);
     $report = $coverage->getReport();
     unset($coverage);
     if (!isset($_SERVER['REQUEST_TIME'])) {
         $_SERVER['REQUEST_TIME'] = time();
     }
     $date = date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']);
     $dashboard = new PHP_CodeCoverage_Report_HTML_Renderer_Dashboard($this->templatePath, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
     $directory = new PHP_CodeCoverage_Report_HTML_Renderer_Directory($this->templatePath, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
     $file = new PHP_CodeCoverage_Report_HTML_Renderer_File($this->templatePath, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
     $directory->render($report, $target . 'index.html');
     $dashboard->render($report, $target . 'dashboard.html');
     foreach ($report as $node) {
         $id = $node->getId();
         if ($node instanceof PHP_CodeCoverage_Report_Node_Directory) {
             if (!file_exists($target . $id)) {
                 mkdir($target . $id, 0777, true);
             }
             $directory->render($node, $target . $id . '/index.html');
             $dashboard->render($node, $target . $id . '/dashboard.html');
         } else {
             $dir = dirname($target . $id);
             if (!file_exists($dir)) {
                 mkdir($dir, 0777, true);
             }
             $file->render($node, $target . $id . '.html');
         }
     }
     $this->copyFiles($target);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:36,代码来源:HTML.php

示例2: process

 public function process(PHP_CodeCoverage $coverage, $target)
 {
     if (substr($target, -1, 1) != DIRECTORY_SEPARATOR) {
         $target .= DIRECTORY_SEPARATOR;
     }
     $this->target = $target;
     $this->initTargetDirectory($target);
     $report = $coverage->getReport();
     $this->project = new PHP_CodeCoverage_Report_XML_Project($coverage->getReport()->getName());
     $this->processTests($coverage->getTests());
     $this->processDirectory($report, $this->project);
     $index = $this->project->asDom();
     $index->formatOutput = true;
     $index->preserveWhiteSpace = false;
     $index->save($target . '/index.xml');
 }
开发者ID:illuminate3,项目名称:PMPortal,代码行数:16,代码来源:XML.php

示例3: getCoverageStats

 /**
  * Extract the data from the PHPUnit code coverage
  *
  * @param PHP_CodeCoverage $codeCoverage
  *
  * @return array
  */
 private function getCoverageStats(\PHP_CodeCoverage $codeCoverage)
 {
     $report = $codeCoverage->getReport();
     $classCoverage = [];
     foreach ($report as $item) {
         if (!$item instanceof \PHP_CodeCoverage_Report_Node_File) {
             continue;
         }
         $classes = $item->getClassesAndTraits();
         foreach ($classes as $className => $class) {
             $classStatements = 0;
             $coveredClassStatements = 0;
             $coveredMethods = 0;
             $classMethods = 0;
             foreach ($class['methods'] as $method) {
                 if ($method['executableLines'] == 0) {
                     continue;
                 }
                 $classMethods++;
                 $classStatements += $method['executableLines'];
                 $coveredClassStatements += $method['executedLines'];
                 if ($method['coverage'] == 100) {
                     $coveredMethods++;
                 }
             }
             if (!empty($class['package']['namespace'])) {
                 $namespace = '\\' . $class['package']['namespace'] . '::';
             } elseif (!empty($class['package']['fullPackage'])) {
                 $namespace = '@' . $class['package']['fullPackage'] . '::';
             } else {
                 $namespace = '';
             }
             if ($coveredClassStatements != 0) {
                 $classCoverage[$namespace . $className] = ['namespace' => $namespace, 'className ' => $className, 'methodsCovered' => $coveredMethods, 'methodCount' => $classMethods, 'statementsCovered' => $coveredClassStatements, 'statementCount' => $classStatements];
             }
         }
     }
     return ['classes' => ['total' => $report->getNumClassesAndTraits(), 'tested' => $report->getNumTestedClassesAndTraits()], 'methods' => ['total' => $report->getNumMethods(), 'tested' => $report->getNumTestedMethods()], 'lines' => ['total' => $report->getNumExecutableLines(), 'tested' => $report->getNumExecutedLines()], 'coverage' => $classCoverage];
 }
开发者ID:zomars,项目名称:bolt,代码行数:46,代码来源:coverage.php

示例4: getOutput

 public function getOutput(\PHP_CodeCoverage $coverage)
 {
     $output = '';
     $report = $coverage->getReport();
     foreach ($report as $item) {
         if (!$item instanceof \PHP_CodeCoverage_Report_Node_File) {
             continue;
         }
         $coverageData = $item->getCoverageData();
         $codeLines = explode(PHP_EOL, file_get_contents($item->getPath()));
         $widestLine = $this->getWidestLine($codeLines);
         $reportLines = [];
         $i = 1;
         foreach ($codeLines as $line) {
             if (array_key_exists($i, $coverageData)) {
                 $numTests = count($coverageData[$i]);
                 if ($coverageData[$i] === null) {
                     $code = self::COVERAGE_META;
                 } elseif ($numTests == 0) {
                     $code = self::COVERAGE_NOT_COVERED;
                 } else {
                     $code = self::COVERAGE_COVERED;
                 }
             } else {
                 $code = self::COVERAGE_META;
             }
             $reportLines[] = ['line' => $line, 'code' => $code];
             ++$i;
         }
         $classCoverage = $this->getClassCoverage($item->getClassesAndTraits());
         $totalCoverage = $this->getTotalCoverage($classCoverage);
         $output .= $this->renderClassCoverage($classCoverage);
         if (!$totalCoverage) {
             $output .= $this->renderCodeCoverage($reportLines, $widestLine);
         }
     }
     return $output;
 }
开发者ID:addvilz,项目名称:phpspec-cover,代码行数:38,代码来源:Reporter.php

示例5: process

 /**
  * @param  PHP_CodeCoverage $coverage
  * @param  bool             $showColors
  * @return string
  */
 public function process(PHP_CodeCoverage $coverage, $showColors = false)
 {
     $output = PHP_EOL . PHP_EOL;
     $report = $coverage->getReport();
     unset($coverage);
     $colors = array('header' => '', 'classes' => '', 'methods' => '', 'lines' => '', 'reset' => '', 'eol' => '');
     if ($showColors) {
         $colors['classes'] = $this->getCoverageColor($report->getNumTestedClassesAndTraits(), $report->getNumClassesAndTraits());
         $colors['methods'] = $this->getCoverageColor($report->getNumTestedMethods(), $report->getNumMethods());
         $colors['lines'] = $this->getCoverageColor($report->getNumExecutedLines(), $report->getNumExecutableLines());
         $colors['reset'] = $this->colors['reset'];
         $colors['header'] = $this->colors['header'];
         $colors['eol'] = $this->colors['eol'];
     }
     $classes = sprintf('  Classes: %6s (%d/%d)', PHP_CodeCoverage_Util::percent($report->getNumTestedClassesAndTraits(), $report->getNumClassesAndTraits(), true), $report->getNumTestedClassesAndTraits(), $report->getNumClassesAndTraits());
     $methods = sprintf('  Methods: %6s (%d/%d)', PHP_CodeCoverage_Util::percent($report->getNumTestedMethods(), $report->getNumMethods(), true), $report->getNumTestedMethods(), $report->getNumMethods());
     $lines = sprintf('  Lines:   %6s (%d/%d)', PHP_CodeCoverage_Util::percent($report->getNumExecutedLines(), $report->getNumExecutableLines(), true), $report->getNumExecutedLines(), $report->getNumExecutableLines());
     $padding = max(array_map('strlen', array($classes, $methods, $lines)));
     if ($this->showOnlySummary) {
         $title = 'Code Coverage Report Summary:';
         $padding = max($padding, strlen($title));
         $output .= $this->format($colors['header'], $padding, $title);
     } else {
         $date = date('  Y-m-d H:i:s', $_SERVER['REQUEST_TIME']);
         $title = 'Code Coverage Report:';
         $output .= $this->format($colors['header'], $padding, $title);
         $output .= $this->format($colors['header'], $padding, $date);
         $output .= $this->format($colors['header'], $padding, '');
         $output .= $this->format($colors['header'], $padding, ' Summary:');
     }
     $output .= $this->format($colors['classes'], $padding, $classes);
     $output .= $this->format($colors['methods'], $padding, $methods);
     $output .= $this->format($colors['lines'], $padding, $lines);
     if ($this->showOnlySummary) {
         return $output . PHP_EOL;
     }
     $classCoverage = array();
     foreach ($report as $item) {
         if (!$item instanceof PHP_CodeCoverage_Report_Node_File) {
             continue;
         }
         $classes = $item->getClassesAndTraits();
         foreach ($classes as $className => $class) {
             $classStatements = 0;
             $coveredClassStatements = 0;
             $coveredMethods = 0;
             $classMethods = 0;
             foreach ($class['methods'] as $method) {
                 if ($method['executableLines'] == 0) {
                     continue;
                 }
                 $classMethods++;
                 $classStatements += $method['executableLines'];
                 $coveredClassStatements += $method['executedLines'];
                 if ($method['coverage'] == 100) {
                     $coveredMethods++;
                 }
             }
             if (!empty($class['package']['namespace'])) {
                 $namespace = '\\' . $class['package']['namespace'] . '::';
             } elseif (!empty($class['package']['fullPackage'])) {
                 $namespace = '@' . $class['package']['fullPackage'] . '::';
             } else {
                 $namespace = '';
             }
             $classCoverage[$namespace . $className] = array('namespace' => $namespace, 'className ' => $className, 'methodsCovered' => $coveredMethods, 'methodCount' => $classMethods, 'statementsCovered' => $coveredClassStatements, 'statementCount' => $classStatements);
         }
     }
     ksort($classCoverage);
     $methodColor = '';
     $linesColor = '';
     $resetColor = '';
     foreach ($classCoverage as $fullQualifiedPath => $classInfo) {
         if ($classInfo['statementsCovered'] != 0 || $this->showUncoveredFiles) {
             if ($showColors) {
                 $methodColor = $this->getCoverageColor($classInfo['methodsCovered'], $classInfo['methodCount']);
                 $linesColor = $this->getCoverageColor($classInfo['statementsCovered'], $classInfo['statementCount']);
                 $resetColor = $colors['reset'];
             }
             $output .= PHP_EOL . $fullQualifiedPath . PHP_EOL . '  ' . $methodColor . 'Methods: ' . $this->printCoverageCounts($classInfo['methodsCovered'], $classInfo['methodCount'], 2) . $resetColor . ' ' . '  ' . $linesColor . 'Lines: ' . $this->printCoverageCounts($classInfo['statementsCovered'], $classInfo['statementCount'], 3) . $resetColor;
         }
     }
     return $output . PHP_EOL;
 }
开发者ID:illuminate3,项目名称:PMPortal,代码行数:89,代码来源:Text.php

示例6: process

 /**
  * @param  PHP_CodeCoverage $coverage
  * @param  string           $target
  * @param  string           $name
  * @return string
  */
 public function process(PHP_CodeCoverage $coverage, $target = null, $name = null)
 {
     $document = new DOMDocument('1.0', 'UTF-8');
     $document->formatOutput = true;
     $root = $document->createElement('crap_result');
     $document->appendChild($root);
     $project = $document->createElement('project', is_string($name) ? $name : '');
     $root->appendChild($project);
     $root->appendChild($document->createElement('timestamp', date('Y-m-d H:i:s', (int) $_SERVER['REQUEST_TIME'])));
     $stats = $document->createElement('stats');
     $methodsNode = $document->createElement('methods');
     $report = $coverage->getReport();
     unset($coverage);
     $fullMethodCount = 0;
     $fullCrapMethodCount = 0;
     $fullCrapLoad = 0;
     $fullCrap = 0;
     foreach ($report as $item) {
         $namespace = 'global';
         if (!$item instanceof PHP_CodeCoverage_Report_Node_File) {
             continue;
         }
         $file = $document->createElement('file');
         $file->setAttribute('name', $item->getPath());
         $classes = $item->getClassesAndTraits();
         foreach ($classes as $className => $class) {
             foreach ($class['methods'] as $methodName => $method) {
                 $crapLoad = $this->getCrapLoad($method['crap'], $method['ccn'], $method['coverage']);
                 $fullCrap += $method['crap'];
                 $fullCrapLoad += $crapLoad;
                 $fullMethodCount++;
                 if ($method['crap'] >= $this->threshold) {
                     $fullCrapMethodCount++;
                 }
                 $methodNode = $document->createElement('method');
                 if (!empty($class['package']['namespace'])) {
                     $namespace = $class['package']['namespace'];
                 }
                 $methodNode->appendChild($document->createElement('package', $namespace));
                 $methodNode->appendChild($document->createElement('className', $className));
                 $methodNode->appendChild($document->createElement('methodName', $methodName));
                 $methodNode->appendChild($document->createElement('methodSignature', htmlspecialchars($method['signature'])));
                 $methodNode->appendChild($document->createElement('fullMethod', htmlspecialchars($method['signature'])));
                 $methodNode->appendChild($document->createElement('crap', $this->roundValue($method['crap'])));
                 $methodNode->appendChild($document->createElement('complexity', $method['ccn']));
                 $methodNode->appendChild($document->createElement('coverage', $this->roundValue($method['coverage'])));
                 $methodNode->appendChild($document->createElement('crapLoad', round($crapLoad)));
                 $methodsNode->appendChild($methodNode);
             }
         }
     }
     $stats->appendChild($document->createElement('name', 'Method Crap Stats'));
     $stats->appendChild($document->createElement('methodCount', $fullMethodCount));
     $stats->appendChild($document->createElement('crapMethodCount', $fullCrapMethodCount));
     $stats->appendChild($document->createElement('crapLoad', round($fullCrapLoad)));
     $stats->appendChild($document->createElement('totalCrap', $fullCrap));
     $stats->appendChild($document->createElement('crapMethodPercent', $this->roundValue(100 * $fullCrapMethodCount / $fullMethodCount)));
     $root->appendChild($stats);
     $root->appendChild($methodsNode);
     if ($target !== null) {
         if (!is_dir(dirname($target))) {
             mkdir(dirname($target), 0777, true);
         }
         return $document->save($target);
     } else {
         return $document->saveXML();
     }
 }
开发者ID:acrixl,项目名称:Reportula,代码行数:74,代码来源:Crap4j.php

示例7: process

 /**
  * @param  PHP_CodeCoverage $coverage
  * @param  string           $target
  * @param  string           $name
  * @return string
  */
 public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL)
 {
     $xmlDocument = new DOMDocument('1.0', 'UTF-8');
     $xmlDocument->formatOutput = TRUE;
     $xmlCoverage = $xmlDocument->createElement('coverage');
     $xmlCoverage->setAttribute('generated', (int) $_SERVER['REQUEST_TIME']);
     $xmlDocument->appendChild($xmlCoverage);
     $xmlProject = $xmlDocument->createElement('project');
     $xmlProject->setAttribute('timestamp', (int) $_SERVER['REQUEST_TIME']);
     if (is_string($name)) {
         $xmlProject->setAttribute('name', $name);
     }
     $xmlCoverage->appendChild($xmlProject);
     $packages = array();
     $report = $coverage->getReport();
     unset($coverage);
     foreach ($report as $item) {
         $namespace = 'global';
         if (!$item instanceof PHP_CodeCoverage_Report_Node_File) {
             continue;
         }
         $xmlFile = $xmlDocument->createElement('file');
         $xmlFile->setAttribute('name', $item->getPath());
         $classes = array_merge($item->getClasses(), $item->getTraits());
         $coverage = $item->getCoverageData();
         $lines = array();
         $ignoredLines = $item->getIgnoredLines();
         foreach ($classes as $className => $class) {
             $classStatements = 0;
             $coveredClassStatements = 0;
             $coveredMethods = 0;
             foreach ($class['methods'] as $methodName => $method) {
                 $methodCount = 0;
                 $methodLines = 0;
                 $methodLinesCovered = 0;
                 for ($i = $method['startLine']; $i <= $method['endLine']; $i++) {
                     if (isset($ignoredLines[$i])) {
                         continue;
                     }
                     $add = TRUE;
                     $count = 0;
                     if (isset($coverage[$i])) {
                         if ($coverage[$i] !== NULL) {
                             $classStatements++;
                             $methodLines++;
                         } else {
                             $add = FALSE;
                         }
                         $count = count($coverage[$i]);
                         if ($count > 0) {
                             $coveredClassStatements++;
                             $methodLinesCovered++;
                         }
                     } else {
                         $add = FALSE;
                     }
                     $methodCount = max($methodCount, $count);
                     if ($add) {
                         $lines[$i] = array('count' => $count, 'type' => 'stmt');
                     }
                 }
                 if ($methodCount > 0) {
                     $coveredMethods++;
                 }
                 $lines[$method['startLine']] = array('count' => $methodCount, 'crap' => PHP_CodeCoverage_Util::crap($method['ccn'], PHP_CodeCoverage_Util::percent($methodLinesCovered, $methodLines)), 'type' => 'method', 'name' => $methodName);
             }
             if (!empty($class['package']['namespace'])) {
                 $namespace = $class['package']['namespace'];
             }
             $xmlClass = $xmlDocument->createElement('class');
             $xmlClass->setAttribute('name', $className);
             $xmlClass->setAttribute('namespace', $namespace);
             if (!empty($class['package']['fullPackage'])) {
                 $xmlClass->setAttribute('fullPackage', $class['package']['fullPackage']);
             }
             if (!empty($class['package']['category'])) {
                 $xmlClass->setAttribute('category', $class['package']['category']);
             }
             if (!empty($class['package']['package'])) {
                 $xmlClass->setAttribute('package', $class['package']['package']);
             }
             if (!empty($class['package']['subpackage'])) {
                 $xmlClass->setAttribute('subpackage', $class['package']['subpackage']);
             }
             $xmlFile->appendChild($xmlClass);
             $xmlMetrics = $xmlDocument->createElement('metrics');
             $xmlMetrics->setAttribute('methods', count($class['methods']));
             $xmlMetrics->setAttribute('coveredmethods', $coveredMethods);
             $xmlMetrics->setAttribute('conditionals', 0);
             $xmlMetrics->setAttribute('coveredconditionals', 0);
             $xmlMetrics->setAttribute('statements', $classStatements);
             $xmlMetrics->setAttribute('coveredstatements', $coveredClassStatements);
             $xmlMetrics->setAttribute('elements', count($class['methods']) + $classStatements);
             $xmlMetrics->setAttribute('coveredelements', $coveredMethods + $coveredClassStatements);
//.........这里部分代码省略.........
开发者ID:nbalonso,项目名称:MunkiFace,代码行数:101,代码来源:Clover.php

示例8: process

 /**
  * @param  PHP_CodeCoverage $coverage
  * @param  string           $target
  * @param  string           $name
  * @return string
  */
 public function process(PHP_CodeCoverage $coverage, $showColors = FALSE)
 {
     $output = '';
     $packages = array();
     $report = $coverage->getReport();
     unset($coverage);
     $colors = array('header' => '', 'classes' => '', 'methods' => '', 'lines' => '', 'reset' => '', 'eol' => '');
     if ($showColors) {
         $colors['classes'] = $this->getCoverageColor($report->getNumTestedClasses(), $report->getNumClasses());
         $colors['methods'] = $this->getCoverageColor($report->getNumTestedMethods(), $report->getNumMethods());
         $colors['lines'] = $this->getCoverageColor($report->getNumExecutedLines(), $report->getNumExecutableLines());
         $colors['reset'] = $this->colors['reset'];
         $colors['header'] = $this->colors['header'];
         $colors['eol'] = $this->colors['eol'];
     }
     $output .= PHP_EOL . PHP_EOL . $colors['header'] . 'Code Coverage Report ';
     if ($this->title) {
         $output .= 'for "' . $this->title . '"';
     }
     $output .= PHP_EOL . date('  Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . PHP_EOL;
     $output .= PHP_EOL . ' Summary: ' . PHP_EOL . $colors['reset'] . $colors['classes'] . $colors['eol'] . '  Classes: ' . PHP_CodeCoverage_Util::percent($report->getNumTestedClasses(), $report->getNumClasses(), TRUE) . ' (' . $report->getNumTestedClasses() . '/' . $report->getNumClasses() . ')' . PHP_EOL . $colors['eol'] . $colors['methods'] . $colors['eol'] . '  Methods: ' . PHP_CodeCoverage_Util::percent($report->getNumTestedMethods(), $report->getNumMethods(), TRUE) . ' (' . $report->getNumTestedMethods() . '/' . $report->getNumMethods() . ')' . PHP_EOL . $colors['eol'] . $colors['lines'] . $colors['eol'] . '  Lines:   ' . PHP_CodeCoverage_Util::percent($report->getNumExecutedLines(), $report->getNumExecutableLines(), TRUE) . ' (' . $report->getNumExecutedLines() . '/' . $report->getNumExecutableLines() . ')' . PHP_EOL . $colors['reset'] . $colors['eol'];
     $classCoverage = array();
     foreach ($report as $item) {
         if (!$item instanceof PHP_CodeCoverage_Report_Node_File) {
             continue;
         }
         $classes = array_merge($item->getClasses(), $item->getTraits());
         $coverage = $item->getCoverageData();
         $lines = array();
         $ignoredLines = $item->getIgnoredLines();
         foreach ($classes as $className => $class) {
             $classStatements = 0;
             $coveredClassStatements = 0;
             $coveredMethods = 0;
             foreach ($class['methods'] as $methodName => $method) {
                 $methodCount = 0;
                 $methodLines = 0;
                 $methodLinesCovered = 0;
                 for ($i = $method['startLine']; $i <= $method['endLine']; $i++) {
                     if (isset($ignoredLines[$i])) {
                         continue;
                     }
                     $add = TRUE;
                     $count = 0;
                     if (isset($coverage[$i])) {
                         if ($coverage[$i] !== NULL) {
                             $classStatements++;
                             $methodLines++;
                         } else {
                             $add = FALSE;
                         }
                         $count = count($coverage[$i]);
                         if ($count > 0) {
                             $coveredClassStatements++;
                             $methodLinesCovered++;
                         }
                     } else {
                         $add = FALSE;
                     }
                     $methodCount = max($methodCount, $count);
                     if ($add) {
                         $lines[$i] = array('count' => $count, 'type' => 'stmt');
                     }
                 }
                 if ($methodCount > 0) {
                     $coveredMethods++;
                 }
             }
             if (!empty($class['package']['namespace'])) {
                 $namespace = '\\' . $class['package']['namespace'] . '::';
             } else {
                 if (!empty($class['package']['fullPackage'])) {
                     $namespace = '@' . $class['package']['fullPackage'] . '::';
                 } else {
                     $namespace = '';
                 }
             }
             $classCoverage[$namespace . $className] = array('namespace' => $namespace, 'className ' => $className, 'methodsCovered' => $coveredMethods, 'methodCount' => count($class['methods']), 'statementsCovered' => $coveredClassStatements, 'statementCount' => $classStatements);
         }
     }
     ksort($classCoverage);
     $methodColor = '';
     $linesColor = '';
     $resetColor = '';
     foreach ($classCoverage as $fullQualifiedPath => $classInfo) {
         if ($classInfo['statementsCovered'] != 0 || $this->showUncoveredFiles) {
             if ($showColors) {
                 $methodColor = $this->getCoverageColor($classInfo['methodsCovered'], $classInfo['methodCount']);
                 $linesColor = $this->getCoverageColor($classInfo['statementsCovered'], $classInfo['statementCount']);
                 $resetColor = $colors['reset'];
             }
             $output .= PHP_EOL . $fullQualifiedPath . PHP_EOL . '  ' . $methodColor . 'Methods: ' . $this->printCoverageCounts($classInfo['methodsCovered'], $classInfo['methodCount'], 2) . $resetColor . ' ' . '  ' . $linesColor . 'Lines: ' . $this->printCoverageCounts($classInfo['statementsCovered'], $classInfo['statementCount'], 3) . $resetColor;
         }
     }
//.........这里部分代码省略.........
开发者ID:nbalonso,项目名称:MunkiFace,代码行数:101,代码来源:Text.php

示例9: process

 /**
  * @param PHP_CodeCoverage $coverage
  * @param string           $target
  */
 public function process(PHP_CodeCoverage $coverage, $target)
 {
     $target = PHP_CodeCoverage_Util::getDirectory($target);
     $report = $coverage->getReport();
     unset($coverage);
     $date = date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']);
     $dashboard = new PHP_CodeCoverage_Report_HTML_Renderer_Dashboard($this->templatePath, $this->charset, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
     $directory = new PHP_CodeCoverage_Report_HTML_Renderer_Directory($this->templatePath, $this->charset, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
     $file = new PHP_CodeCoverage_Report_HTML_Renderer_File($this->templatePath, $this->charset, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound, $this->highlight, $this->yui);
     $dashboard->render($report, $target . 'index.dashboard.html', $this->title);
     $directory->render($report, $target . 'index.html', $this->title);
     foreach ($report as $node) {
         $id = $node->getId();
         if ($node instanceof PHP_CodeCoverage_Report_Node_Directory) {
             $dashboard->render($node, $target . $id . '.dashboard.html');
             $directory->render($node, $target . $id . '.html');
         } else {
             $file->render($node, $target . $id . '.html');
         }
     }
     $this->copyFiles($target);
 }
开发者ID:staabm,项目名称:redaxo,代码行数:26,代码来源:HTML.php

示例10: process

 /**
  * @param PHP_CodeCoverage $coverage
  * @param string           $target
  * @param string           $name
  *
  * @return string
  */
 public function process(PHP_CodeCoverage $coverage, $target = null, $name = null)
 {
     $xmlDocument = new DOMDocument('1.0', 'UTF-8');
     $xmlDocument->formatOutput = true;
     $xmlCoverage = $xmlDocument->createElement('coverage');
     $xmlCoverage->setAttribute('generated', (int) $_SERVER['REQUEST_TIME']);
     $xmlDocument->appendChild($xmlCoverage);
     $xmlProject = $xmlDocument->createElement('project');
     $xmlProject->setAttribute('timestamp', (int) $_SERVER['REQUEST_TIME']);
     if (is_string($name)) {
         $xmlProject->setAttribute('name', $name);
     }
     $xmlCoverage->appendChild($xmlProject);
     $packages = [];
     $report = $coverage->getReport();
     unset($coverage);
     foreach ($report as $item) {
         if (!$item instanceof PHP_CodeCoverage_Report_Node_File) {
             continue;
         }
         $xmlFile = $xmlDocument->createElement('file');
         $xmlFile->setAttribute('name', $item->getPath());
         $classes = $item->getClassesAndTraits();
         $coverage = $item->getCoverageData();
         $lines = [];
         $namespace = 'global';
         foreach ($classes as $className => $class) {
             $classStatements = 0;
             $coveredClassStatements = 0;
             $coveredMethods = 0;
             $classMethods = 0;
             foreach ($class['methods'] as $methodName => $method) {
                 if ($method['executableLines'] == 0) {
                     continue;
                 }
                 $classMethods++;
                 $classStatements += $method['executableLines'];
                 $coveredClassStatements += $method['executedLines'];
                 if ($method['coverage'] == 100) {
                     $coveredMethods++;
                 }
                 $methodCount = 0;
                 foreach (range($method['startLine'], $method['endLine']) as $line) {
                     if (isset($coverage[$line]) && $coverage[$line] !== null) {
                         $methodCount = max($methodCount, count($coverage[$line]));
                     }
                 }
                 $lines[$method['startLine']] = ['ccn' => $method['ccn'], 'count' => $methodCount, 'crap' => $method['crap'], 'type' => 'method', 'visibility' => $method['visibility'], 'name' => $methodName];
             }
             if (!empty($class['package']['namespace'])) {
                 $namespace = $class['package']['namespace'];
             }
             $xmlClass = $xmlDocument->createElement('class');
             $xmlClass->setAttribute('name', $className);
             $xmlClass->setAttribute('namespace', $namespace);
             if (!empty($class['package']['fullPackage'])) {
                 $xmlClass->setAttribute('fullPackage', $class['package']['fullPackage']);
             }
             if (!empty($class['package']['category'])) {
                 $xmlClass->setAttribute('category', $class['package']['category']);
             }
             if (!empty($class['package']['package'])) {
                 $xmlClass->setAttribute('package', $class['package']['package']);
             }
             if (!empty($class['package']['subpackage'])) {
                 $xmlClass->setAttribute('subpackage', $class['package']['subpackage']);
             }
             $xmlFile->appendChild($xmlClass);
             $xmlMetrics = $xmlDocument->createElement('metrics');
             $xmlMetrics->setAttribute('complexity', $class['ccn']);
             $xmlMetrics->setAttribute('methods', $classMethods);
             $xmlMetrics->setAttribute('coveredmethods', $coveredMethods);
             $xmlMetrics->setAttribute('conditionals', 0);
             $xmlMetrics->setAttribute('coveredconditionals', 0);
             $xmlMetrics->setAttribute('statements', $classStatements);
             $xmlMetrics->setAttribute('coveredstatements', $coveredClassStatements);
             $xmlMetrics->setAttribute('elements', $classMethods + $classStatements);
             $xmlMetrics->setAttribute('coveredelements', $coveredMethods + $coveredClassStatements);
             $xmlClass->appendChild($xmlMetrics);
         }
         foreach ($coverage as $line => $data) {
             if ($data === null || isset($lines[$line])) {
                 continue;
             }
             $lines[$line] = ['count' => count($data), 'type' => 'stmt'];
         }
         ksort($lines);
         foreach ($lines as $line => $data) {
             $xmlLine = $xmlDocument->createElement('line');
             $xmlLine->setAttribute('num', $line);
             $xmlLine->setAttribute('type', $data['type']);
             if (isset($data['name'])) {
                 $xmlLine->setAttribute('name', $data['name']);
//.........这里部分代码省略.........
开发者ID:stephenmoore56,项目名称:mooredatabase-laravel,代码行数:101,代码来源:Clover.php


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