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


PHP PHP_CodeCoverage_Util类代码示例

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


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

示例1: merge

 static function merge($project, $codeCoverageInformation)
 {
     $coverageDatabase = $project->getProperty('coverage.database');
     if (!$coverageDatabase) {
         throw new BuildException("Property coverage.database is not set - please include coverage-setup in your build file");
     }
     $database = new PhingFile($coverageDatabase);
     $props = new Properties();
     $props->load($database);
     $coverageTotal = $codeCoverageInformation;
     foreach ($coverageTotal as $filename => $data) {
         if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0') >= 0) {
             $ignoreLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($filename);
         } else {
             // FIXME retrieve ignored lines for PHPUnit Version < 3.5.0
             $ignoreLines = array();
         }
         $lines = array();
         $filename = strtolower($filename);
         if ($props->getProperty($filename) != null) {
             foreach ($data as $_line => $_data) {
                 if (is_array($_data)) {
                     $count = count($_data);
                 } else {
                     if (isset($ignoreLines[$_line])) {
                         // line is marked as ignored
                         $count = 1;
                     } else {
                         if ($_data == -1) {
                             // not executed
                             $count = -1;
                         } else {
                             if ($_data == -2) {
                                 // dead code
                                 $count = -2;
                             }
                         }
                     }
                 }
                 $lines[$_line] = $count;
             }
             ksort($lines);
             $file = unserialize($props->getProperty($filename));
             $left = $file['coverage'];
             $coverageMerged = CoverageMerger::mergeCodeCoverage($left, $lines);
             $file['coverage'] = $coverageMerged;
             $props->setProperty($filename, serialize($file));
         }
     }
     $props->store($database);
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:51,代码来源:CoverageMerger.php

示例2: process

 /**
  * @param PHP_CodeCoverage $coverage
  * @param string           $target
  */
 public function process(PHP_CodeCoverage $coverage, $target)
 {
     $target = PHP_CodeCoverage_Util::getDirectory($target);
     $files = $coverage->getSummary();
     $commonPath = PHP_CodeCoverage_Util::reducePaths($files);
     $items = PHP_CodeCoverage_Util::buildDirectoryStructure($files);
     $root = new PHP_CodeCoverage_Report_HTML_Node_Directory($commonPath, NULL);
     $this->addItems($root, $items, $files);
     $this->renderDashboard($root, $target . 'index.dashboard.html', $this->options['title']);
     foreach ($root as $node) {
         if ($node instanceof PHP_CodeCoverage_Report_HTML_Node_Directory) {
             $this->renderDashboard($node, $target . PHP_CodeCoverage_Util::getSafeFilename($node->getId()) . '.dashboard.html', $node->getName(TRUE));
         }
     }
     $root->render($target, $this->options['title'], $this->options['charset'], $this->options['lowUpperBound'], $this->options['highLowerBound'], $this->options['generator']);
     $this->copyFiles($target);
 }
开发者ID:redlion09,项目名称:pcppi,代码行数:21,代码来源:HTML.php

