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