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