Example #1
0
 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;
                 }
             }
         }
     }
 }
Example #2
0
 public function testIsException()
 {
     $this->setExpectedException('InvalidArgumentException');
     $domElement = $this->createDomElement('input');
     $element = new Element($domElement);
     $element->is(null);
 }
Example #3
0
 public function testToString()
 {
     $element = new Element('span', 'hello');
     $this->assertEquals($element->html(), $element->__toString());
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 /**
  * 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();
 }
Example #6
0
 public function testIsException()
 {
     $this->setExpectedException('InvalidArgumentException');
     $element = new Element('span', 'hello');
     $element->is(null);
 }