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