Beispiel #1
0
 /**
  * @param  bool $indent
  * @return string
  */
 public function getSource($indent = true)
 {
     return $this->getProlog() . $this->rootNode->getSource($indent);
 }
 /**
  * Compares XML after stripping all whitespace between tags of both 
  * expected and actual strings.
  *
  * @see     xp://unittest.TestCase#assertEquals
  * @param   string $expect
  * @param   xml.Node $node
  * @throws  unittest.AssertionFailedError
  */
 public function assertMarshalled($expect, $node)
 {
     $this->assertEquals(preg_replace('#>[\\s\\r\\n]+<#', '><', trim($expect)), preg_replace('#>[\\s\\r\\n]+<#', '><', trim($node->getSource(INDENT_DEFAULT))));
 }
 /**
  * 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());
 }