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
 /**
  * Retrieve name of an identifier attribute for a node
  *
  * @param string $nodeXpath
  * @return string|null
  */
 public function getIdAttribute($nodeXpath)
 {
     foreach ($this->idAttributes as $pathPattern => $idAttribute) {
         if ($this->nodePathMatcher->match($pathPattern, $nodeXpath)) {
             return $idAttribute;
         }
     }
     return null;
 }
 /**
  * Retrieve name of array key attribute, if a node is an associative array
  *
  * @param string $nodeXpath
  * @return string|null
  */
 public function getAssocArrayKeyAttribute($nodeXpath)
 {
     foreach ($this->assocArrays as $pathPattern => $keyAttribute) {
         if ($this->nodePathMatcher->match($pathPattern, $nodeXpath)) {
             return $keyAttribute;
         }
     }
     return null;
 }
示例#4
0
 /**
  * @param string $pathPattern
  * @param string $xpathSubject
  * @param boolean $expectedResult
  *
  * @dataProvider getNodeInfoDataProvider
  */
 public function testMatch($pathPattern, $xpathSubject, $expectedResult)
 {
     $actualResult = $this->_model->match($pathPattern, $xpathSubject);
     $this->assertSame($expectedResult, $actualResult);
 }