xref: /PHP-8.3/ext/dom/tests/gh12616_2.phpt (revision 3167d076)
1--TEST--
2GH-12616 (DOM: Removing XMLNS namespace node results in invalid default: prefix)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$doc = new DOMDocument();
9$doc->loadXML(
10    <<<XML
11    <container xmlns:test="urn:test" xmlns:symfony="http://symfony.com/schema/dic/services">
12        <symfony:services>
13            <test:service id="hello" />
14        </symfony:services>
15    </container>
16    XML
17);
18
19$doc->documentElement->removeAttributeNS('http://symfony.com/schema/dic/services', 'symfony');
20$xpath = new DOMXPath($doc);
21$xpath->registerNamespace('test', 'urn:test');
22
23echo $doc->saveXML();
24
25$result = $xpath->query('//container/services/test:service[@id="hello"]');
26var_dump($result);
27
28?>
29--EXPECT--
30<?xml version="1.0"?>
31<container xmlns:test="urn:test">
32    <services>
33        <test:service id="hello"/>
34    </services>
35</container>
36object(DOMNodeList)#4 (1) {
37  ["length"]=>
38  int(1)
39}
40