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); }
/** * @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); }
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, ''); }
/** * @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); }
/** * @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'); }
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]; }
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); } }
/** * @param \TheSeer\fDOM\fDOMDocument $dom */ public function import(fDOMDocument $dom) { $this->dom = $dom; $this->rootNode = $dom->documentElement; $this->dom->registerNamespace('phpdox', self::XMLNS); }
/** * @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); } }
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)); }
/** * @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); } }
/** * @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; }
/** * @param fDOMDocument $document */ public function __construct(fDOMDocument $document) { $document->registerNamespace('src', AbstractUnitObject::XMLNS); $this->document = $document; }
protected function loadDataFile($filename) { $classDom = new fDOMDocument(); $classDom->load($this->xmlDir . '/' . $filename); $classDom->registerNamespace('phpdox', 'http://xml.phpdox.net/src#'); return $classDom; }
/** * @param fDOMDocument $index * @param string $buildDirectory */ public function __construct(fDOMDocument $index, $buildDirectory) { $index->registerNamespace('src', AbstractUnitObject::XMLNS); $this->index = $index; $this->buildDirectory = $buildDirectory; }