public function testText()
 {
     $html = '<div>foo</div>';
     $document = new Document($html);
     $element = new Element($document->getDocument()->documentElement);
     $this->assertEquals('foo', $element->text());
     $this->assertEquals('foo', $element->plaintext);
 }
 public function testGetDocument()
 {
     $document = new Document();
     $this->assertInstanceOf('DOMDocument', $document->getDocument());
 }
 /**
  * Replace child node
  *
  * @param $string
  *
  * @return $this
  */
 protected function replaceChild($string)
 {
     if (!empty($string)) {
         $newDocument = new Document($string);
         if ($newDocument->outertext != $string) {
             throw new RuntimeException("Not valid HTML fragment");
         }
     }
     foreach ($this->node->childNodes as $node) {
         $this->node->removeChild($node);
     }
     if (!empty($string)) {
         $newNode = $this->node->ownerDocument->importNode($newDocument->getDocument()->documentElement, true);
         $this->node->appendChild($newNode);
     }
     return $this;
 }