public function testToXpath() { // h1.foo $element = new ElementNode('*', 'h1'); $class = new ClassNode($element, 'foo'); $this->assertEquals("h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", (string) $class->toXpath(), '->toXpath() returns the xpath representation of the node'); }
/** * @param Node\ClassNode $node * * @return XPathExpr */ public function translateClass(Node\ClassNode $node) { $xpath = $this->translator->nodeToXPath($node->getSelector()); return $this->translator->addAttributeMatching($xpath, '~=', '@class', $node->getName()); }