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