/**
  * Called when a test run finishes.
  *
  * @param   unittest.TestSuite suite
  * @param   unittest.TestResult result
  */
 public function testRunFinished(\unittest\TestSuite $suite, TestResult $result)
 {
     $coverage = xdebug_get_code_coverage();
     xdebug_stop_code_coverage();
     $results = array();
     foreach ($coverage as $fileName => $data) {
         foreach ($this->paths as $path) {
             if (substr($fileName, 0, strlen($path)) !== $path) {
                 continue;
             }
             $results[dirname($fileName)][basename($fileName)] = $data;
             break;
         }
     }
     $pathsNode = new Node('paths');
     foreach ($results as $pathName => $files) {
         $pathNode = new Node('path');
         $pathNode->setAttribute('name', $pathName);
         foreach ($files as $fileName => $data) {
             $fileNode = new Node('file');
             $fileNode->setAttribute('name', $fileName);
             $num = 1;
             $reader = new TextReader(new FileInputStream($pathName . '/' . $fileName));
             while (($line = $reader->readLine()) !== null) {
                 $lineNode = new Node('line', new CData($line));
                 if (isset($data[$num])) {
                     if (1 === $data[$num]) {
                         $lineNode->setAttribute('checked', 'checked');
                     } elseif (-1 === $data[$num]) {
                         $lineNode->setAttribute('unchecked', 'unchecked');
                     }
                 }
                 $fileNode->addChild($lineNode);
                 ++$num;
             }
             $pathNode->addChild($fileNode);
         }
         $pathsNode->addChild($pathNode);
     }
     $pathsNode->setAttribute('time', date('Y-m-d H:i:s'));
     $this->processor->setXMLBuf($pathsNode->getSource());
     $this->processor->run();
     FileUtil::setContents(new File($this->reportFile), $this->processor->output());
 }
示例#2
0
 /**
  * Create node for XML feed
  *
  * @param  xml.Node n
  */
 public function visit(\xml\Node $n)
 {
     $n->setAttribute('url', $this->url);
     $this->lastModified && $n->setAttribute('last-modified', $this->lastModified->toString('r'));
 }