1--TEST--
2Dom\Element::insertAdjacentHTML() with HTML nodes - error conditions
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\HTMLDocument::createEmpty();
9$element = $dom->createElement('root');
10
11echo "--- BeforeBegin no parent ---\n";
12
13try {
14    $element->insertAdjacentHTML(Dom\AdjacentPosition::BeforeBegin, "test");
15} catch (DOMException $e) {
16    echo $e->getMessage(), "\n";
17}
18
19echo "--- AfterEnd no parent ---\n";
20
21try {
22    $element->insertAdjacentHTML(Dom\AdjacentPosition::AfterEnd, "test");
23} catch (DOMException $e) {
24    echo $e->getMessage(), "\n";
25}
26
27$dom->appendChild($element);
28
29echo "--- BeforeBegin document parent ---\n";
30
31try {
32    $element->insertAdjacentHTML(Dom\AdjacentPosition::BeforeBegin, "test");
33} catch (DOMException $e) {
34    echo $e->getMessage(), "\n";
35}
36
37echo "--- AfterEnd document parent ---\n";
38
39try {
40    $element->insertAdjacentHTML(Dom\AdjacentPosition::AfterEnd, "test");
41} catch (DOMException $e) {
42    echo $e->getMessage(), "\n";
43}
44
45?>
46--EXPECT--
47--- BeforeBegin no parent ---
48No Modification Allowed Error
49--- AfterEnd no parent ---
50No Modification Allowed Error
51--- BeforeBegin document parent ---
52No Modification Allowed Error
53--- AfterEnd document parent ---
54No Modification Allowed Error
55