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--INI-- 10assert.bail=true 11--SKIPIF-- 12<?php include('skipif.inc'); ?> 13--FILE-- 14<?php 15$dom = new DOMDocument(); 16 17$doc = $dom->load(dirname(__FILE__) . "/book.xml", LIBXML_NOBLANKS); 18assert($doc === true); 19 20$parent_node = $dom->getElementsByTagName("book")->item(0); 21assert(!is_null($parent_node)); 22 23$new_node = $dom->createElement('newnode'); 24assert($new_node !== false); 25 26// creating a new node (descendant) and getting it as the refnode 27 28$ref_node = $dom->createElement('newnode3'); 29$parent_node->childNodes->item(0)->appendChild($ref_node); 30$dom->saveXML(); 31 32try { 33 $parent_node->insertBefore($new_node, $ref_node); 34} catch(DOMException $e) { 35 echo $e->getMessage(); 36} 37 38?> 39--EXPECT-- 40Not Found Error 41