示例3: calculateStatistics

 /**
  * Calculates coverage statistics for the file.
  *
  */
 protected function calculateStatistics()
 {
     $this->processClasses();
     $this->processFunctions();
     $max = count($this->codeLines);
     for ($lineNumber = 1; $lineNumber <= $max; $lineNumber++) {
         if (isset($this->startLines[$lineNumber])) {
             // Start line of a class.
             if (isset($this->startLines[$lineNumber]['methods'])) {
                 $currentClass =& $this->startLines[$lineNumber];
             } else {
                 $currentMethod =& $this->startLines[$lineNumber];
             }
         }
         if (isset($this->executedLines[$lineNumber])) {
             // Array: Line is executable and was executed.
             if (is_array($this->executedLines[$lineNumber])) {
                 if (isset($currentClass)) {
                     $currentClass['executableLines']++;
                     $currentClass['executedLines']++;
                 }
                 if (isset($currentMethod)) {
                     $currentMethod['executableLines']++;
                     $currentMethod['executedLines']++;
                 }
                 $this->numExecutableLines++;
                 $this->numExecutedLines++;
             } else {
                 if ($this->executedLines[$lineNumber] == -1) {
                     if (isset($currentClass)) {
                         $currentClass['executableLines']++;
                     }
                     if (isset($currentMethod)) {
                         $currentMethod['executableLines']++;
                     }
                     $this->numExecutableLines++;
                     if (isset($this->ignoredLines[$lineNumber])) {
                         if (isset($currentClass)) {
                             $currentClass['executedLines']++;
                         }
                         if (isset($currentMethod)) {
                             $currentMethod['executedLines']++;
                         }
                         $this->numExecutedLines++;
                     }
                 }
             }
         }
         if (isset($this->endLines[$lineNumber])) {
             // End line of a class.
             if (isset($this->endLines[$lineNumber]['methods'])) {
                 unset($currentClass);
             } else {
                 unset($currentMethod);
             }
         }
     }
     foreach ($this->classes as $className => &$class) {
         foreach ($class['methods'] as &$method) {
             if ($method['executableLines'] > 0) {
                 $method['coverage'] = $method['executedLines'] / $method['executableLines'] * 100;
             } else {
                 $method['coverage'] = 100;
             }
             $method['crap'] = PHP_CodeCoverage_Util::crap($method['ccn'], $method['coverage']);
             $class['ccn'] += $method['ccn'];
         }
         if ($className != '*') {
             if ($class['executableLines'] > 0) {
                 $class['coverage'] = $class['executedLines'] / $class['executableLines'] * 100;
             } else {
                 $class['coverage'] = 100;
             }
             if ($class['coverage'] == 100) {
                 $this->numTestedClasses++;
             }
             $class['crap'] = PHP_CodeCoverage_Util::crap($class['ccn'], $class['coverage']);
         }
     }
 }
开发者ID:reflectivedevelopment,项目名称:jfh-lib,代码行数:84,代码来源:File.php

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

