xref: /PHP-8.3/ext/dom/tests/gh12870_b.phpt (revision e658f805)
1--TEST--
2GH-12870 (Creating an xmlns attribute results in a DOMException) - xml variations
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8require __DIR__ . '/gh12870.inc';
9
10echo "=== NORMAL CASES ===\n";
11
12test('http://www.w3.org/XML/1998/namespaceqx', 'foo:xml');
13test('http://www.w3.org/XML/1998/namespace', 'xml');
14test('http://www.w3.org/XML/1998/namespace', 'bar:xml');
15test('', 'xml');
16test('http://www.w3.org/XML/1998/namespacea', 'xml');
17
18echo "=== ERROR CASES ===\n";
19
20test('http://www.w3.org/XML/1998/namespace', 'xmlns:xml');
21test('http://www.w3.org/XML/1998/namespace', '');
22test('http://www.w3.org/XML/1998/namespacea', 'xml:foo');
23test(NULL, 'xml:foo');
24
25?>
26--EXPECT--
27=== NORMAL CASES ===
28--- Testing "http://www.w3.org/XML/1998/namespaceqx", "foo:xml" ---
29Attr prefix: string(3) "foo"
30Attr namespaceURI: string(38) "http://www.w3.org/XML/1998/namespaceqx"
31Attr value: string(0) ""
32root namespaceURI: NULL
33Equality check: bool(true)
34<?xml version="1.0"?>
35<root xmlns:foo="http://www.w3.org/XML/1998/namespaceqx" foo:xml=""/>
36
37--- Testing "http://www.w3.org/XML/1998/namespace", "xml" ---
38Attr prefix: string(3) "xml"
39Attr namespaceURI: string(36) "http://www.w3.org/XML/1998/namespace"
40Attr value: string(0) ""
41root namespaceURI: NULL
42Equality check: bool(true)
43<?xml version="1.0"?>
44<root xml:xml=""/>
45
46--- Testing "http://www.w3.org/XML/1998/namespace", "bar:xml" ---
47Attr prefix: string(3) "xml"
48Attr namespaceURI: string(36) "http://www.w3.org/XML/1998/namespace"
49Attr value: string(0) ""
50root namespaceURI: NULL
51Equality check: bool(true)
52<?xml version="1.0"?>
53<root xml:xml=""/>
54
55--- Testing "", "xml" ---
56Attr prefix: string(0) ""
57Attr namespaceURI: NULL
58Attr value: string(0) ""
59root namespaceURI: NULL
60Equality check: bool(false)
61<?xml version="1.0"?>
62<root xml=""/>
63
64--- Testing "http://www.w3.org/XML/1998/namespacea", "xml" ---
65Attr prefix: string(7) "default"
66Attr namespaceURI: string(37) "http://www.w3.org/XML/1998/namespacea"
67Attr value: string(0) ""
68root namespaceURI: NULL
69Equality check: bool(true)
70<?xml version="1.0"?>
71<root xmlns:default="http://www.w3.org/XML/1998/namespacea" default:xml=""/>
72
73=== ERROR CASES ===
74--- Testing "http://www.w3.org/XML/1998/namespace", "xmlns:xml" ---
75Exception: Namespace Error
76
77--- Testing "http://www.w3.org/XML/1998/namespace", "" ---
78Exception: Namespace Error
79
80--- Testing "http://www.w3.org/XML/1998/namespacea", "xml:foo" ---
81Exception: Namespace Error
82
83--- Testing NULL, "xml:foo" ---
84Exception: Namespace Error
85