本文整理汇总了PHP中TheSeer\fDOM\fDOMDocument::getDOMXPath方法的典型用法代码示例。如果您正苦于以下问题:PHP fDOMDocument::getDOMXPath方法的具体用法?PHP fDOMDocument::getDOMXPath怎么用?PHP fDOMDocument::getDOMXPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TheSeer\fDOM\fDOMDocument
的用法示例。
在下文中一共展示了fDOMDocument::getDOMXPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCloningTriggersCreationOfNewDOMXPathInstance
/**
* @covers \TheSeer\fDOM\fDOMDocument::__clone
*/
public function testCloningTriggersCreationOfNewDOMXPathInstance()
{
$this->dom->loadXML('<?xml version="1.0" ?><test />');
$xp1 = $this->dom->getDOMXPath();
$clone = clone $this->dom;
$xp2 = $clone->getDOMXPath();
$this->assertNotSame($xp2, $xp1);
}
示例2: processUnit
private function processUnit(fDOMDocument $unit, fDOMDocument $coverage)
{
$enrichment = $this->getEnrichtmentContainer($unit->documentElement, 'phpunit');
$className = $unit->documentElement->getAttribute('name');
$classNamespace = $unit->documentElement->getAttribute('namespace');
$classNode = $coverage->queryOne(sprintf('//pu:class[@name = "%s" and pu:namespace[@name = "%s"]]', $className, $classNamespace));
if (!$classNode) {
// This class seems to be newer than the last phpunit run
return;
}
$coverageTarget = $enrichment->appendElementNS(self::XMLNS, 'coverage');
foreach (array('executable', 'executed', 'crap') as $attr) {
$coverageTarget->appendChild($coverageTarget->ownerDocument->importNode($classNode->getAttributeNode($attr)));
}
$result = array('PASSED' => 0, 'SKIPPED' => 0, 'INCOMPLETE' => 0, 'FAILURE' => 0, 'ERROR' => 0, 'RISKY' => 0);
$methods = $unit->query('/phpdox:*/phpdox:constructor|/phpdox:*/phpdox:destructor|/phpdox:*/phpdox:method');
$xp = $this->index->getDOMXPath();
foreach ($methods as $method) {
$start = $method->getAttribute('start');
$end = $method->getAttribute('end');
$enrichment = $this->getEnrichtmentContainer($method, 'phpunit');
$coverageTarget = $enrichment->appendElementNS(self::XMLNS, 'coverage');
/** @var fDOMElement $coverageMethod */
$coverageMethod = $coverage->queryOne(sprintf('//pu:method[@start = "%d" and @end = "%d"]', $start, $end));
if ($coverageMethod != NULL) {
foreach (array('executable', 'executed', 'coverage', 'crap') as $attr) {
$coverageTarget->appendChild($coverageTarget->ownerDocument->importNode($coverageMethod->getAttributeNode($attr)));
}
}
$coveredNodes = $coverage->query(sprintf('//pu:coverage/pu:line[@nr >= "%d" and @nr <= "%d"]/pu:covered', $start, $end));
$seen = array();
foreach ($coveredNodes as $coveredNode) {
$by = $coveredNode->getAttribute('by');
if (isset($seen[$by])) {
continue;
}
$seen[$by] = true;
$name = $xp->prepare(':name', array('name' => $by));
$test = $coverageTarget->appendChild($unit->importNode($this->index->queryOne(sprintf('//pu:tests/pu:test[@name = %s]', $name))));
$result[$test->getAttribute('status')]++;
}
}
if (!isset($this->results[$classNamespace])) {
$this->results[$classNamespace] = array();
$this->coverage[$classNamespace] = array();
}
$this->results[$classNamespace][$className] = $result;
$this->coverage[$classNamespace][$className] = $coverageTarget->cloneNode(false);
}
示例3: parse
/**
* @param string $xpath
* @return array
*/
public function parse($xpath = '')
{
$result = array('items' => array(), 'excludes' => array(), 'names' => array());
foreach ($this->xml->getDOMXPath()->query($xpath . 'include/directory') as $item) {
$result['items'][] = $this->toAbsolutePath($item->nodeValue);
}
foreach ($this->xml->getDOMXPath()->query($xpath . 'include/file') as $item) {
$result['items'][] = $this->toAbsolutePath($item->nodeValue);
}
foreach ($this->xml->getDOMXPath()->query($xpath . 'exclude') as $exclude) {
$result['excludes'][] = $exclude->nodeValue;
}
foreach ($this->xml->getDOMXPath()->query($xpath . 'name') as $name) {
$result['names'][] = $name->nodeValue;
}
return $result;
}
示例4: setUp
public function setUp()
{
$this->dom = new fDOMDocument();
$this->dom->loadXML('<?xml version="1.0" ?><root><node attr="foo" /></root>');
$this->xp = $this->dom->getDOMXPath();
}