xref: /php-src/ext/dom/tests/bug38474.phpt (revision bd9f4fa6)
1--TEST--
2Bug #38474 (getAttribute select attribute by order, even when prefixed) (OK to fail with libxml2 < 2.6.2x)
3--EXTENSIONS--
4dom
5--SKIPIF--
6<?php
7if (version_compare(LIBXML_DOTTED_VERSION, "2.6.20", "<")) {
8    print "skip libxml version " . LIBXML_DOTTED_VERSION;
9}
10?>
11--FILE--
12<?php
13$xml = '<node xmlns:pre="http://foo.com/tr/pre"
14              xmlns:post="http://foo.com/tr/post"
15              pre:type="bar" type="foo" ><sub /></node>';
16$dom = new DomDocument();
17$dom->loadXML($xml);
18echo $dom->firstChild->getAttribute('type')."\n";
19echo $dom->firstChild->getAttribute('pre:type')."\n";
20
21$dom->firstChild->setAttribute('pre:type', 'bar2');
22$dom->firstChild->setAttribute('type', 'foo2');
23$dom->firstChild->setAttribute('post:type', 'baz');
24$dom->firstChild->setAttribute('new:type', 'baz2');
25
26echo $dom->firstChild->getAttribute('type')."\n";
27echo $dom->firstChild->getAttribute('pre:type')."\n";
28echo $dom->firstChild->getAttribute('post:type')."\n";
29
30$dom->firstChild->removeAttribute('pre:type');
31$dom->firstChild->removeAttribute('type');
32
33echo $dom->firstChild->getAttribute('type')."\n";
34echo $dom->firstChild->getAttribute('pre:type')."\n";
35echo $dom->firstChild->getAttribute('post:type')."\n";
36echo $dom->firstChild->getAttribute('new:type');
37?>
38--EXPECT--
39foo
40bar
41foo2
42bar2
43baz
44
45
46baz
47baz2
48