Пример #1
0
 /**
  * @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
0
 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');
 }
Пример #3
0
    /**
     * @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
0
 /**
  * Merges the data from another instance of PHP_CodeCoverage.
  *
  * @param PHP_CodeCoverage $that
  */
 public function merge(PHP_CodeCoverage $that)
 {
     foreach ($that->data as $file => $lines) {
         if (!isset($this->data[$file])) {
             if (!$this->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());
 }
Пример #5
0
 /**
  * @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);
 }
Пример #6
0
 /**
  * Merges the data from another instance of PHP_CodeCoverage.
  *
  * @param PHP_CodeCoverage $that
  * @param boolean          $matchPaths
  */
 public function merge(PHP_CodeCoverage $that, $matchPaths = FALSE)
 {
     if ($matchPaths) {
         $thatData = $this->matchPaths($that->checksums, $that->data);
     } else {
         $thatData = $that->data;
     }
     foreach ($that->data as $file => $lines) {
         if (!isset($this->data[$file])) {
             if (!$this->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());
 }