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