示例5: calculateStatistics

 /**
  * Calculates coverage statistics for the file.
  */
 protected function calculateStatistics()
 {
     if ($this->cacheTokens) {
         $tokens = PHP_Token_Stream_CachingFactory::get($this->getPath());
     } else {
         $tokens = new PHP_Token_Stream($this->getPath());
     }
     $this->processClasses($tokens);
     $this->processTraits($tokens);
     $this->processFunctions($tokens);
     $this->linesOfCode = $tokens->getLinesOfCode();
     unset($tokens);
     for ($lineNumber = 1; $lineNumber <= $this->linesOfCode['loc']; $lineNumber++) {
         if (isset($this->startLines[$lineNumber])) {
             // Start line of a class.
             if (isset($this->startLines[$lineNumber]['className'])) {
                 $currentClass =& $this->startLines[$lineNumber];
             } else {
                 if (isset($this->startLines[$lineNumber]['traitName'])) {
                     $currentTrait =& $this->startLines[$lineNumber];
                 } else {
                     if (isset($this->startLines[$lineNumber]['methodName'])) {
                         $currentMethod =& $this->startLines[$lineNumber];
                     } else {
                         if (isset($this->startLines[$lineNumber]['functionName'])) {
                             $currentFunction =& $this->startLines[$lineNumber];
                         }
                     }
                 }
             }
         }
         if (!isset($this->ignoredLines[$lineNumber]) && isset($this->coverageData[$lineNumber]) && $this->coverageData[$lineNumber] !== NULL) {
             if (isset($currentClass)) {
                 $currentClass['executableLines']++;
             }
             if (isset($currentTrait)) {
                 $currentTrait['executableLines']++;
             }
             if (isset($currentMethod)) {
                 $currentMethod['executableLines']++;
             }
             if (isset($currentFunction)) {
                 $currentFunction['executableLines']++;
             }
             $this->numExecutableLines++;
             if (count($this->coverageData[$lineNumber]) > 0 || isset($this->ignoredLines[$lineNumber])) {
                 if (isset($currentClass)) {
                     $currentClass['executedLines']++;
                 }
                 if (isset($currentTrait)) {
                     $currentTrait['executedLines']++;
                 }
                 if (isset($currentMethod)) {
                     $currentMethod['executedLines']++;
                 }
                 if (isset($currentFunction)) {
                     $currentFunction['executedLines']++;
                 }
                 $this->numExecutedLines++;
             }
         }
         if (isset($this->endLines[$lineNumber])) {
             // End line of a class.
             if (isset($this->endLines[$lineNumber]['className'])) {
                 unset($currentClass);
             } else {
                 if (isset($this->endLines[$lineNumber]['traitName'])) {
                     unset($currentTrait);
                 } else {
                     if (isset($this->endLines[$lineNumber]['methodName'])) {
                         unset($currentMethod);
                     } else {
                         if (isset($this->endLines[$lineNumber]['functionName'])) {
                             unset($currentFunction);
                         }
                     }
                 }
             }
         }
     }
     foreach ($this->traits as $traitName => &$trait) {
         foreach ($trait['methods'] as &$method) {
             if ($method['executableLines'] > 0) {
                 $method['coverage'] = $method['executedLines'] / $method['executableLines'] * 100;
             } else {
                 $method['coverage'] = 100;
             }
             $method['crap'] = PHP_CodeCoverage_Util::crap($method['ccn'], $method['coverage']);
             $trait['ccn'] += $method['ccn'];
         }
         if ($trait['executableLines'] > 0) {
             $trait['coverage'] = $trait['executedLines'] / $trait['executableLines'] * 100;
         } else {
             $trait['coverage'] = 100;
         }
         if ($trait['coverage'] == 100) {
             $this->numTestedClasses++;
//.........这里部分代码省略.........
开发者ID:staabm,项目名称:redaxo,代码行数:101,代码来源:File.php

示例6: doRender

 /**
  * @param string  $target
  * @param string  $title
  * @param string  $charset
  * @param integer $lowUpperBound
  * @param integer $highLowerBound
  * @param string  $generator
  */
 protected function doRender($target, $title, $charset, $lowUpperBound, $highLowerBound, $generator)
 {
     $cleanId = PHP_CodeCoverage_Util::getSafeFilename($this->getId());
     $file = $target . $cleanId . '.html';
     $template = new Text_Template(PHP_CodeCoverage_Report_HTML::$templatePath . 'directory.html');
     $this->setTemplateVars($template, $title, $charset, $generator);
     $template->setVar(array('total_item' => $this->renderTotalItem($lowUpperBound, $highLowerBound), 'items' => $this->renderItems($lowUpperBound, $highLowerBound), 'low_upper_bound' => $lowUpperBound, 'high_lower_bound' => $highLowerBound));
     $template->renderTo($file);
     $this->directories = array();
     $this->files = array();
 }
开发者ID:rdohms,项目名称:php-code-coverage,代码行数:19,代码来源:Directory.php

示例7: merge

 public static function merge($project, $codeCoverageInformation)
 {
     $props = self::_getDatabase($project);
     $coverageTotal = $codeCoverageInformation;
     foreach ($coverageTotal as $filename => $data) {
         $ignoreLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($filename);
         $lines = array();
         $filename = strtolower($filename);
         if ($props->getProperty($filename) != null) {
             foreach ($data as $_line => $_data) {
                 if (is_array($_data)) {
                     $count = count($_data);
                 } else {
                     if (isset($ignoreLines[$_line])) {
                         // line is marked as ignored
                         $count = 1;
                     } else {
                         if ($_data == -1) {
                             // not executed
                             $count = -1;
                         } else {
                             if ($_data == -2) {
                                 // dead code
                                 $count = -2;
                             }
                         }
                     }
                 }
                 $lines[$_line] = $count;
             }
             ksort($lines);
             $file = unserialize($props->getProperty($filename));
             $left = $file['coverage'];
             $coverageMerged = CoverageMerger::mergeCodeCoverage($left, $lines);
             $file['coverage'] = $coverageMerged;
             $props->setProperty($filename, serialize($file));
         }
     }
     $props->store();
 }
开发者ID:namesco,项目名称:phing,代码行数:40,代码来源:CoverageMerger.php

示例8: printCoverageCounts

 protected function printCoverageCounts($numberOfCoveredElements, $totalNumberOfElements, $presicion)
 {
     $format = '%' . $presicion . 's';
     return PHP_CodeCoverage_Util::percent($numberOfCoveredElements, $totalNumberOfElements, true, true) . ' (' . sprintf($format, $numberOfCoveredElements) . '/' . sprintf($format, $totalNumberOfElements) . ')';
 }
开发者ID:illuminate3,项目名称:PMPortal,代码行数:5,代码来源:Text.php

示例9: testPercent

 /**
  * @covers PHP_CodeCoverage_Util::percent
  */
 public function testPercent()
 {
     $this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 0));
     $this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 100));
     $this->assertEquals('100.00%', PHP_CodeCoverage_Util::percent(100, 100, TRUE));
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:9,代码来源:UtilTest.php

