1--TEST--
2DOMParentNode functions with empty argument
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$dom = new DOMDocument();
8$dom->loadXML('<?xml version="1.0"?><root><node/></root>');
9
10$emptyFragment = $dom->createDocumentFragment();
11
12echo "--- DOMElement test ---\n";
13
14$dom->documentElement->after(...$emptyFragment->childNodes);
15$dom->documentElement->before(...$emptyFragment->childNodes);
16$dom->documentElement->append(...$emptyFragment->childNodes);
17$dom->documentElement->prepend(...$emptyFragment->childNodes);
18$dom->documentElement->after();
19$dom->documentElement->before();
20$dom->documentElement->append();
21$dom->documentElement->prepend();
22echo $dom->saveXML();
23
24$dom->documentElement->firstChild->replaceWith(...$emptyFragment->childNodes);
25echo $dom->saveXML();
26
27$dom->documentElement->replaceWith(...$emptyFragment->childNodes);
28echo $dom->saveXML();
29
30echo "--- DOMDocumentFragment test ---\n";
31
32$fragment = $dom->createDocumentFragment();
33$fragment->append($dom->createElement('foo'));
34$fragment->append(...$emptyFragment->childNodes);
35$fragment->prepend(...$emptyFragment->childNodes);
36$fragment->append();
37$fragment->prepend();
38echo $dom->saveXML($fragment), "\n";
39
40echo "--- DOMDocument test ---\n";
41
42$dom->append(...$emptyFragment->childNodes);
43$dom->prepend(...$emptyFragment->childNodes);
44$dom->append();
45$dom->prepend();
46echo $dom->saveXML(), "\n";
47
48echo "--- DOMCharacterData test ---\n";
49
50$cdata = $dom->createCDATASection('foo');
51$dom->appendChild($cdata);
52
53$cdata->after(...$emptyFragment->childNodes);
54$cdata->before(...$emptyFragment->childNodes);
55$cdata->after();
56$cdata->before();
57echo $dom->saveXML(), "\n";
58$cdata->replaceWith(...$emptyFragment->childNodes);
59echo $dom->saveXML(), "\n";
60
61$cdata = $dom->createCDATASection('foo');
62$dom->appendChild($cdata);
63$cdata->replaceWith(...$emptyFragment->childNodes);
64echo $dom->saveXML(), "\n";
65?>
66--EXPECT--
67--- DOMElement test ---
68<?xml version="1.0"?>
69<root><node/></root>
70<?xml version="1.0"?>
71<root/>
72<?xml version="1.0"?>
73--- DOMDocumentFragment test ---
74<foo/>
75--- DOMDocument test ---
76<?xml version="1.0"?>
77
78--- DOMCharacterData test ---
79<?xml version="1.0"?>
80<![CDATA[foo]]>
81
82<?xml version="1.0"?>
83
84<?xml version="1.0"?>
85