private function init($cfgName)
 {
     $this->version = new Version('0.0');
     $this->fileInfo = new FileInfo($this->baseDir . $cfgName . '.xml');
     $this->cfgDom = new fDOMDocument();
     $this->cfgDom->load($this->fileInfo->getPathname());
     $this->cfgDom->registerNamespace('cfg', 'http://xml.phpdox.net/config');
     $this->config = new GlobalConfig($this->version, new FileInfo('/tmp'), $this->cfgDom, $this->fileInfo);
 }
示例#2
0
 /**
  * @param string[] $units
  * @param string[] $visibilities
  * @return fDOMDocument
  */
 private function createPhpDoxConfig(array $units, array $visibilities)
 {
     $dom = new fDOMDocument();
     $dom->loadXML($this->factory->getConfigSkeleton()->renderStripped());
     $dom->registerNamespace('config', ConfigLoader::XMLNS);
     // set up silent
     $silent = $this->output->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL ? 'true' : 'false';
     $dom->queryOne('//config:phpdox')->setAttribute('silent', $silent);
     // set up directories
     $projectNode = $dom->queryOne('//config:project');
     $projectNode->setAttribute('source', $this->sourceDirectory);
     $projectNode->setAttribute('workdir', $this->buildDirectory);
     // inject flag to avoid unecessary processing according to the visibility filter
     if (1 === count($visibilities) && in_array('public', $visibilities)) {
         $collectorNode = $dom->queryOne('//config:collector');
         $projectNode->setAttribute('publiconly', 'true');
     }
     // remove current masks
     $query = "//config:collector/*[name()='include' or name()='exclude']";
     foreach ($dom->query($query) as $mask) {
         $mask->parentNode->removeChild($mask);
     }
     // append files to be parsed
     $collector = $dom->queryOne('//config:collector');
     foreach ($units as $unitFile) {
         $include = $dom->createElement('include');
         $include->setAttribute('mask', $unitFile);
         $collector->appendChild($include);
     }
     return $dom;
 }
 public function testAppendingANewElementWithinANamespaceByPrefix()
 {
     $this->dom->registerNamespace('t', 'test:uri');
     $node = $this->frag->appendElementPrefix('t', 'append', 'text');
     $this->assertInstanceOf('TheSeer\\fDOM\\fDOMElement', $node);
     $this->assertEquals(1, $this->frag->query('count(t:append)'));
     $this->assertEquals('text', $node->nodeValue);
 }
示例#4
0
 public function import(fDOMDocument $dom) {
     $dom->registerNamespace('phpdox', 'http://xml.phpdox.net/src#');
     $dir = $dom->queryOne('/phpdox:source/phpdox:dir');
     if (!$dir)  {
         return;
     }
     $this->importDirNode($dir, '');
 }
示例#5
0
 /**
  * @covers \TheSeer\fDOM\fDOMDocument::__clone
  */
 public function testRegisteredNamespacePrefixesGetCopiedToClonedDocument()
 {
     $this->dom->loadXML('<?xml version="1.0" ?><foo:test xmlns:foo="test:uri" />');
     $this->dom->registerNamespace('foo', 'test:uri');
     $clone = clone $this->dom;
     $node = $clone->queryOne('//foo:test');
     $this->assertSame($clone->documentElement, $node);
 }
示例#6
0
 /**
  * @return void
  */
 private function initCollections()
 {
     $this->source = new fDOMDocument();
     $this->source->load($this->xmlDir . '/source.xml');
     $this->source->registerNamespace('phpdox', 'http://xml.phpdox.net/src');
     $this->index = new fDOMDocument();
     $this->index->load($this->xmlDir . '/index.xml');
     $this->index->registerNamespace('phpdox', 'http://xml.phpdox.net/src');
 }
示例#7
0
 protected function loadDocument($dir)
 {
     $path = $dir . '/' . $this->getNode()->getAttribute('xml');
     if (!isset($this->dom[$path])) {
         $classDom = new fDOMDocument();
         $classDom->load($path);
         $classDom->registerNamespace('phpdox', 'http://xml.phpdox.net/src');
         $this->dom[$path] = $classDom;
     }
     return $this->dom[$path];
 }
示例#8
0
 protected function createInstanceFor($fname)
 {
     try {
         $dom = new fDOMDocument();
         $dom->load($fname);
         $root = $dom->documentElement;
         if ($root->namespaceURI == 'http://phpdox.de/config') {
             throw new ConfigLoaderException("File '{$fname}' uses an outdated xml namespace. Please update the xmlns to 'http://phpdox.net/config'", ConfigLoaderException::OldNamespace);
         }
         if ($root->namespaceURI != 'http://phpdox.net/config' || $root->localName != 'phpdox') {
             throw new ConfigLoaderException("File '{$fname}' is not a valid phpDox configuration.", ConfigLoaderException::WrongType);
         }
         $dom->registerNamespace('cfg', 'http://phpdox.net/config');
         return new GlobalConfig($dom, new FileInfo($fname));
     } catch (fDOMException $e) {
         throw new ConfigLoaderException("Parsing config file '{$fname}' failed.", ConfigLoaderException::ParseError, $e);
     }
 }
