1--TEST--
2appendChild() with DocumentType
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$original = new DOMDocument();
9$original->loadXML(<<<XML
10<?xml version="1.0"?>
11<!DOCTYPE doc [
12    <!ENTITY foo "bar">
13]>
14<doc/>
15XML);
16$doctype = $original->doctype->cloneNode();
17foreach ($doctype->entities as $entity) {
18    echo "Found entity: ", $entity->nodeName, "\n";
19}
20
21$other = new DOMDocument();
22$doctype = $other->importNode($original->doctype);
23$other->appendChild($doctype);
24$other->appendChild($doctype);
25try {
26    $other->appendChild($other->implementation->createDocumentType('doc', '', ''));
27} catch (DOMException $e) {
28    echo $e->getMessage(), "\n";
29}
30echo $other->saveXml();
31
32?>
33--EXPECT--
34Found entity: foo
35A document may only contain one document type
36<?xml version="1.0"?>
37<!DOCTYPE doc [
38<!ENTITY foo "bar">
39]>
40