public function findNextNodeByText(DiDomElement $element, $expression, $grep = false) { $childNodes = $element->getNode()->childNodes; $length = $childNodes->length; $stop = false; for ($i = 0; $i < $length; $i++) { $node = $childNodes->item($i); if ($stop && trim($node->textContent)) { $document = new DiDomDocument(); $document->appendChild($node); return $document; } else { if (!$grep && $expression == $node->textContent) { $stop = true; } else { if ($grep && preg_match($expression, $node->textContent)) { $stop = true; } } } } }
public function testIsException() { $this->setExpectedException('InvalidArgumentException'); $domElement = $this->createDomElement('input'); $element = new Element($domElement); $element->is(null); }
public function testToString() { $element = new Element('span', 'hello'); $this->assertEquals($element->html(), $element->__toString()); }
/** * Sets current \DOMElement instance. * * @param \DOMElement $node A \DOMElement instance * * @throws \LogicException If given node is not an anchor */ protected function setNode(\DOMElement $node) { if ('a' !== $node->nodeName and 'area' !== $node->nodeName and 'link' !== $node->nodeName) { throw new \LogicException(sprintf('Unable to navigate from a "%s" tag.', $node->nodeName)); } parent::setNode($node); }
/** * Constructor. * * @param \DOMElement $node The node associated with this field */ public function __construct(\DOMElement $node) { parent::__construct($node); $this->name = $node->getAttribute('name'); $this->initialize(); }
public function testIsException() { $this->setExpectedException('InvalidArgumentException'); $element = new Element('span', 'hello'); $element->is(null); }