php-src/ext/dom/tests/DOMNode_insertBefore_error4.phpt
Antonio Diaz Ruiz 92bbe6be72 Includes 5 new phpTests to check that the error message DOM_NOT_FOUND is properly raised by the method DOMNode::insertBefore(newNode, [refNode]).
Each file covers a different test case

    DOMNode_insertBefore_error2.phpt: refNode is a sibling of the node where newNode wanted to be inserted.
    DOMNode_insertBefore_error3.phpt: refNode is the parent of the node where newNode wanted to be inserted.
    DOMNode_insertBefore_error4.phpt: refNode is a brand new node.
    DOMNode_insertBefore_error5.phpt: refNode is a descendant (not child) of the node where newNode wanted to be inserted.
    DOMNode_insertBefore_error6.phpt: refNode is the node where newNode wanted to be inserted.
2013-04-21 11:05:59 +08:00

39 lines
924 B
PHP

--TEST--
Test DOMNode::insertBefore() check the error code DOM_NOT_FOUND is raised
--DESCRIPTION--
DOMNode::insertBefore(newNode, [refNode])
DOM_NOT_FOUND is raised if refnode is not a child
This test checks the error message is raised when the refnode is a brand new node
--CREDITS--
Antonio Diaz Ruiz <dejalatele@gmail.com>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$dom = new DOMDocument();
$doc = $dom->load(dirname(__FILE__) . "/book.xml", LIBXML_NOBLANKS);
assert('$doc === true');
$parent_node = $dom->getElementsByTagName("book")->item(0);
assert('!is_null($parent_node)');
$new_node = $dom->createElement('newnode');
assert('$new_node !== false');
// could be a brand new node
$ref_node = $dom->createElement('newnode2');
try {
$parent_node->insertBefore($new_node, $ref_node);
} catch(DOMException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Not Found Error