php-src/ext/dom/tests/DOMNode_removeChild_error1.phpt
Tim Starling 781e6b4d21
Fix O(N) performance of DOMNode::replaceChild() and DOMNode::removeChild()
Don't loop over all children to determine if the target node really is a
child, just trust the parent pointer. Add tests.
2021-09-14 15:30:34 +02:00

20 lines
519 B
PHP

--TEST--
removeChild() where the node is not a child
--EXTENSIONS--
dom
--FILE--
<?php
$document = new DOMDocument();
$real_parent = $document->createElement('real');
$parent = $document->createElement('p');
$child1 = $document->createElement('child1');
$child2 = $document->createElement('child2');
$real_parent->appendChild($child1);
$parent->appendChild($child2);
try {
$parent->removeChild($child1);
} catch (DOMException $e) {
echo "DOMException: " . $e->getMessage();
}
--EXPECT--
DOMException: Not Found Error