summaryrefslogtreecommitdiff
path: root/ext/dom/tests/DOMNode_hasChildNodes.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dom/tests/DOMNode_hasChildNodes.phpt')
-rw-r--r--ext/dom/tests/DOMNode_hasChildNodes.phpt49
1 files changed, 49 insertions, 0 deletions
diff --git a/ext/dom/tests/DOMNode_hasChildNodes.phpt b/ext/dom/tests/DOMNode_hasChildNodes.phpt
new file mode 100644
index 0000000..5c1d714
--- /dev/null
+++ b/ext/dom/tests/DOMNode_hasChildNodes.phpt
@@ -0,0 +1,49 @@
+--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)