summaryrefslogtreecommitdiff
path: root/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dom/tests/DOMNode_hasChildNodes_basic.phpt')
-rw-r--r--ext/dom/tests/DOMNode_hasChildNodes_basic.phpt43
1 files changed, 43 insertions, 0 deletions
diff --git a/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt b/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt
new file mode 100644
index 000000000..3a6f6b421
--- /dev/null
+++ b/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Test whether a node has child nodes: hasChildNodes()
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+
+/* Create an XML document
+ * with strcuture
+ * <book>
+ * <title>This is the title</title>
+ * </book>
+ * Check for child nodes of the <book>, <title> and This is the title
+ *
+*/
+
+$doc = new DOMDocument();
+
+$root = $doc->createElement('book');
+$doc->appendChild($root);
+
+$title = $doc->createElement('title');
+$root->appendChild($title);
+
+$text = $doc->createTextNode('This is the title');
+$title->appendChild($text);
+
+echo "Root has child nodes: ";
+var_dump($root->hasChildNodes());
+
+echo "Title has child nodes: ";
+var_dump($title->hasChildNodes());
+
+echo "Text has child nodes: ";
+var_dump($text->hasChildNodes());
+
+?>
+--EXPECTF--
+Root has child nodes: bool(true)
+Title has child nodes: bool(true)
+Text has child nodes: bool(false) \ No newline at end of file