1--TEST-- 2GH-11830 (ParentNode methods should perform their checks upfront) - document variation 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7$otherDoc = new DOMDocument; 8$otherDoc->loadXML(<<<XML 9<?xml version="1.0"?> 10<other/> 11XML); 12 13$otherElement = $otherDoc->documentElement; 14 15$doc = new DOMDocument; 16$doc->loadXML(<<<XML 17<?xml version="1.0"?> 18<container> 19 <alone/> 20 <child><testelement/></child> 21</container> 22XML); 23 24$testElement = $doc->documentElement->firstElementChild->nextElementSibling->firstElementChild; 25 26try { 27 $doc->documentElement->firstElementChild->prepend($testElement, $otherElement); 28} catch (\DOMException $e) { 29 echo $e->getMessage(), "\n"; 30} 31 32try { 33 $doc->documentElement->firstElementChild->append($testElement, $otherElement); 34} catch (\DOMException $e) { 35 echo $e->getMessage(), "\n"; 36} 37 38try { 39 $doc->documentElement->firstElementChild->before($testElement, $otherElement); 40} catch (\DOMException $e) { 41 echo $e->getMessage(), "\n"; 42} 43 44try { 45 $doc->documentElement->firstElementChild->after($testElement, $otherElement); 46} catch (\DOMException $e) { 47 echo $e->getMessage(), "\n"; 48} 49 50try { 51 $doc->documentElement->firstElementChild->replaceWith($testElement, $otherElement); 52} catch (\DOMException $e) { 53 echo $e->getMessage(), "\n"; 54} 55 56echo $otherDoc->saveXML(); 57echo $doc->saveXML(); 58?> 59--EXPECT-- 60Wrong Document Error 61Wrong Document Error 62Wrong Document Error 63Wrong Document Error 64Wrong Document Error 65<?xml version="1.0"?> 66<other/> 67<?xml version="1.0"?> 68<container> 69 <alone/> 70 <child><testelement/></child> 71</container> 72