1--TEST--
2Element::hasAttributeNS()
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\HTMLDocument::createFromString('<!DOCTYPE html><html><body align="foo" foo:bar="baz"></body></html>');
9$body = $dom->getElementsByTagName("body")[0];
10
11echo "--- After parsing, i.e. without namespace ---\n";
12
13// Every pair of 2 calls should return the same result
14var_dump($body->hasAttributeNS(NULL, "align"));
15var_dump($body->hasAttributeNS("", "align"));
16var_dump($body->hasAttributeNS(NULL, "ALIGN"));
17var_dump($body->hasAttributeNS("", "ALIGN"));
18var_dump($body->hasAttributeNS(NULL, "foo:bar"));
19var_dump($body->hasAttributeNS("", "foo:bar"));
20var_dump($body->hasAttributeNS(NULL, "FOO:BAR"));
21var_dump($body->hasAttributeNS("", "FOO:BAR"));
22
23echo "--- Special legacy case ---\n";
24
25var_dump($dom->documentElement->hasAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns"));
26
27echo "--- Get after creating without namespace ---\n";
28
29$body->setAttributeNode($attr = $dom->createAttribute("prefix:local"));
30$attr->value = "A";
31var_dump($body->hasAttributeNS(NULL, "prefix:local"));
32var_dump($body->hasAttributeNS(NULL, "prefix:LOCAL"));
33
34echo "--- Get after creating with namespace ---\n";
35
36$body->setAttributeNode($attr = $dom->createAttributeNS("urn:a", "prefix:local2"));
37$attr->value = "B";
38var_dump($body->hasAttributeNS("urn:a", "local2"));
39var_dump($body->hasAttributeNS("urn:a", "LOCAL2"));
40
41?>
42--EXPECT--
43--- After parsing, i.e. without namespace ---
44bool(true)
45bool(true)
46bool(false)
47bool(false)
48bool(true)
49bool(true)
50bool(false)
51bool(false)
52--- Special legacy case ---
53bool(false)
54--- Get after creating without namespace ---
55bool(true)
56bool(false)
57--- Get after creating with namespace ---
58bool(true)
59bool(false)
60