1--TEST--
2Element::setAttribute() with namespace
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8require __DIR__ . "/dump_attr.inc";
9
10$dom = Dom\HTMLDocument::createEmpty();
11$container = $dom->appendChild($dom->createElementNS("urn:a", "container"));
12
13$attrs = [];
14
15function setAttribute($container, string $name, string $value): Dom\Attr {
16    $container->setAttribute($name, $value);
17    return $container->getAttributeNode($name);
18}
19
20$attrs[] = setAttribute($container, "foo:bar", "&hello1");
21echo $dom->saveHtml($container), "\n";
22$attrs[] = setAttribute($container, "foo:bar", "&hello2");
23echo $dom->saveHtml($container), "\n";
24$attrs[] = setAttribute($container, "bar", "&hello3");
25echo $dom->saveHtml($container), "\n";
26$attrs[] = setAttribute($container, "xmlns", "&hello4");
27echo $dom->saveHtml($container), "\n";
28$attrs[] = setAttribute($container, "XMLns", "&hello5");
29echo $dom->saveHtml($container), "\n";
30$attrs[] = setAttribute($container, "BAR", "&hello6");
31echo $dom->saveHtml($container), "\n";
32
33$container->setAttributeNode($dom->createAttributeNS("urn:b", "in:ns"));
34$attrs[] = setAttribute($container, "in:ns", "&hello7");
35echo $dom->saveHtml($container), "\n";
36
37// Dump at the end to check whether they influenced each other
38foreach ($attrs as $attr) {
39    dumpAttr($attr);
40}
41
42?>
43--EXPECT--
44<container foo:bar="&amp;hello1"></container>
45<container foo:bar="&amp;hello2"></container>
46<container foo:bar="&amp;hello2" bar="&amp;hello3"></container>
47<container foo:bar="&amp;hello2" bar="&amp;hello3" xmlns="&amp;hello4"></container>
48<container foo:bar="&amp;hello2" bar="&amp;hello3" xmlns="&amp;hello4" XMLns="&amp;hello5"></container>
49<container foo:bar="&amp;hello2" bar="&amp;hello3" xmlns="&amp;hello4" XMLns="&amp;hello5" BAR="&amp;hello6"></container>
50<container foo:bar="&amp;hello2" bar="&amp;hello3" xmlns="&amp;hello4" XMLns="&amp;hello5" BAR="&amp;hello6" in:ns="&amp;hello7"></container>
51Attr: foo:bar
52NULL
53string(7) "foo:bar"
54NULL
55Attr: foo:bar
56NULL
57string(7) "foo:bar"
58NULL
59Attr: bar
60NULL
61string(3) "bar"
62NULL
63Attr: xmlns
64NULL
65string(5) "xmlns"
66NULL
67Attr: XMLns
68NULL
69string(5) "XMLns"
70NULL
71Attr: BAR
72NULL
73string(3) "BAR"
74NULL
75Attr: in:ns
76string(2) "in"
77string(5) "in:ns"
78string(5) "urn:b"
79