summaryrefslogtreecommitdiff
path: root/ext/dom/tests/DOM4_ChildNode_wrong_document.phpt
blob: dc16cc158fc5f0df9632f82e1ed3369709158466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--TEST--
DOMChildNode::after(), before, replaceWith with DOMNode from wrong document throws exception
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
require_once("dom_test.inc");

$dom1 = new DOMDocument;
$dom1->loadXML('<test/>');

$dom2 = new DOMDocument;
$dom2->loadXML('<test><foo /></test>');

$element = $dom1->documentElement;

try {
    $element->after($dom2->documentElement->firstChild);
    echo "FAIL";
} catch (DOMException $e) {
    echo $e->getMessage() . "\n";
}

try {
    $element->before($dom2->documentElement->firstChild);
    echo "FAIL";
} catch (DOMException $e) {
    echo $e->getMessage() . "\n";
}

try {
    $element->replaceWith($dom2->documentElement->firstChild);
    echo "FAIL";
} catch (DOMException $e) {
    echo $e->getMessage();
}
?>
--EXPECT--
Wrong Document Error
Wrong Document Error
Wrong Document Error