예제 #1
0
 public function testImportNode_unchanged()
 {
     $doc = new DOMDocument();
     $node = $doc->createElement("tag");
     $newNode = \r8\XMLBuilder::importNode($doc, $node);
     $this->assertSame($newNode, $node);
 }
예제 #2
0
 /**
  * A helper function for building a node, ensuring a proper value was returned,
  * and then importing it into the document
  *
  * @param \r8\iface\XMLBuilder $builder
  * @param \DOMDocument $doc The document being built
  * @return DOMNode
  */
 public static function buildNode(\r8\iface\XMLBuilder $builder, \DOMDocument $doc)
 {
     $built = $builder->buildNode($doc);
     if (!$built instanceof \DOMNode) {
         $err = new \r8\Exception\Interaction("XMLBuilder did not return a DOMNode object");
         $err->addData("Document", \r8\getDump($doc));
         $err->addData("Built Node", \r8\getDump($built));
         throw $err;
     }
     // Ensure the built node is a member of the document
     return \r8\XMLBuilder::importNode($doc, $built);
 }