--TEST--
Bug #81642 (DOMChildNode::replaceWith() bug when replacing a node with itself)
--EXTENSIONS--
dom
--FILE--
appendChild($target = $doc->createElement('test'));
$target->replaceWith($target);
var_dump($doc->saveXML());
// Replace with itself + another element
$doc = new DOMDocument();
$doc->appendChild($target = $doc->createElement('test'));
$target->replaceWith($target, $doc->createElement('foo'));
var_dump($doc->saveXML());
// Replace with text node
$doc = new DOMDocument();
$doc->appendChild($target = $doc->createElement('test'));
$target->replaceWith($target, 'foo');
var_dump($doc->saveXML());
// Replace with text node variant 2
$doc = new DOMDocument();
$doc->appendChild($target = $doc->createElement('test'));
$target->replaceWith('bar', $target, 'foo');
var_dump($doc->saveXML());
?>
--EXPECT--
string(30) "
"
string(37) "
"
string(34) "
foo
"
string(38) "
bar
foo
"