File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / dom / tests / bug43364.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:54 2012 UTC (12 years, 4 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
Bug #43364 (recursive xincludes don't remove internal xml nodes properly)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php 
function loopElements($nodes)
{
    $count = 0;
    foreach($nodes as $node) {
        if($node instanceof DOMElement) {
            $count++;
            if($node->childNodes->length > 0) {
                $count += loopElements($node->childNodes);
            }
        }
    }
    return $count;
}

$xml = <<<DOC
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xi="http://www.w3.org/2001/XInclude">
    <a>
        <a_child1>ac1</a_child1>
        <a_child2>ac2</a_child2>
    </a>
    <b><xi:include xpointer="xpointer(/root/a)" /></b>
    <c><xi:include xpointer="xpointer(/root/b)" /></c>
</root>
DOC;

$doc = new DomDocument();
$doc->loadXml($xml);
$doc->xinclude();

$count = loopElements(array($doc->documentElement));

var_dump($count);
?>
--EXPECT--
int(13)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>