private function processFile(PHP_CodeCoverage_Report_Node_File $file, PHP_CodeCoverage_Report_XML_Directory $context) { $fileObject = $context->addFile($file->getName(), $file->getId() . '.xml'); $this->setTotals($file, $fileObject->getTotals()); $fileReport = new PHP_CodeCoverage_Report_XML_File_Report($file->getName()); $this->setTotals($file, $fileReport->getTotals()); foreach ($file->getClassesAndTraits() as $unit) { $this->processUnit($unit, $fileReport); } foreach ($file->getFunctions() as $function) { $this->processFunction($function, $fileReport); } foreach ($file->getCoverageData() as $line => $tests) { if (!is_array($tests) || count($tests) == 0) { continue; } $coverage = $fileReport->getLineCoverage($line); foreach ($tests as $test) { $coverage->addTest($test); } $coverage->finalize(); } $this->initTargetDirectory($this->target . dirname($file->getId()) . '/'); $fileDom = $fileReport->asDom(); $fileDom->formatOutput = true; $fileDom->preserveWhiteSpace = false; $fileDom->save($this->target . $file->getId() . '.xml'); }
/** * @param PHP_CodeCoverage_Report_Node_File $node * @param string $file * @param string $title */ public function render(PHP_CodeCoverage_Report_Node_File $node, $file, $title = NULL) { if ($title === NULL) { $title = $node->getName(); } if ($this->yui) { $template = new Text_Template($this->templatePath . 'file.html'); } else { $template = new Text_Template($this->templatePath . 'file_no_yui.html'); } list($source, $yuiTemplate) = $this->renderSource($node); $template->setVar(array('items' => $this->renderItems($node), 'source' => $source, 'yuiPanelJS' => $yuiTemplate)); $this->setCommonTemplateVariables($template, $title, $node); $template->renderTo($file); }