public function testToXpath() { $combinators = array(' ' => "h1/descendant::p", '>' => "h1/p", '+' => "h1/following-sibling::*[name() = 'p' and (position() = 1)]", '~' => "h1/following-sibling::p"); // h1 ?? p $element1 = new ElementNode('*', 'h1'); $element2 = new ElementNode('*', 'p'); foreach ($combinators as $combinator => $xpath) { $combinator = new CombinedSelectorNode($element1, $combinator, $element2); $this->assertEquals($xpath, (string) $combinator->toXpath(), '->toXpath() returns the xpath representation of the node'); } }
/** * @param Node\CombinedSelectorNode $node * * @return XPathExpr */ public function translateCombinedSelector(Node\CombinedSelectorNode $node) { return $this->translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector()); }