xref: /PHP-8.2/ext/dom/tests/gh11906.phpt (revision d19e4da1)
1--TEST--
2GH-11906 (prepend without children after creating fragment results in segfault)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$doc = new DOMDocument;
8$doc->loadXML(<<<XML
9<?xml version="1.0"?>
10<container>
11    <child/>
12</container>
13XML);
14
15$container = $doc->documentElement;
16$child = $container->firstElementChild;
17
18$test = $doc->createElement('foo');
19$test->append($child);
20echo "--- document output ---\n";
21echo $doc->saveXML();
22echo "--- \$test output ---\n";
23echo $doc->saveXML($test), "\n";
24$test->prepend($child);
25echo "--- document output ---\n";
26echo $doc->saveXML();
27echo "--- \$test output ---\n";
28echo $doc->saveXML($test), "\n";
29$test->append($child);
30?>
31--EXPECT--
32--- document output ---
33<?xml version="1.0"?>
34<container>
35
36</container>
37--- $test output ---
38<foo><child/></foo>
39--- document output ---
40<?xml version="1.0"?>
41<container>
42
43</container>
44--- $test output ---
45<foo><child/></foo>
46