public function testGetIdAttributeNotMatched()
 {
     $xpath = '/root/four[@attr="value"]';
     $this->nodePathMatcher->expects($this->at(0))->method('match')->with('/root/one', $xpath)->will($this->returnValue(false));
     $this->nodePathMatcher->expects($this->at(1))->method('match')->with('/root/two', $xpath)->will($this->returnValue(false));
     $this->nodePathMatcher->expects($this->at(2))->method('match')->with('/root/three', $xpath)->will($this->returnValue(false));
     $this->assertNull($this->object->getIdAttribute($xpath));
 }
Пример #2
0
 /**
  * Identify node path based on parent path and node attributes
  *
  * @param \DOMElement $node
  * @param string $parentPath
  * @return string
  */
 protected function _getNodePathByParent(\DOMElement $node, $parentPath)
 {
     $prefix = is_null($this->rootNamespace) ? '' : self::ROOT_NAMESPACE_PREFIX . ':';
     $path = $parentPath . '/' . $prefix . $node->tagName;
     $idAttribute = $this->nodeMergingConfig->getIdAttribute($path);
     if (is_array($idAttribute)) {
         $constraints = [];
         foreach ($idAttribute as $attribute) {
             $value = $node->getAttribute($attribute);
             $constraints[] = "@{$attribute}='{$value}'";
         }
         $path .= '[' . join(' and ', $constraints) . ']';
     } elseif ($idAttribute && ($value = $node->getAttribute($idAttribute))) {
         $path .= "[@{$idAttribute}='{$value}']";
     }
     return $path;
 }