示例#9
0
 /**
  * @param \TheSeer\fDOM\fDOMDocument $dom
  */
 public function import(fDOMDocument $dom)
 {
     $this->dom = $dom;
     $this->rootNode = $dom->documentElement;
     $this->dom->registerNamespace('phpdox', self::XMLNS);
 }
示例#10
0
 /**
  * @param $fname
  *
  * @return fDOMDocument
  *
  * @throws EnricherException
  */
 private function loadXML($fname)
 {
     try {
         $fname = (string) $this->coveragePath . '/' . $fname;
         if (!file_exists($fname)) {
             throw new EnricherException(sprintf('PHPUnit xml file "%s" not found.', $fname), EnricherException::LoadError);
         }
         $dom = new fDOMDocument();
         $dom->load($fname);
         $dom->registerNamespace('pu', 'http://schema.phpunit.de/coverage/1.0');
         return $dom;
     } catch (fDOMException $e) {
         throw new EnricherException('Parsing PHPUnit xml file failed: ' . $e->getMessage(), EnricherException::LoadError);
     }
 }
示例#11
0
 public function testDocBlockWithMultipleOccurencesOfAnnotationCanBeSerializedToDom()
 {
     $dom = new fDOMDocument();
     $dom->registerNamespace('test', 'http://xml.phpdox.net/src');
     $element2 = clone $this->element;
     $this->element->expects($this->once())->method('asDom')->will($this->returnValue($dom->createElementNS('http://xml.phpdox.net/src', 'stub')));
     $element2->expects($this->once())->method('asDom')->will($this->returnValue($dom->createElementNS('http://xml.phpdox.net/src', 'stub')));
     $this->docBlock->appendElement($this->element);
     $this->docBlock->appendElement($element2);
     $node = $this->docBlock->asDom($dom);
     $this->assertEquals('<docblock xmlns="http://xml.phpdox.net/src"><stub/><stub/></docblock>', $dom->saveXML($node));
 }
示例#12
0
 /**
  * @param $fname
  *
  * @return fDOMDocument
  * @throws ConfigLoaderException
  */
 private function loadFile($fname)
 {
     try {
         $dom = new fDOMDocument();
         $dom->load($fname);
         $dom->registerNamespace('cfg', self::XMLNS);
         return $dom;
     } catch (fDOMException $e) {
         throw new ConfigLoaderException("Parsing config file '{$fname}' failed.", ConfigLoaderException::ParseError, $e);
     }
 }
示例#13
0
文件: Project.php 项目: sakshika/ATM
 /**
  * @param $fname
  *
  * @return array
  */
 private function findAffectedUnits($fname)
 {
     $affected = array();
     $dom = new fDOMDocument();
     $dom->load($this->xmlDir . '/' . $fname);
     $dom->registerNamespace('phpdox', 'http://xml.phpdox.net/src#');
     $extends = $dom->queryOne('//phpdox:extends');
     if ($extends instanceof fDOMElement) {
         try {
             $affected[$extends->getAttribute('full')] = $this->getUnitByName($extends->getAttribute('full'));
         } catch (ProjectException $e) {
         }
     }
     $implements = $dom->query('//phpdox:implements');
     foreach ($implements as $implement) {
         try {
             $affected[$implement->getAttribute('full')] = $this->getUnitByName($implement->getAttribute('full'));
         } catch (ProjectException $e) {
         }
     }
     return $affected;
 }
示例#14
0
文件: Unit.php 项目: renanbr/phpact
 /**
  * @param fDOMDocument $document
  */
 public function __construct(fDOMDocument $document)
 {
     $document->registerNamespace('src', AbstractUnitObject::XMLNS);
     $this->document = $document;
 }
示例#15
0
 protected function loadDataFile($filename)
 {
     $classDom = new fDOMDocument();
     $classDom->load($this->xmlDir . '/' . $filename);
     $classDom->registerNamespace('phpdox', 'http://xml.phpdox.net/src#');
     return $classDom;
 }
示例#16
0
 /**
  * @param fDOMDocument $index
  * @param string $buildDirectory
  */
 public function __construct(fDOMDocument $index, $buildDirectory)
 {
     $index->registerNamespace('src', AbstractUnitObject::XMLNS);
     $this->index = $index;
     $this->buildDirectory = $buildDirectory;
 }