--TEST-- DOMElement::append() with hierarchy changes and errors --EXTENSIONS-- dom --FILE-- loadXML('

helloworld

'); echo "-- Append hello with world --\n"; $dom = clone $dom_original; $b_hello = $dom->firstChild->firstChild; $b_world = $b_hello->nextSibling; $b_hello->append($b_world); var_dump($dom->saveHTML()); echo "-- Append hello with world's child --\n"; $dom = clone $dom_original; $b_hello = $dom->firstChild->firstChild; $b_world = $b_hello->nextSibling; $b_hello->append($b_world->firstChild); var_dump($dom->saveHTML()); echo "-- Append world's child with hello --\n"; $dom = clone $dom_original; $b_hello = $dom->firstChild->firstChild; $b_world = $b_hello->nextSibling; $b_world->firstChild->append($b_hello); var_dump($dom->saveHTML()); echo "-- Append hello with itself --\n"; $dom = clone $dom_original; $b_hello = $dom->firstChild->firstChild; try { $b_hello->append($b_hello); } catch (\DOMException $e) { echo $e->getMessage(), "\n"; } var_dump($dom->saveHTML()); echo "-- Append world's i tag with the parent --\n"; $dom = clone $dom_original; $b_hello = $dom->firstChild->firstChild; $b_world = $b_hello->nextSibling; try { $b_world->firstChild->append($b_world); } catch (\DOMException $e) { echo $e->getMessage(), "\n"; } var_dump($dom->saveHTML()); echo "-- Append from another document --\n"; $dom = clone $dom_original; $dom2 = new DOMDocument; $dom2->loadXML('

other

'); try { $dom->firstChild->firstChild->prepend($dom2->firstChild); } catch (\DOMException $e) { echo $e->getMessage(), "\n"; } var_dump($dom2->saveHTML()); var_dump($dom->saveHTML()); ?> --EXPECT-- -- Append hello with world -- string(39) "

helloworld

" -- Append hello with world's child -- string(39) "

helloworld

" -- Append world's child with hello -- string(39) "

worldhello

" -- Append hello with itself -- Hierarchy Request Error string(39) "

helloworld

" -- Append world's i tag with the parent -- Hierarchy Request Error string(39) "

helloworld

" -- Append from another document -- Wrong Document Error string(13) "

other

" string(39) "

helloworld

"