Files
php-src/ext/dom/tests/DOM4_ParentNode_append_wrong_document.phpt

32 lines
651 B
PHP

--TEST--
DOMParentNode::append() with DOMNode from wrong document throws exception
--EXTENSIONS--
dom
--FILE--
<?php
require_once("dom_test.inc");
function test($method) {
$dom1 = new DOMDocument;
$dom1->loadXML('<test/>');
$dom2 = new DOMDocument;
$dom2->loadXML('<test><foo /></test>');
$element = $dom1->documentElement;
try {
$element->$method($dom2->documentElement->firstChild);
echo "FAIL";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
}
test("append");
test("prepend");
?>
--EXPECT--
DOMException: Wrong Document Error
DOMException: Wrong Document Error