1--TEST--
2Element::hasAttribute()
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8echo "--- Get after parsing ---\n";
9
10$dom = Dom\HTMLDocument::createFromString('<!DOCTYPE html><html><body align="foo" foo:bar="baz"></body></html>');
11$body = $dom->getElementsByTagName("body")[0];
12var_dump($body->hasAttribute("align"));
13var_dump($body->hasAttribute("foo:bar"));
14
15echo "--- Get after creating without namespace ---\n";
16
17$body->setAttributeNode($attr = $dom->createAttribute("prefix:local"));
18$attr->value = "A";
19var_dump($body->hasAttribute("prefix:local"));
20
21echo "--- Get after creating with namespace ---\n";
22
23$body->setAttributeNode($attr = $dom->createAttributeNS("urn:a", "prefix:local2"));
24$attr->value = "B";
25var_dump($body->hasAttribute("prefix:local2"));
26var_dump($body->hasAttribute("Prefix:LOCAL2"));
27
28echo "--- Get after creating with namespace case sensitive ---\n";
29
30$element = $dom->createElementNS("urn:a", "a:element");
31$attr = $dom->createAttributeNS("urn:a", "Prefix:local2");
32$element->setAttributeNode($attr);
33$attr->value = "C";
34var_dump($element->hasAttribute("Prefix:local2"));
35var_dump($element->hasAttribute("Prefix:LOCAL2"));
36var_dump($element->hasAttribute("prefix:local2"));
37
38?>
39--EXPECT--
40--- Get after parsing ---
41bool(true)
42bool(true)
43--- Get after creating without namespace ---
44bool(true)
45--- Get after creating with namespace ---
46bool(true)
47bool(true)
48--- Get after creating with namespace case sensitive ---
49bool(true)
50bool(false)
51bool(false)
52