1--TEST--
2Test: setAttributeNode()
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--INI--
6error_reporting = E_ALL & ~E_WARNING
7--FILE--
8<?php
9
10$xml = <<<HERE
11<?xml version="1.0" ?>
12<root a="b" />
13HERE;
14
15$xml2 = <<<HERE
16<?xml version="1.0" ?>
17<doc2 />
18HERE;
19
20$dom = new DOMDocument();
21$dom->loadXML($xml);
22$root = $dom->documentElement;
23$attr = $root->getAttributeNode('a');
24
25$dom2 = new DOMDocument();
26$dom2->loadXML($xml2);
27$root2 = $dom2->documentElement;
28try {
29	$root2->setAttributeNode($attr);
30} catch (domexception $e) {
31ob_start();
32	var_dump($e);
33	$contents = ob_get_contents();
34	ob_end_clean();
35	echo preg_replace('/object\(DOMAttr\).+\{.*?\}/s', 'DOMAttr', $contents);
36}
37
38?>
39--EXPECTF--
40object(DOMException)#%d (7) {
41  ["message":protected]=>
42  string(20) "Wrong Document Error"
43  ["string":"Exception":private]=>
44  string(0) ""
45  ["file":protected]=>
46  string(%d) "%sdom_set_attr_node.php"
47  ["line":protected]=>
48  int(%d)
49  ["trace":"Exception":private]=>
50  array(1) {
51    [0]=>
52    array(6) {
53      ["file"]=>
54      string(%d) "%sdom_set_attr_node.php"
55      ["line"]=>
56      int(%d)
57      ["function"]=>
58      string(16) "setAttributeNode"
59      ["class"]=>
60      string(10) "DOMElement"
61      ["type"]=>
62      string(2) "->"
63      ["args"]=>
64      array(1) {
65        [0]=>
66        DOMAttr
67      }
68    }
69  }
70  ["previous":"Exception":private]=>
71  NULL
72  ["code"]=>
73  int(4)
74}
75