1--TEST-- 2Test DOMNode::insertBefore() check the error code DOM_NOT_FOUND is raised 3--DESCRIPTION-- 4DOMNode::insertBefore(newNode, [refNode]) 5DOM_NOT_FOUND is raised if refnode is not a child 6This test checks the error message is raised when the refnode is a descendant but not a child 7--CREDITS-- 8Antonio Diaz Ruiz <dejalatele@gmail.com> 9--EXTENSIONS-- 10dom 11--FILE-- 12<?php 13$dom = new DOMDocument(); 14 15$doc = $dom->load(__DIR__ . "/book.xml", LIBXML_NOBLANKS); 16assert($doc === true); 17 18$parent_node = $dom->getElementsByTagName("book")->item(0); 19assert(!is_null($parent_node)); 20 21$new_node = $dom->createElement('newnode'); 22assert($new_node !== false); 23 24// creating a new node (descendant) and getting it as the refnode 25 26$ref_node = $dom->createElement('newnode3'); 27$parent_node->childNodes->item(0)->appendChild($ref_node); 28$dom->saveXML(); 29 30try { 31 $parent_node->insertBefore($new_node, $ref_node); 32} catch(DOMException $e) { 33 echo $e->getMessage(); 34} 35 36?> 37--EXPECT-- 38Not Found Error 39