1--TEST--
2Test clone with conflicting namespace prefix
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\XMLDocument::createFromString(<<<XML
9<?xml version="1.0"?>
10<root>
11    <a:root1 xmlns:a="urn:a">
12        <a:root2 xmlns:a="urn:b">
13            <a:child xmlns:b="urn:b">
14                <b:child1 xmlns:a="urn:x">bar</b:child1>
15            </a:child>
16        </a:root2>
17    </a:root1>
18</root>
19XML);
20
21$dom->documentElement->firstElementChild->setAttributeNS("urn:y", "a:foo", "bar");
22
23echo $dom->saveXml(), "\n";
24
25$clone = clone $dom->documentElement->firstElementChild;
26var_dump($clone->nodeName, $clone->namespaceURI);
27
28foreach ($clone->attributes as $attr) {
29    var_dump($attr->name, $attr->namespaceURI);
30}
31
32echo $dom->saveXml($clone), "\n";
33
34?>
35--EXPECT--
36<?xml version="1.0" encoding="UTF-8"?>
37<root>
38    <a:root1 xmlns:a="urn:a" xmlns:ns1="urn:y" ns1:foo="bar">
39        <a:root2 xmlns:a="urn:b">
40            <a:child xmlns:b="urn:b">
41                <b:child1 xmlns:a="urn:x">bar</b:child1>
42            </a:child>
43        </a:root2>
44    </a:root1>
45</root>
46string(7) "a:root1"
47string(5) "urn:a"
48string(7) "xmlns:a"
49string(29) "http://www.w3.org/2000/xmlns/"
50string(5) "a:foo"
51string(5) "urn:y"
52<a:root1 xmlns:a="urn:a" xmlns:ns1="urn:y" ns1:foo="bar">
53        <a:root2 xmlns:a="urn:b">
54            <a:child xmlns:b="urn:b">
55                <b:child1 xmlns:a="urn:x">bar</b:child1>
56            </a:child>
57        </a:root2>
58    </a:root1>
59