1--TEST--
2DOMNamedNodeMap::getNamedItem()
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\HTMLDocument::createFromString(<<<HTML
9<!DOCTYPE html>
10<html>
11<head>
12    <title>Test</title>
13</head>
14<body align="foo" foo:bar="baz">
15</body>
16</html>
17HTML);
18
19echo "--- On HTML document ---\n";
20
21$body = $dom->getElementsByTagName('body')->item(0);
22$body->setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:foo", "http://example.com/foo");
23$attributes = $body->attributes;
24
25var_dump($attributes->getNamedItem("FOO:BAR")->value);
26var_dump($attributes->getNamedItem("foo:BAR")->value);
27var_dump($attributes->getNamedItem("foo:bar")->value);
28var_dump($attributes->getNamedItem("XmLnS:foo")->value);
29var_dump($attributes->getNamedItem("xmlns:foo")->value);
30
31var_dump($attributes["FOO:BAR"]->value);
32var_dump($attributes["foo:BAR"]->value);
33var_dump($attributes["foo:bar"]->value);
34var_dump($attributes["XmLnS:foo"]->value);
35var_dump($attributes["xmlns:foo"]->value);
36
37echo "--- On XML document ---\n";
38
39$dom = Dom\XMLDocument::createEmpty();
40$dom->appendChild($dom->importNode($body, true));
41
42$body = $dom->getElementsByTagName('body')->item(0);
43$attributes = $body->attributes;
44
45var_dump($attributes->getNamedItem("FOO:BAR"));
46var_dump($attributes->getNamedItem("foo:BAR"));
47var_dump($attributes->getNamedItem("foo:bar")->value);
48var_dump($attributes->getNamedItem("XmLnS:foo"));
49var_dump($attributes->getNamedItem("xmlns:foo")->value);
50
51var_dump($attributes["FOO:BAR"]);
52var_dump($attributes["foo:BAR"]);
53var_dump($attributes["foo:bar"]->value);
54var_dump($attributes["XmLnS:foo"]);
55var_dump($attributes["xmlns:foo"]->value);
56
57?>
58--EXPECT--
59--- On HTML document ---
60string(3) "baz"
61string(3) "baz"
62string(3) "baz"
63string(22) "http://example.com/foo"
64string(22) "http://example.com/foo"
65string(3) "baz"
66string(3) "baz"
67string(3) "baz"
68string(22) "http://example.com/foo"
69string(22) "http://example.com/foo"
70--- On XML document ---
71NULL
72NULL
73string(3) "baz"
74NULL
75string(22) "http://example.com/foo"
76NULL
77NULL
78string(3) "baz"
79NULL
80string(22) "http://example.com/foo"
81