File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / dom / tests / DOMNode_hasChildNodes.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--
Tests DOMNode::hasChildNodes()
--CREDITS--
Michael Stillwell <mjs@beebo.org>
# TestFest 2008
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php

$dom = new DOMDocument();

$dom->loadXML('<root/>');

echo $dom->saveXML();

echo "Document has child nodes\n";
var_dump($dom->documentElement->hasChildNodes());

echo "Document has child nodes\n";
$dom->loadXML('<root><a/></root>');
var_dump($dom->documentElement->hasChildNodes());

echo "Remove node and save\n";
$dom->documentElement->removeChild($dom->documentElement->firstChild);
echo $dom->saveXML();

echo "Document has child nodes\n";
var_dump($dom->documentElement->hasChildNodes());

echo "Document with 2 child nodes\n";
$dom->loadXML('<root><a/><b/></root>');
var_dump($dom->documentElement->hasChildNodes());

?>
--EXPECTF--
<?xml version="1.0"?>
<root/>
Document has child nodes
bool(false)
Document has child nodes
bool(true)
Remove node and save
<?xml version="1.0"?>
<root/>
Document has child nodes
bool(false)
Document with 2 child nodes
bool(true)

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