xref: /PHP-7.2/ext/dom/tests/bug43364.phpt (revision 17ccbeec)
1--TEST--
2Bug #43364 (recursive xincludes don't remove internal xml nodes properly)
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7function loopElements($nodes)
8{
9    $count = 0;
10    foreach($nodes as $node) {
11        if($node instanceof DOMElement) {
12            $count++;
13            if($node->childNodes->length > 0) {
14                $count += loopElements($node->childNodes);
15            }
16        }
17    }
18    return $count;
19}
20
21$xml = <<<DOC
22<?xml version="1.0" encoding="UTF-8"?>
23<root xmlns:xi="http://www.w3.org/2001/XInclude">
24    <a>
25        <a_child1>ac1</a_child1>
26        <a_child2>ac2</a_child2>
27    </a>
28    <b><xi:include xpointer="xpointer(/root/a)" /></b>
29    <c><xi:include xpointer="xpointer(/root/b)" /></c>
30</root>
31DOC;
32
33$doc = new DomDocument();
34$doc->loadXml($xml);
35$doc->xinclude();
36
37$count = loopElements(array($doc->documentElement));
38
39var_dump($count);
40?>
41--EXPECT--
42int(13)
43