1--TEST-- 2Cloning text nodes should not merge adjacent text nodes 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = Dom\XMLDocument::createEmpty(); 9$root = $dom->appendChild($dom->createElementNS("urn:a", "a:root")); 10$root->setAttribute("foo", "bar"); 11 12$root->appendChild($dom->createTextNode("a")); 13$root->appendChild($dom->createTextNode("foo")); 14$root->appendChild($dom->createTextNode("b")); 15$child = $root->appendChild($dom->createElement("child")); 16$child->appendChild($dom->createTextNode("c")); 17$child2 = $root->appendChild($dom->createElement("child2")); 18$child2->appendChild($dom->createTextNode("d")); 19 20echo $dom->saveXml(), "\n"; 21 22$clone = clone $root; 23var_dump($clone->firstChild->textContent); 24var_dump($clone->firstChild->nextSibling->textContent); 25var_dump($clone->firstChild->nextSibling->nextSibling->textContent); 26echo $dom->saveXml($clone), "\n"; 27 28$clone = $child2->cloneNode(true); 29echo $dom->saveXml($clone), "\n"; 30 31$clone = $child2->cloneNode(false); 32echo $dom->saveXml($clone), "\n"; 33 34?> 35--EXPECT-- 36<?xml version="1.0" encoding="UTF-8"?> 37<a:root xmlns:a="urn:a" foo="bar">afoob<child>c</child><child2>d</child2></a:root> 38string(1) "a" 39string(3) "foo" 40string(1) "b" 41<a:root xmlns:a="urn:a" foo="bar">afoob<child>c</child><child2>d</child2></a:root> 42<child2>d</child2> 43<child2/> 44