示例10: renderTraitOrClassItems

 /**
  * @param  array         $items
  * @param  Text_Template $template
  *
  * @return string
  */
 protected function renderTraitOrClassItems(array $items, Text_Template $template, Text_Template $methodItemTemplate)
 {
     if (empty($items)) {
         return '';
     }
     $buffer = '';
     foreach ($items as $name => $item) {
         $numMethods = count($item['methods']);
         $numTestedMethods = 0;
         foreach ($item['methods'] as $method) {
             if ($method['executedLines'] == $method['executableLines']) {
                 $numTestedMethods++;
             }
         }
         $buffer .= $this->renderItemTemplate($template, array('name' => $name, 'numClasses' => 1, 'numTestedClasses' => $numTestedMethods == $numMethods ? 1 : 0, 'numMethods' => $numMethods, 'numTestedMethods' => $numTestedMethods, 'linesExecutedPercent' => PHP_CodeCoverage_Util::percent($item['executedLines'], $item['executableLines'], false), 'linesExecutedPercentAsString' => PHP_CodeCoverage_Util::percent($item['executedLines'], $item['executableLines'], true), 'numExecutedLines' => $item['executedLines'], 'numExecutableLines' => $item['executableLines'], 'testedMethodsPercent' => PHP_CodeCoverage_Util::percent($numTestedMethods, $numMethods, false), 'testedMethodsPercentAsString' => PHP_CodeCoverage_Util::percent($numTestedMethods, $numMethods, true), 'testedClassesPercent' => PHP_CodeCoverage_Util::percent($numTestedMethods == $numMethods ? 1 : 0, 1, false), 'testedClassesPercentAsString' => PHP_CodeCoverage_Util::percent($numTestedMethods == $numMethods ? 1 : 0, 1, true), 'crap' => $item['crap']));
         foreach ($item['methods'] as $method) {
             $buffer .= $this->renderFunctionOrMethodItem($methodItemTemplate, $method, '&nbsp;');
         }
     }
     return $buffer;
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:27,代码来源:File.php

示例11: __construct

 /**
  * Prefills the blacklist with source files used by PHPUnit
  * and PHP_CodeCoverage.
  */
 public function __construct()
 {
     $functions = array('file_iterator_autoload', 'php_codecoverage_autoload', 'php_invoker_autoload', 'php_timer_autoload', 'php_tokenstream_autoload', 'phpunit_autoload', 'phpunit_dbunit_autoload', 'phpunit_mockobject_autoload', 'phpunit_selenium_autoload', 'phpunit_story_autoload', 'text_template_autoload');
     foreach ($functions as $function) {
         if (function_exists($function)) {
             $this->addFilesToBlacklist($function());
         }
     }
     $file = PHP_CodeCoverage_Util::fileExistsInIncludePath('SymfonyComponents/YAML/sfYaml.php');
     if ($file) {
         $this->addFileToBlacklist($file);
     }
     $file = PHP_CodeCoverage_Util::fileExistsInIncludePath('SymfonyComponents/YAML/sfYamlDumper.php');
     if ($file) {
         $this->addFileToBlacklist($file);
     }
 }
开发者ID:nbalonso,项目名称:MunkiFace,代码行数:21,代码来源:Filter.php

示例12: renderFunctionOrMethodItem

 /**
  * @param  Text_Template $template
  * @return string
  */
 protected function renderFunctionOrMethodItem(Text_Template $template, array $item, $indent = '')
 {
     $numTestedItems = $item['executedLines'] == $item['executableLines'] ? 1 : 0;
     return $this->renderItemTemplate($template, array('name' => sprintf('%s<a href="#%d"><abbr title="%s">%s</abbr></a>', $indent, $item['startLine'], htmlspecialchars($item['signature']), isset($item['functionName']) ? $item['functionName'] : $item['methodName']), 'numMethods' => 1, 'numTestedMethods' => $numTestedItems, 'linesExecutedPercent' => PHP_CodeCoverage_Util::percent($item['executedLines'], $item['executableLines'], false), 'linesExecutedPercentAsString' => PHP_CodeCoverage_Util::percent($item['executedLines'], $item['executableLines'], true), 'numExecutedLines' => $item['executedLines'], 'numExecutableLines' => $item['executableLines'], 'testedMethodsPercent' => PHP_CodeCoverage_Util::percent($numTestedItems, 1, false), 'testedMethodsPercentAsString' => PHP_CodeCoverage_Util::percent($numTestedItems, 1, true), 'crap' => $item['crap']));
 }
开发者ID:akarimgh,项目名称:matrix42-slim-api,代码行数:9,代码来源:File.php

示例13: __construct

 /**
  * Constructor.
  *
  * @param  string                       $name
  * @param  PHP_CodeCoverage_Report_Node $parent
  * @param  array                        $coverageData
  * @param  array                        $testData
  * @param  boolean                      $cacheTokens
  * @throws PHP_CodeCoverage_Exception
  */
 public function __construct($name, PHP_CodeCoverage_Report_Node $parent, array $coverageData, array $testData, $cacheTokens)
 {
     if (!is_bool($cacheTokens)) {
         throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory(1, 'boolean');
     }
     parent::__construct($name, $parent);
     $this->coverageData = $coverageData;
     $this->testData = $testData;
     $this->ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($this->getPath(), $cacheTokens);
     $this->cacheTokens = $cacheTokens;
     $this->calculateStatistics();
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:22,代码来源:File.php

示例14: setTemplateVars

 /**
  * @param Text_Template $template
  * @param string        $title
  * @param string        $charset
  * @param string        $generator
  */
 protected function setTemplateVars(Text_Template $template, $title, $charset, $generator)
 {
     $dashboard = '';
     if ($this instanceof PHP_CodeCoverage_Report_HTML_Node_Directory) {
         $dashboard = sprintf('<a href="%s">dashboard</a>', PHP_CodeCoverage_Util::getSafeFilename($this->getId()) . '.dashboard.html');
     }
     $template->setVar(array('title' => $title, 'charset' => $charset, 'link' => $this->getLink(TRUE), 'dashboard_link' => $dashboard, 'num_executable_lines' => $this->getNumExecutableLines(), 'num_executed_lines' => $this->getNumExecutedLines(), 'lines_executed_percent' => $this->getLineExecutedPercent(), 'date' => date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']), 'version' => '@package_version@', 'php_version' => PHP_VERSION, 'generator' => $generator));
 }
开发者ID:proofek,项目名称:php-code-coverage,代码行数:14,代码来源:Node.php

示例15: applyCoversAnnotationFilter

 /**
  * Applies the @covers annotation filtering.
  *
  * @param array $data
  * @param mixed $id
  */
 protected function applyCoversAnnotationFilter(&$data, $id)
 {
     if ($id instanceof PHPUnit_Framework_TestCase) {
         $testClassName = get_class($id);
         $linesToBeCovered = PHP_CodeCoverage_Util::getLinesToBeCovered($testClassName, $id->getName());
         if ($this->mapTestClassNameToCoveredClassName && empty($linesToBeCovered)) {
             $testedClass = substr($testClassName, 0, -4);
             if (class_exists($testedClass)) {
                 $class = new ReflectionClass($testedClass);
                 $linesToBeCovered = array($class->getFileName() => range($class->getStartLine(), $class->getEndLine()));
             }
         }
     } else {
         $linesToBeCovered = array();
     }
     if (!empty($linesToBeCovered)) {
         $data = array_intersect_key($data, $linesToBeCovered);
         foreach (array_keys($data) as $filename) {
             $data[$filename] = array_intersect_key($data[$filename], array_flip($linesToBeCovered[$filename]));
         }
     } else {
         if ($this->forceCoversAnnotation) {
             $data = array();
         }
     }
 }
开发者ID:reflectivedevelopment,项目名称:jfh-lib,代码行数:32,代码来源:CodeCoverage.php


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