本文整理汇总了PHP中PHP_CodeCoverage::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeCoverage::getData方法的具体用法?PHP PHP_CodeCoverage::getData怎么用?PHP PHP_CodeCoverage::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_CodeCoverage
的用法示例。
在下文中一共展示了PHP_CodeCoverage::getData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* @param PHP_CodeCoverage $coverage
*/
public function create(PHP_CodeCoverage $coverage)
{
$files = $coverage->getData();
$commonPath = $this->reducePaths($files);
$root = new PHP_CodeCoverage_Report_Node_Directory($commonPath, null);
$this->addItems($root, $this->buildDirectoryStructure($files), $coverage->getTests(), $coverage->getCacheTokens());
return $root;
}
示例2: parseReport
public function parseReport(\PHP_CodeCoverage $report)
{
$classes = array();
foreach ($report->getData() as $filename => $coverage) {
try {
$classes[] = $this->parseClass($filename, $coverage);
} catch (ParserException $e) {
echo "Skipping class " . $filename . ", failed to parse\n";
}
}
return $classes;
}
示例3: process
/**
* @param PHP_CodeCoverage $coverage
* @param string $target
* @return string
*/
public function process(PHP_CodeCoverage $coverage, $target = null)
{
$filter = $coverage->filter();
$output = sprintf('<?php
$coverage = new PHP_CodeCoverage;
$coverage->setData(%s);
$coverage->setTests(%s);
$filter = $coverage->filter();
$filter->setWhitelistedFiles(%s);
return $coverage;', var_export($coverage->getData(true), 1), var_export($coverage->getTests(), 1), var_export($filter->getWhitelistedFiles(), 1));
if ($target !== null) {
return file_put_contents($target, $output);
} else {
return $output;
}
}
示例4: testMerge2
/**
* @covers PHP_CodeCoverage::getData
* @covers PHP_CodeCoverage::merge
*/
public function testMerge2()
{
$driver = $this->getMockBuilder('PHP_CodeCoverage_Driver')->setConstructorArgs(array(new PHP_CodeCoverage_Filter(), new PHP_CodeCoverage_Parser()))->getMockForAbstractClass();
$coverage = new PHP_CodeCoverage($driver, new PHP_CodeCoverage_Filter());
$coverage->merge($this->getCoverageForBankAccount());
$this->assertEquals($this->getExpectedDataArrayForBankAccount(), $coverage->getData());
}
示例5: testMerge2
/**
* @covers PHP_CodeCoverage::getData
* @covers PHP_CodeCoverage::merge
*/
public function testMerge2()
{
$coverage = new PHP_CodeCoverage($this->getMock('PHP_CodeCoverage_Driver_Xdebug'), new PHP_CodeCoverage_Filter());
$coverage->merge($this->getCoverageForBankAccount());
$this->assertEquals($this->getExpectedDataArrayForBankAccount(), $coverage->getData());
}
示例6: merge
/**
* Merges the data from another instance of PHP_CodeCoverage.
*
* @param PHP_CodeCoverage $that
*/
public function merge(PHP_CodeCoverage $that)
{
foreach ($that->getData() as $file => $lines) {
if (!isset($this->data[$file])) {
if (!$that->filter()->isFiltered($file)) {
$this->data[$file] = $lines;
}
continue;
}
foreach ($lines as $line => $data) {
if ($data !== null) {
if (!isset($this->data[$file][$line])) {
$this->data[$file][$line] = $data;
} else {
$this->data[$file][$line] = array_unique(array_merge($this->data[$file][$line], $data));
}
}
}
}
$this->tests = array_merge($this->tests, $that->getTests());
}
示例7: process
/**
* @param PHP_CodeCoverage $coverage
* @param string $target
*/
public function process(PHP_CodeCoverage $coverage, $target)
{
$target = PHP_CodeCoverage_Util::getDirectory($target);
$files = $coverage->getData();
$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, $coverage->getTests());
$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);
}
示例8: 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('coverage');
$root->setAttribute('generated', (int) $_SERVER['REQUEST_TIME']);
$document->appendChild($root);
$project = $document->createElement('project');
$project->setAttribute('timestamp', (int) $_SERVER['REQUEST_TIME']);
if (is_string($name)) {
$project->setAttribute('name', $name);
}
$root->appendChild($project);
$files = $coverage->getData();
$packages = array();
$projectStatistics = array('files' => 0, 'loc' => 0, 'ncloc' => 0, 'classes' => 0, 'methods' => 0, 'coveredMethods' => 0, 'conditionals' => 0, 'coveredConditionals' => 0, 'statements' => 0, 'coveredStatements' => 0);
foreach ($files as $filename => $data) {
$namespace = 'global';
if (file_exists($filename)) {
$fileStatistics = array('classes' => 0, 'methods' => 0, 'coveredMethods' => 0, 'conditionals' => 0, 'coveredConditionals' => 0, 'statements' => 0, 'coveredStatements' => 0);
$file = $document->createElement('file');
$file->setAttribute('name', $filename);
if ($this->cacheTokens) {
$tokens = PHP_Token_Stream_CachingFactory::get($filename);
} else {
$tokens = new PHP_Token_Stream($filename);
}
$classesInFile = $tokens->getClasses();
$linesOfCode = $tokens->getLinesOfCode();
unset($tokens);
$ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored($filename, $this->cacheTokens);
$lines = array();
foreach ($classesInFile as $className => $_class) {
$classStatistics = array('methods' => 0, 'coveredMethods' => 0, 'conditionals' => 0, 'coveredConditionals' => 0, 'statements' => 0, 'coveredStatements' => 0);
foreach ($_class['methods'] as $methodName => $method) {
$classStatistics['methods']++;
$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($files[$filename][$i])) {
if ($files[$filename][$i] !== NULL) {
$classStatistics['statements']++;
$methodLines++;
} else {
$add = FALSE;
}
$count = count($files[$filename][$i]);
if ($count > 0) {
$classStatistics['coveredStatements']++;
$methodLinesCovered++;
}
} else {
$add = FALSE;
}
$methodCount = max($methodCount, $count);
if ($add) {
$lines[$i] = array('count' => $count, 'type' => 'stmt');
}
}
if ($methodCount > 0) {
$classStatistics['coveredMethods']++;
}
$lines[$method['startLine']] = array('count' => $methodCount, 'crap' => PHP_CodeCoverage_Util::crap($method['ccn'], PHP_CodeCoverage_Util::percent($methodLinesCovered, $methodLines)), 'type' => 'method', 'name' => $methodName);
}
$package = PHP_CodeCoverage_Util::getPackageInformation($className, $_class['docblock']);
if (!empty($package['namespace'])) {
$namespace = $package['namespace'];
}
$class = $document->createElement('class');
$class->setAttribute('name', $className);
$class->setAttribute('namespace', $namespace);
if (!empty($package['fullPackage'])) {
$class->setAttribute('fullPackage', $package['fullPackage']);
}
if (!empty($package['category'])) {
$class->setAttribute('category', $package['category']);
}
if (!empty($package['package'])) {
$class->setAttribute('package', $package['package']);
}
if (!empty($package['subpackage'])) {
$class->setAttribute('subpackage', $package['subpackage']);
}
$file->appendChild($class);
$metrics = $document->createElement('metrics');
$metrics->setAttribute('methods', $classStatistics['methods']);
$metrics->setAttribute('coveredmethods', $classStatistics['coveredMethods']);
$metrics->setAttribute('conditionals', $classStatistics['conditionals']);
//.........这里部分代码省略.........