summaryrefslogtreecommitdiff
path: root/ext/dom/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dom/tests')
-rw-r--r--ext/dom/tests/DOMAttr_construct_error_001.phpt17
-rw-r--r--ext/dom/tests/DOMAttr_name_basic_001.phpt14
-rw-r--r--ext/dom/tests/DOMAttr_ownerElement_error_001.phpt23
-rw-r--r--ext/dom/tests/DOMAttr_value_basic_001.phpt16
-rw-r--r--ext/dom/tests/DOMAttr_value_basic_002.phpt15
-rw-r--r--ext/dom/tests/DOMCDATASection_construct_error_001.phpt21
-rw-r--r--ext/dom/tests/DOMCharacterData_appendData_basic.phpt37
-rw-r--r--ext/dom/tests/DOMCharacterData_appendData_error_001.phpt19
-rw-r--r--ext/dom/tests/DOMCharacterData_data_basic_002.phpt28
-rw-r--r--ext/dom/tests/DOMCharacterData_data_error_002.phpt14
-rw-r--r--ext/dom/tests/DOMCharacterData_deleteData_basic_001.phpt20
-rw-r--r--ext/dom/tests/DOMCharacterData_deleteData_error_001.phpt19
-rw-r--r--ext/dom/tests/DOMCharacterData_deleteData_error_002.phpt23
-rw-r--r--ext/dom/tests/DOMCharacterData_insertData_error_001.phpt19
-rw-r--r--ext/dom/tests/DOMCharacterData_length_error_001.phpt17
-rw-r--r--ext/dom/tests/DOMCharacterData_replaceData_error_001.phpt19
-rw-r--r--ext/dom/tests/DOMCharacterData_substringData_basic_001.phpt21
-rw-r--r--ext/dom/tests/DOMComment_appendData_basic.phpt21
-rw-r--r--ext/dom/tests/DOMComment_appendData_basic_Sullivan.phpt37
-rw-r--r--ext/dom/tests/DOMComment_construct_basic_001.phpt19
-rw-r--r--ext/dom/tests/DOMComment_construct_error_001.phpt17
-rw-r--r--ext/dom/tests/DOMComment_insertData_basic.phpt21
-rw-r--r--ext/dom/tests/DOMComment_insertData_error1.phpt24
-rw-r--r--ext/dom/tests/DOMComment_insertData_error2.phpt24
-rw-r--r--ext/dom/tests/DOMComment_replaceData_basic.phpt29
-rw-r--r--ext/dom/tests/DOMComment_replaceData_error1.phpt24
-rw-r--r--ext/dom/tests/DOMComment_replaceData_error2.phpt24
-rw-r--r--ext/dom/tests/DOMDocumentFragment_appendXML_basic_001.phpt22
-rw-r--r--ext/dom/tests/DOMDocumentFragment_appendXML_error_001.phpt14
-rw-r--r--ext/dom/tests/DOMDocumentFragment_appendXML_error_002.phpt19
-rw-r--r--ext/dom/tests/DOMDocumentFragment_appendXML_error_003.phpt19
-rw-r--r--ext/dom/tests/DOMDocumentFragment_appendXML_hasChildNodes_basic.phpt23
-rw-r--r--ext/dom/tests/DOMDocumentFragment_construct_basic_001.phpt14
-rw-r--r--ext/dom/tests/DOMDocumentFragment_construct_basic_002.phpt16
-rw-r--r--ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt17
-rw-r--r--ext/dom/tests/DOMDocumentType_basic_001.phpt48
-rw-r--r--ext/dom/tests/DOMDocumentType_entities_error_001.phpt14
-rw-r--r--ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt14
-rw-r--r--ext/dom/tests/DOMDocumentType_name_error_001.phpt14
-rw-r--r--ext/dom/tests/DOMDocumentType_notations_error_001.phpt14
-rw-r--r--ext/dom/tests/DOMDocumentType_publicId_basic_001.phpt19
-rw-r--r--ext/dom/tests/DOMDocumentType_publicId_error_001.phpt14
-rw-r--r--ext/dom/tests/DOMDocumentType_systemId_basic_001.phpt19
-rw-r--r--ext/dom/tests/DOMDocumentType_systemId_error_001.phpt14
-rw-r--r--ext/dom/tests/DOMDocument_config_basic.phpt26
-rw-r--r--ext/dom/tests/DOMDocument_createAttribute_basic.phpt26
-rw-r--r--ext/dom/tests/DOMDocument_createAttribute_error.phpt27
-rw-r--r--ext/dom/tests/DOMDocument_createAttribute_error1.phpt29
-rw-r--r--ext/dom/tests/DOMDocument_createAttribute_variation.phpt14
-rw-r--r--ext/dom/tests/DOMDocument_createEntityReference_basic.phpt19
-rw-r--r--ext/dom/tests/DOMDocument_createProcessingInstruction_basic.phpt30
-rw-r--r--ext/dom/tests/DOMDocument_createProcessingInstruction_error.phpt31
-rw-r--r--ext/dom/tests/DOMDocument_documentURI_basic.phpt39
-rw-r--r--ext/dom/tests/DOMDocument_encoding_basic.phpt52
-rw-r--r--ext/dom/tests/DOMDocument_implementationRead_basic.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_loadHTML_basic.phpt18
-rw-r--r--ext/dom/tests/DOMDocument_loadHTML_error1.phpt15
-rw-r--r--ext/dom/tests/DOMDocument_loadHTML_error2.phpt15
-rw-r--r--ext/dom/tests/DOMDocument_preserveWhiteSpace_basic.phpt23
-rw-r--r--ext/dom/tests/DOMDocument_preserveWhiteSpace_variations.phpt40
-rw-r--r--ext/dom/tests/DOMDocument_relaxNGValidateSource_basic.phpt39
-rw-r--r--ext/dom/tests/DOMDocument_relaxNGValidateSource_error1.phpt41
-rw-r--r--ext/dom/tests/DOMDocument_relaxNGValidateSource_error2.phpt39
-rw-r--r--ext/dom/tests/DOMDocument_relaxNGValidate_basic.phpt24
-rw-r--r--ext/dom/tests/DOMDocument_relaxNGValidate_basic.rng11
-rw-r--r--ext/dom/tests/DOMDocument_relaxNGValidate_error1.phpt26
-rw-r--r--ext/dom/tests/DOMDocument_relaxNGValidate_error2.phpt31
-rw-r--r--ext/dom/tests/DOMDocument_resolveExternals_basic.phpt49
-rw-r--r--ext/dom/tests/DOMDocument_saveHTMLFile_basic.phpt29
-rw-r--r--ext/dom/tests/DOMDocument_saveHTMLFile_error1.phpt24
-rw-r--r--ext/dom/tests/DOMDocument_saveHTMLFile_error2.phpt15
-rw-r--r--ext/dom/tests/DOMDocument_saveHTMLFile_formatOutput.phpt33
-rw-r--r--ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt25
-rw-r--r--ext/dom/tests/DOMDocument_saveHTML_basic.phpt24
-rw-r--r--ext/dom/tests/DOMDocument_saveHTML_error2.phpt15
-rw-r--r--ext/dom/tests/DOMDocument_saveHTML_variant1.phpt24
-rw-r--r--ext/dom/tests/DOMDocument_saveHTML_variant2.phpt26
-rw-r--r--ext/dom/tests/DOMDocument_save_basic.phpt33
-rw-r--r--ext/dom/tests/DOMDocument_savexml_basic.phpt39
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidateSource_basic.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidateSource_error1.phpt29
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidateSource_error2.phpt23
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidateSource_error3.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidate_basic.phpt20
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidate_error1.phpt29
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidate_error2.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidate_error3.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidate_error4.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidate_error5.phpt25
-rw-r--r--ext/dom/tests/DOMDocument_standalone_basic.phpt48
-rw-r--r--ext/dom/tests/DOMDocument_strictErrorChecking_basic.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_strictErrorChecking_variation.phpt59
-rw-r--r--ext/dom/tests/DOMDocument_validate_basic.phpt31
-rw-r--r--ext/dom/tests/DOMDocument_validate_error1.phpt16
-rw-r--r--ext/dom/tests/DOMDocument_validate_error2.phpt15
-rw-r--r--ext/dom/tests/DOMDocument_validate_external_dtd.phpt19
-rw-r--r--ext/dom/tests/DOMDocument_validate_on_parse_basic.phpt38
-rw-r--r--ext/dom/tests/DOMDocument_validate_on_parse_variation.phpt46
-rw-r--r--ext/dom/tests/DOMElement_hasAttributes_basic.phpt49
-rw-r--r--ext/dom/tests/DOMImplementation_createDocumentType_basic.phpt18
-rw-r--r--ext/dom/tests/DOMImplementation_createDocument_basic.phpt14
-rw-r--r--ext/dom/tests/DOMImplementation_hasFeature_basic.phpt15
-rw-r--r--ext/dom/tests/DOMNode_C14NFile_basic.phpt38
-rw-r--r--ext/dom/tests/DOMNode_C14N_basic.phpt29
-rw-r--r--ext/dom/tests/DOMNode_cloneNode_basic.phpt106
-rw-r--r--ext/dom/tests/DOMNode_getLineNo_basic.phpt19
-rw-r--r--ext/dom/tests/DOMNode_getNodePath_basic.phpt19
-rw-r--r--ext/dom/tests/DOMNode_hasChildNodes.phpt49
-rw-r--r--ext/dom/tests/DOMNode_hasChildNodes_basic.phpt43
-rw-r--r--ext/dom/tests/DOMNode_insertBefore.phpt34
-rw-r--r--ext/dom/tests/DOMNode_insertBefore_error1.phpt24
-rw-r--r--ext/dom/tests/DOMNode_issamenode_basic.phpt37
-rw-r--r--ext/dom/tests/DOMNode_normalize_basic.phpt64
-rw-r--r--ext/dom/tests/DOMNode_removeChild_basic.phpt106
-rw-r--r--ext/dom/tests/DOMNode_replaceChild_basic.phpt44
-rw-r--r--ext/dom/tests/DOMText_appendData_basic.phpt40
-rwxr-xr-xext/dom/tests/book-non-conforming-schema.xsd17
-rwxr-xr-xext/dom/tests/book-not-a-schema.xsd1
-rw-r--r--ext/dom/tests/book.xml11
-rw-r--r--ext/dom/tests/book.xml.gzbin0 -> 119 bytes
-rwxr-xr-xext/dom/tests/book.xsd17
-rw-r--r--ext/dom/tests/bug28721.phpt485
-rw-r--r--ext/dom/tests/bug28817.phpt38
-rw-r--r--ext/dom/tests/bug32615.phpt84
-rw-r--r--ext/dom/tests/bug34276.phpt43
-rw-r--r--ext/dom/tests/bug35342.phpt20
-rw-r--r--ext/dom/tests/bug35673.phpt20
-rw-r--r--ext/dom/tests/bug36756.phpt35
-rw-r--r--ext/dom/tests/bug37277.phpt25
-rw-r--r--ext/dom/tests/bug37456.phpt22
-rw-r--r--ext/dom/tests/bug38438.phpt13
-rw-r--r--ext/dom/tests/bug38474.phpt46
-rw-r--r--ext/dom/tests/bug38850.phpt22
-rw-r--r--ext/dom/tests/bug38949.phpt27
-rw-r--r--ext/dom/tests/bug40836.phpt29
-rw-r--r--ext/dom/tests/bug41257.phpt31
-rw-r--r--ext/dom/tests/bug41374.phpt32
-rw-r--r--ext/dom/tests/bug42082.phpt31
-rw-r--r--ext/dom/tests/bug43364.phpt42
-rw-r--r--ext/dom/tests/bug44648.phpt45
-rw-r--r--ext/dom/tests/bug45251.phpt30
-rw-r--r--ext/dom/tests/bug46185.phpt23
-rw-r--r--ext/dom/tests/bug46335.phpt35
-rw-r--r--ext/dom/tests/bug46849.phpt16
-rw-r--r--ext/dom/tests/bug47430.phpt30
-rw-r--r--ext/dom/tests/bug47848.phpt25
-rw-r--r--ext/dom/tests/bug47849.phpt22
-rw-r--r--ext/dom/tests/bug49463.phpt17
-rw-r--r--ext/dom/tests/bug49490.phpt17
-rw-r--r--ext/dom/tests/bug50661.phpt16
-rw-r--r--ext/dom/tests/bug52656.phpt14
-rw-r--r--ext/dom/tests/bug54601.phpt29
-rw-r--r--ext/dom/tests/canonicalization.phpt102
-rw-r--r--ext/dom/tests/dom.ent8
-rw-r--r--ext/dom/tests/dom.xml8
-rw-r--r--ext/dom/tests/dom001.phpt275
-rw-r--r--ext/dom/tests/dom002.phpt57
-rw-r--r--ext/dom/tests/dom003.phpt69
-rw-r--r--ext/dom/tests/dom004.phpt25
-rw-r--r--ext/dom/tests/dom005.phpt33
-rw-r--r--ext/dom/tests/dom006.phpt40
-rw-r--r--ext/dom/tests/dom007.phpt111
-rw-r--r--ext/dom/tests/dom_comment_basic.phpt43
-rw-r--r--ext/dom/tests/dom_comment_variation.phpt32
-rw-r--r--ext/dom/tests/dom_create_element.phpt394
-rw-r--r--ext/dom/tests/dom_import_simplexml.phpt27
-rw-r--r--ext/dom/tests/dom_set_attr_node.phpt74
-rw-r--r--ext/dom/tests/dom_test.inc47
-rw-r--r--ext/dom/tests/dom_xinclude.phpt42
-rw-r--r--ext/dom/tests/domattributes.phpt43
-rw-r--r--ext/dom/tests/domchardata.phpt76
-rw-r--r--ext/dom/tests/domdocument_createcomment_error_001.phpt16
-rw-r--r--ext/dom/tests/domdocument_createentityreference_001.phpt18
-rw-r--r--ext/dom/tests/domdocument_createentityreference_002.phpt17
-rw-r--r--ext/dom/tests/domelement.phpt114
-rw-r--r--ext/dom/tests/domobject_debug_handler.phpt59
-rw-r--r--ext/dom/tests/domxpath.phpt58
-rw-r--r--ext/dom/tests/note.dtd6
-rw-r--r--ext/dom/tests/note.xml8
-rw-r--r--ext/dom/tests/nsdoc.xml4
-rw-r--r--ext/dom/tests/regsiter_node_class.phpt40
-rw-r--r--ext/dom/tests/skipif.inc1
-rw-r--r--ext/dom/tests/test.html9
-rw-r--r--ext/dom/tests/xinclude.xml4
185 files changed, 6433 insertions, 0 deletions
diff --git a/ext/dom/tests/DOMAttr_construct_error_001.phpt b/ext/dom/tests/DOMAttr_construct_error_001.phpt
new file mode 100644
index 0000000..08734ca
--- /dev/null
+++ b/ext/dom/tests/DOMAttr_construct_error_001.phpt
@@ -0,0 +1,17 @@
+--TEST--
+DOMAttr __construct() with no arguments.
+--CREDITS--
+Josh Sweeney <jsweeney@alt-invest.net>
+# TestFest Atlanta 2009-05-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$attr = new DOMAttr();
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'DOMException' with message 'DOMAttr::__construct() expects at least 1 parameter, 0 given' in %s:%d
+Stack trace:
+#0 %s(%d): DOMAttr->__construct()
+#1 {main}
+ thrown in %s on line %d
diff --git a/ext/dom/tests/DOMAttr_name_basic_001.phpt b/ext/dom/tests/DOMAttr_name_basic_001.phpt
new file mode 100644
index 0000000..29ca8c5
--- /dev/null
+++ b/ext/dom/tests/DOMAttr_name_basic_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMAttr read $name property.
+--CREDITS--
+Nic Rosental <nicrosental@gmail.com>
+# TestFest Atlanta 2009-05-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$attr = new DOMAttr('category', 'books');
+print $attr->name;
+?>
+--EXPECT--
+category \ No newline at end of file
diff --git a/ext/dom/tests/DOMAttr_ownerElement_error_001.phpt b/ext/dom/tests/DOMAttr_ownerElement_error_001.phpt
new file mode 100644
index 0000000..a776654
--- /dev/null
+++ b/ext/dom/tests/DOMAttr_ownerElement_error_001.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Read $ownerElement with null parent.
+--CREDITS--
+Travis Pew
+# TestFest Atlanta 2009-05-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+$attr = $root->setAttribute('category', 'books');
+$document->removeChild($root);
+$root = null;
+var_dump($attr->ownerElement);
+?>
+--EXPECTF--
+Warning: Couldn't fetch DOMAttr. Node no longer exists in %s on line %d
+
+Notice: Undefined property: DOMAttr::$ownerElement in %s on line %d
+NULL
diff --git a/ext/dom/tests/DOMAttr_value_basic_001.phpt b/ext/dom/tests/DOMAttr_value_basic_001.phpt
new file mode 100644
index 0000000..51c4ac9
--- /dev/null
+++ b/ext/dom/tests/DOMAttr_value_basic_001.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Read empty $value.
+--CREDITS--
+Jason Bouffard <jbouffard1@yahoo.com>
+# TestFest Atlanta 2009-05-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$attr = new DOMAttr('category');
+print $attr->value."\n";
+?>
+===DONE===
+--EXPECTF--
+===DONE===
+
diff --git a/ext/dom/tests/DOMAttr_value_basic_002.phpt b/ext/dom/tests/DOMAttr_value_basic_002.phpt
new file mode 100644
index 0000000..384a9ca
--- /dev/null
+++ b/ext/dom/tests/DOMAttr_value_basic_002.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Write non-string $value property
+--CREDITS--
+Eric Berg <ehberg@gmail.com>
+# TestFest Atlanta 2009-05-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$attr = new DOMAttr('category');
+$attr->value = 1;
+print $attr->value;
+?>
+--EXPECTF--
+1
diff --git a/ext/dom/tests/DOMCDATASection_construct_error_001.phpt b/ext/dom/tests/DOMCDATASection_construct_error_001.phpt
new file mode 100644
index 0000000..4db2130
--- /dev/null
+++ b/ext/dom/tests/DOMCDATASection_construct_error_001.phpt
@@ -0,0 +1,21 @@
+--TEST--
+__construct() with no arguments.
+--CREDITS--
+Nic Rosental nicrosental@gmail.com
+# TestFest Atlanta 2009-5-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+ try
+ {
+ $section = new DOMCDataSection();
+
+ }
+ catch (Exception $e)
+ {
+ echo $e->getMessage();
+ }
+?>
+--EXPECT--
+DOMCdataSection::__construct() expects exactly 1 parameter, 0 given \ No newline at end of file
diff --git a/ext/dom/tests/DOMCharacterData_appendData_basic.phpt b/ext/dom/tests/DOMCharacterData_appendData_basic.phpt
new file mode 100644
index 0000000..e479c1e
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_appendData_basic.phpt
@@ -0,0 +1,37 @@
+--TEST--
+DOMCharacterData::appendData basic functionality test
+--CREDITS--
+Mike Sullivan <mike@regexia.com>
+#TestFest 2008 (London)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$cdata = $document->createElement('cdata');
+$root->appendChild($cdata);
+
+$cdatanode = $document->createCDATASection('');
+$cdata->appendChild($cdatanode);
+$cdatanode->appendData('data');
+echo "CDATA Length (one append): " . $cdatanode->length . "\n";
+
+$cdatanode->appendData('><&"');
+echo "CDATA Length (two appends): " . $cdatanode->length . "\n";
+
+echo "CDATA Content: " . $cdatanode->data . "\n";
+
+echo "\n" . $document->saveXML();
+
+?>
+--EXPECT--
+CDATA Length (one append): 4
+CDATA Length (two appends): 8
+CDATA Content: data><&"
+
+<?xml version="1.0"?>
+<root><cdata><![CDATA[data><&"]]></cdata></root> \ No newline at end of file
diff --git a/ext/dom/tests/DOMCharacterData_appendData_error_001.phpt b/ext/dom/tests/DOMCharacterData_appendData_error_001.phpt
new file mode 100644
index 0000000..4126f99
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_appendData_error_001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMCharacterData::appendData() with no arguments.
+--CREDITS--
+Eric Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$cdata = $document->createCDATASection('test');
+$root->appendChild($cdata);
+$cdata->appendData();
+?>
+--EXPECTF--
+Warning: DOMCharacterData::appendData() expects exactly 1 parameter, 0 given in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMCharacterData_data_basic_002.phpt b/ext/dom/tests/DOMCharacterData_data_basic_002.phpt
new file mode 100644
index 0000000..394b316
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_data_basic_002.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Create CDATA section and change it using DOMcreateCDATASection
+--CREDITS--
+Nic Rosental nicrosental@gmail.com
+# TestFest Atlanta 2009-5-28
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$cdata = $document->createCDATASection('t');
+$root->appendChild($cdata);
+print $document->saveXML()."\n";
+
+$cdata->data = 100;
+print $document->saveXML()."\n";
+
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<root><![CDATA[t]]></root>
+
+<?xml version="1.0"?>
+<root><![CDATA[100]]></root>
diff --git a/ext/dom/tests/DOMCharacterData_data_error_002.phpt b/ext/dom/tests/DOMCharacterData_data_error_002.phpt
new file mode 100644
index 0000000..401e0f2
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_data_error_002.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Invalid State Error when getting data on DOMCharacterData out of content.
+--CREDITS--
+Eric Berg <ehberg@gmail.com>
+# TestFest Atlanta 2009-05-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$character_data = new DOMCharacterData();
+print $character_data->data;
+?>
+--EXPECTF--
+Warning: main(): Invalid State Error in %s on line %d
diff --git a/ext/dom/tests/DOMCharacterData_deleteData_basic_001.phpt b/ext/dom/tests/DOMCharacterData_deleteData_basic_001.phpt
new file mode 100644
index 0000000..ad104f1
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_deleteData_basic_001.phpt
@@ -0,0 +1,20 @@
+--TEST--
+DOMCharacterData::deleteData() with count exceeding string size.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$cdata = $document->createCDATASection('test');
+$root->appendChild($cdata);
+$cdata->deleteData(1, 10);
+var_dump($cdata->data);
+?>
+--EXPECTF--
+%unicode|string%(%d) "t" \ No newline at end of file
diff --git a/ext/dom/tests/DOMCharacterData_deleteData_error_001.phpt b/ext/dom/tests/DOMCharacterData_deleteData_error_001.phpt
new file mode 100644
index 0000000..3fa7fba
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_deleteData_error_001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMCharacterData::deleteData() with no arguments.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$cdata = $document->createCDATASection('test');
+$root->appendChild($cdata);
+$cdata->deleteData();
+?>
+--EXPECTF--
+Warning: DOMCharacterData::deleteData() expects exactly 2 parameters, 0 given in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMCharacterData_deleteData_error_002.phpt b/ext/dom/tests/DOMCharacterData_deleteData_error_002.phpt
new file mode 100644
index 0000000..117d5de
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_deleteData_error_002.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DOMCharacterData::deleteData() with offset exceeding string size.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$cdata = $document->createCDATASection('test');
+$root->appendChild($cdata);
+$cdata->deleteData(5, 1);
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'DOMException' with message 'Index Size Error' in %s:%d
+Stack trace:
+#0 %s(%d): DOMCharacterData->deleteData(5, 1)
+#1 {main}
+ thrown in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMCharacterData_insertData_error_001.phpt b/ext/dom/tests/DOMCharacterData_insertData_error_001.phpt
new file mode 100644
index 0000000..813a0be
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_insertData_error_001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMCharacterData::insertData() with no arguments.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$cdata = $document->createCDATASection('test');
+$root->appendChild($cdata);
+$cdata->insertData();
+?>
+--EXPECTF--
+Warning: DOMCharacterData::insertData() expects exactly 2 parameters, 0 given in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMCharacterData_length_error_001.phpt b/ext/dom/tests/DOMCharacterData_length_error_001.phpt
new file mode 100644
index 0000000..e8bf16a
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_length_error_001.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Invalid State Error when getting length on DOMCharacterData out of content.
+--CREDITS--
+Jason Bouffard <jbouffard1@yahoo.com>
+# TestFest Atlanta 2009-05-14
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$character_data = new DOMCharacterData();
+print $character_data->length;
+?>
+===DONE===
+--EXPECTF--
+Warning: main(): Invalid State Error in %s
+===DONE===
+
diff --git a/ext/dom/tests/DOMCharacterData_replaceData_error_001.phpt b/ext/dom/tests/DOMCharacterData_replaceData_error_001.phpt
new file mode 100644
index 0000000..45d25dd
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_replaceData_error_001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMCharacterData::replaceData() with no arguments.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$cdata = $document->createCDATASection('test');
+$root->appendChild($cdata);
+$cdata->replaceData();
+?>
+--EXPECTF--
+Warning: DOMCharacterData::replaceData() expects exactly 3 parameters, 0 given in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMCharacterData_substringData_basic_001.phpt b/ext/dom/tests/DOMCharacterData_substringData_basic_001.phpt
new file mode 100644
index 0000000..b9d73e1
--- /dev/null
+++ b/ext/dom/tests/DOMCharacterData_substringData_basic_001.phpt
@@ -0,0 +1,21 @@
+--TEST--
+__DOMCharacterData::substringData pull mid section of string
+--CREDITS--
+Nic Rosental nicrosental@gmail.com
+# TestFest Atlanta 2009-5-28
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$cdata = $document->createCDATASection('testfest');
+$root->appendChild($cdata);
+print $cdata->substringData(1, 6);
+
+?>
+--EXPECT--
+estfes \ No newline at end of file
diff --git a/ext/dom/tests/DOMComment_appendData_basic.phpt b/ext/dom/tests/DOMComment_appendData_basic.phpt
new file mode 100644
index 0000000..c756f16
--- /dev/null
+++ b/ext/dom/tests/DOMComment_appendData_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Test adding data to a DOMComment
+--CREDITS--
+Andrew Larssen <al@larssen.org>
+London TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$dom = new DomDocument();
+$comment = $dom->createComment('test-comment');
+$comment->appendData('-more-data');
+$dom->appendChild($comment);
+$dom->saveXML();
+echo $dom->saveXML();
+
+?>
+--EXPECTF--
+<?xml version="1.0"?>
+<!--test-comment-more-data--> \ No newline at end of file
diff --git a/ext/dom/tests/DOMComment_appendData_basic_Sullivan.phpt b/ext/dom/tests/DOMComment_appendData_basic_Sullivan.phpt
new file mode 100644
index 0000000..ae06d8a
--- /dev/null
+++ b/ext/dom/tests/DOMComment_appendData_basic_Sullivan.phpt
@@ -0,0 +1,37 @@
+--TEST--
+DOMComment::appendData basic functionality test
+--CREDITS--
+Mike Sullivan <mike@regexia.com>
+#TestFest 2008 (London)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$comment = $document->createElement('comment');
+$root->appendChild($comment);
+
+$commentnode = $document->createComment('');
+$comment->appendChild($commentnode);
+$commentnode->appendData('data');
+echo "Comment Length (one append): " . $commentnode->length . "\n";
+
+$commentnode->appendData('><&"');
+echo "Comment Length (two appends): " . $commentnode->length . "\n";
+
+echo "Comment Content: " . $commentnode->data . "\n";
+
+echo "\n" . $document->saveXML();
+
+?>
+--EXPECT--
+Comment Length (one append): 4
+Comment Length (two appends): 8
+Comment Content: data><&"
+
+<?xml version="1.0"?>
+<root><comment><!--data><&"--></comment></root> \ No newline at end of file
diff --git a/ext/dom/tests/DOMComment_construct_basic_001.phpt b/ext/dom/tests/DOMComment_construct_basic_001.phpt
new file mode 100644
index 0000000..902f7bb
--- /dev/null
+++ b/ext/dom/tests/DOMComment_construct_basic_001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMComment::__construct() with constructor called twice.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new DOMDocument('1.0', 'UTF-8');
+$element = $dom->appendChild(new DOMElement('root'));
+$comment = new DOMComment("This is the first comment.");
+$comment->__construct("This is the second comment.");
+$comment = $element->appendChild($comment);
+print $dom->saveXML();
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<root><!--This is the second comment.--></root>
diff --git a/ext/dom/tests/DOMComment_construct_error_001.phpt b/ext/dom/tests/DOMComment_construct_error_001.phpt
new file mode 100644
index 0000000..89142fe
--- /dev/null
+++ b/ext/dom/tests/DOMComment_construct_error_001.phpt
@@ -0,0 +1,17 @@
+--TEST--
+DOMComment::__construct() with more arguments than acceptable.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$comment = new DOMComment("comment1", "comment2");
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'DOMException' with message 'DOMComment::__construct() expects at most 1 parameter, 2 given' in %s:%d
+Stack trace:
+#0 %s(%d): DOMComment->__construct('comment1', 'comment2')
+#1 {main}
+ thrown in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMComment_insertData_basic.phpt b/ext/dom/tests/DOMComment_insertData_basic.phpt
new file mode 100644
index 0000000..5a4857d
--- /dev/null
+++ b/ext/dom/tests/DOMComment_insertData_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Test inserting data into a DOMComment basic test
+--CREDITS--
+Andrew Larssen <al@larssen.org>
+London TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+//correct offset
+$dom = new DomDocument();
+$comment = $dom->createComment('test-comment');
+$comment->insertData(4,'-inserted');
+$dom->appendChild($comment);
+echo $dom->saveXML();
+
+?>
+--EXPECTF--
+<?xml version="1.0"?>
+<!--test-inserted-comment-->
diff --git a/ext/dom/tests/DOMComment_insertData_error1.phpt b/ext/dom/tests/DOMComment_insertData_error1.phpt
new file mode 100644
index 0000000..56922ac
--- /dev/null
+++ b/ext/dom/tests/DOMComment_insertData_error1.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test inserting data into a DOMComment basic test
+--CREDITS--
+Andrew Larssen <al@larssen.org>
+London TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+//Negative offset
+$dom = new DomDocument();
+$comment = $dom->createComment('test-comment');
+try {
+ $comment->insertData(-1,'-inserted');
+} catch (DOMException $e ) {
+ if ($e->getMessage() == 'Index Size Error'){
+ echo "Throws DOMException for -ve offset\n";
+ }
+}
+
+?>
+--EXPECTF--
+Throws DOMException for -ve offset
diff --git a/ext/dom/tests/DOMComment_insertData_error2.phpt b/ext/dom/tests/DOMComment_insertData_error2.phpt
new file mode 100644
index 0000000..d2affa8
--- /dev/null
+++ b/ext/dom/tests/DOMComment_insertData_error2.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test inserting data into a DOMComment basic test
+--CREDITS--
+Andrew Larssen <al@larssen.org>
+London TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+//offset to large
+$dom = new DomDocument();
+$comment = $dom->createComment('test-comment');
+try {
+ $comment->insertData(999,'-inserted');
+} catch (DOMException $e ) {
+ if ($e->getMessage() == 'Index Size Error'){
+ echo "Throws DOMException for offset too large\n";
+ }
+}
+
+?>
+--EXPECTF--
+Throws DOMException for offset too large \ No newline at end of file
diff --git a/ext/dom/tests/DOMComment_replaceData_basic.phpt b/ext/dom/tests/DOMComment_replaceData_basic.phpt
new file mode 100644
index 0000000..2963cb1
--- /dev/null
+++ b/ext/dom/tests/DOMComment_replaceData_basic.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test replacing data into a DOMComment basic test
+--CREDITS--
+Andrew Larssen <al@larssen.org>
+London TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$dom = new DomDocument();
+$comment = $dom->createComment('test-comment');
+$comment->replaceData(4,1,'replaced');
+$dom->appendChild($comment);
+echo $dom->saveXML();
+
+// Replaces rest of string if count is greater than length of existing string
+$dom = new DomDocument();
+$comment = $dom->createComment('test-comment');
+$comment->replaceData(0,50,'replaced');
+$dom->appendChild($comment);
+echo $dom->saveXML();
+
+?>
+--EXPECTF--
+<?xml version="1.0"?>
+<!--testreplacedcomment-->
+<?xml version="1.0"?>
+<!--replaced-->
diff --git a/ext/dom/tests/DOMComment_replaceData_error1.phpt b/ext/dom/tests/DOMComment_replaceData_error1.phpt
new file mode 100644
index 0000000..4ae4cb6
--- /dev/null
+++ b/ext/dom/tests/DOMComment_replaceData_error1.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test replacing data into a DOMComment basic test
+--CREDITS--
+Andrew Larssen <al@larssen.org>
+London TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+//Negative offset
+$dom = new DomDocument();
+$comment = $dom->createComment('test-comment');
+try {
+ $comment->replaceData(-1,4,'-inserted');
+} catch (DOMException $e ) {
+ if ($e->getMessage() == 'Index Size Error'){
+ echo "Throws DOMException for -ve offest\n";
+ }
+}
+
+?>
+--EXPECTF--
+Throws DOMException for -ve offest
diff --git a/ext/dom/tests/DOMComment_replaceData_error2.phpt b/ext/dom/tests/DOMComment_replaceData_error2.phpt
new file mode 100644
index 0000000..89614f9
--- /dev/null
+++ b/ext/dom/tests/DOMComment_replaceData_error2.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test replacing data into a DOMComment basic test
+--CREDITS--
+Andrew Larssen <al@larssen.org>
+London TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+//offset to large
+$dom = new DomDocument();
+$comment = $dom->createComment('test-comment');
+try {
+ $comment->replaceData(999,4,'-inserted');
+} catch (DOMException $e ) {
+ if ($e->getMessage() == 'Index Size Error'){
+ echo "Throws DOMException for offest too large\n";
+ }
+}
+
+?>
+--EXPECTF--
+Throws DOMException for offest too large \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentFragment_appendXML_basic_001.phpt b/ext/dom/tests/DOMDocumentFragment_appendXML_basic_001.phpt
new file mode 100644
index 0000000..a6f381b
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentFragment_appendXML_basic_001.phpt
@@ -0,0 +1,22 @@
+--TEST--
+DOMDocumentFragment::appendXML() with children with properties.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$fragment = $document->createDocumentFragment();
+$fragment->appendXML('<foo id="baz">bar</foo>');
+$root->appendChild($fragment);
+
+print $document->saveXML();
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<root><foo id="baz">bar</foo></root>
diff --git a/ext/dom/tests/DOMDocumentFragment_appendXML_error_001.phpt b/ext/dom/tests/DOMDocumentFragment_appendXML_error_001.phpt
new file mode 100644
index 0000000..6ffe510
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentFragment_appendXML_error_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMDocumentFragment::appendXML() with no arguments.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$fragment = new DOMDocumentFragment();
+$fragment->appendXML();
+?>
+--EXPECTF--
+Warning: DOMDocumentFragment::appendXML() expects exactly 1 parameter, 0 given in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentFragment_appendXML_error_002.phpt b/ext/dom/tests/DOMDocumentFragment_appendXML_error_002.phpt
new file mode 100644
index 0000000..c02c920
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentFragment_appendXML_error_002.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMDocumentFragment::appendXML() with unbound fragment.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$fragment = new DOMDocumentFragment();
+$fragment->appendXML('<bait>crankbait</bait>');
+$document->appendChild($fragment);
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'DOMException' with message 'No Modification Allowed Error' in %s:%d
+Stack trace:
+#0 %s(%d): DOMDocumentFragment->appendXML('<bait>crankbait...')
+#1 {main}
+ thrown in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentFragment_appendXML_error_003.phpt b/ext/dom/tests/DOMDocumentFragment_appendXML_error_003.phpt
new file mode 100644
index 0000000..8735ae6
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentFragment_appendXML_error_003.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMDocumentFragment::appendXML() with unbalanced chunks.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$fragment = $document->createDocumentFragment();
+@$fragment->appendXML('<foo>is<bar>great</foo>');
+$root->appendChild($fragment);
+?>
+--EXPECTF--
+Warning: DOMNode::appendChild(): Document Fragment is empty in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentFragment_appendXML_hasChildNodes_basic.phpt b/ext/dom/tests/DOMDocumentFragment_appendXML_hasChildNodes_basic.phpt
new file mode 100644
index 0000000..c82a73b
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentFragment_appendXML_hasChildNodes_basic.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Testing DOMDocumentFragment::appendXML and DOMDocumentFragment::hasChildNodes
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doc = new DOMDocument();
+
+$fragment = $doc->createDocumentFragment();
+if ($fragment->hasChildNodes()) {
+ echo "has child nodes\n";
+} else {
+ echo "has no child nodes\n";
+}
+$fragment->appendXML('<foo>bar</foo>');
+if ($fragment->hasChildNodes()) {
+ echo "has child nodes\n";
+} else {
+ echo "has no child nodes\n";
+}
+--EXPECT--
+has no child nodes
+has child nodes
diff --git a/ext/dom/tests/DOMDocumentFragment_construct_basic_001.phpt b/ext/dom/tests/DOMDocumentFragment_construct_basic_001.phpt
new file mode 100644
index 0000000..63de771
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentFragment_construct_basic_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMDocumentFragment::__construct().
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$fragment = new DOMDocumentFragment();
+var_dump(get_class($fragment));
+?>
+--EXPECT--
+string(19) "DOMDocumentFragment"
diff --git a/ext/dom/tests/DOMDocumentFragment_construct_basic_002.phpt b/ext/dom/tests/DOMDocumentFragment_construct_basic_002.phpt
new file mode 100644
index 0000000..0d73445
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentFragment_construct_basic_002.phpt
@@ -0,0 +1,16 @@
+--TEST--
+DOMDocumentFragment::__construct() called twice.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$fragment = new DOMDocumentFragment();
+$fragment->__construct();
+var_dump($fragment);
+?>
+--EXPECTF--
+object(DOMDocumentFragment)#%d (%d) {
+}
diff --git a/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt b/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt
new file mode 100644
index 0000000..91173c4
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt
@@ -0,0 +1,17 @@
+--TEST--
+DOMDocumentFragment::__construct() with too many errors.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-24
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$fragment = new DOMDocumentFragment("root");
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'DOMException' with message 'DOMDocumentFragment::__construct() expects exactly 0 parameters, 1 given' in %s:%d
+Stack trace:
+#0 %s(%d): DOMDocumentFragment->__construct('root')
+#1 {main}
+ thrown in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentType_basic_001.phpt b/ext/dom/tests/DOMDocumentType_basic_001.phpt
new file mode 100644
index 0000000..8991ed9
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentType_basic_001.phpt
@@ -0,0 +1,48 @@
+--TEST--
+DOMDocumentType: basic access to all properties.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+// Access publicId, systemId, name, internalSubset all with values.
+$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
+$xml .= '<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML//EN" "docbookx.dtd">';
+$xml .= '<chapter>1</chapter>';
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$doctype = $doc->doctype;
+print "publicId: ".$doctype->publicId."\n";
+print "systemId: ".$doctype->systemId."\n";
+print "name: ".$doctype->name."\n";
+print "internalSubset: ".$doctype->internalSubset."\n";
+
+
+// Access entities and notations with values.
+$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
+$xml .= '<!DOCTYPE img [';
+$xml .= ' <!ELEMENT img EMPTY>';
+$xml .= ' <!ATTLIST img src ENTITY #REQUIRED>';
+$xml .= ' <!ENTITY logo SYSTEM "http://www.xmlwriter.net/logo.gif" NDATA gif>';
+$xml .= ' <!NOTATION gif PUBLIC "gif viewer">';
+$xml .= ']>';
+$xml .= '<img src="logo"/>';
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$doctype = $doc->doctype;
+$entities = $doctype->entities;
+$entity = $entities->item(0);
+print 'entity: '.$entity->nodeName."\n";
+$notations = $doctype->notations;
+$notation = $notations->item(0);
+print 'notation: '.$notation->nodeName."\n";
+?>
+--EXPECT--
+publicId: -//OASIS//DTD DocBook XML//EN
+systemId: docbookx.dtd
+name: chapter
+internalSubset: <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML//EN" "docbookx.dtd">
+entity: logo
+notation: gif \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentType_entities_error_001.phpt b/ext/dom/tests/DOMDocumentType_entities_error_001.phpt
new file mode 100644
index 0000000..73655b0
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentType_entities_error_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMDocumentType::entities with invalid state.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doctype = new DOMDocumentType();
+$entities = $doctype->entities;
+?>
+--EXPECTF--
+Warning: main(): Invalid State Error in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt b/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt
new file mode 100644
index 0000000..c1f7d9b
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMDocumentType::internalSubset with invalid state.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doctype = new DOMDocumentType();
+$internalSubset = $doctype->internalSubset;
+?>
+--EXPECTF--
+Warning: main(): Invalid State Error in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentType_name_error_001.phpt b/ext/dom/tests/DOMDocumentType_name_error_001.phpt
new file mode 100644
index 0000000..d2426e8
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentType_name_error_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMDocumentType::name with invalid state.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doctype = new DOMDocumentType();
+$name = $doctype->name;
+?>
+--EXPECTF--
+Warning: main(): Invalid State Error in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentType_notations_error_001.phpt b/ext/dom/tests/DOMDocumentType_notations_error_001.phpt
new file mode 100644
index 0000000..e4d1c3c
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentType_notations_error_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMDocumentType::notations with invalid state.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doctype = new DOMDocumentType();
+$notations = $doctype->notations;
+?>
+--EXPECTF--
+Warning: main(): Invalid State Error in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentType_publicId_basic_001.phpt b/ext/dom/tests/DOMDocumentType_publicId_basic_001.phpt
new file mode 100644
index 0000000..49a7eec
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentType_publicId_basic_001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMDocumentType::publicId with empty value.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
+$xml .= '<!DOCTYPE chapter SYSTEM "http://www.xmlwriter.net/logo.gif">';
+$xml .= '<chapter>1</chapter>';
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$doctype = $doc->doctype;
+var_dump($doctype->publicId);
+?>
+--EXPECT--
+string(0) "" \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt b/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt
new file mode 100644
index 0000000..275bb65
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMDocumentType::publicId with invalid state.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doctype = new DOMDocumentType();
+$publicId = $doctype->publicId;
+?>
+--EXPECTF--
+Warning: main(): Invalid State Error in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentType_systemId_basic_001.phpt b/ext/dom/tests/DOMDocumentType_systemId_basic_001.phpt
new file mode 100644
index 0000000..56f7ddd
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentType_systemId_basic_001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMDocumentType::systemId with empty value.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
+$xml .= '<!DOCTYPE chapter>';
+$xml .= '<chapter>1</chapter>';
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$doctype = $doc->doctype;
+var_dump($doctype->systemId);
+?>
+--EXPECT--
+string(0) "" \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt b/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt
new file mode 100644
index 0000000..a4aadd7
--- /dev/null
+++ b/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMDocumentType::systemId with invalid state.
+--CREDITS--
+Eric Lee Stewart <ericleestewart@gmail.com>
+# TestFest Atlanta 2009-05-25
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doctype = new DOMDocumentType();
+$systemId = $doctype->systemId;
+?>
+--EXPECTF--
+Warning: main(): Invalid State Error in %s on line %d \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocument_config_basic.phpt b/ext/dom/tests/DOMDocument_config_basic.phpt
new file mode 100644
index 0000000..947743a
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_config_basic.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Tests DOMDocument::config read
+--CREDITS--
+Chris Snyder <chsnyder@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+// create dom document
+$dom = new DOMDocument;
+echo "DOMDocument created\n";
+
+$test = $dom->config;
+echo "Read config:\n";
+var_dump( $test );
+
+// note -- will always be null as DOMConfiguration is not implemented in PHP
+
+echo "Done\n";
+?>
+--EXPECT--
+DOMDocument created
+Read config:
+NULL
+Done
diff --git a/ext/dom/tests/DOMDocument_createAttribute_basic.phpt b/ext/dom/tests/DOMDocument_createAttribute_basic.phpt
new file mode 100644
index 0000000..4dd181b
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_createAttribute_basic.phpt
@@ -0,0 +1,26 @@
+--TEST--
+DomDocument::createAttribute() - basic test for DomDocument::createAttribute()
+--CREDITS--
+Muhammad Khalid Adnan
+# TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$node = $doc->createElement("para");
+$newnode = $doc->appendChild($node);
+
+// A pass case.
+$test_attribute = $doc->createAttribute("hahaha");
+$node->appendChild($test_attribute);
+
+echo $doc->saveXML();
+
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<para hahaha=""/>
+
diff --git a/ext/dom/tests/DOMDocument_createAttribute_error.phpt b/ext/dom/tests/DOMDocument_createAttribute_error.phpt
new file mode 100644
index 0000000..bf71d55
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_createAttribute_error.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Test DOMDocument::createAttribute() for expected expection thrown when wrong parameter passed
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new DOMDocument();
+
+try {
+ $attr = $dom->createAttribute(0);
+}
+catch(DOMException $e) {
+ $code = $e->getCode();
+ if(DOM_INVALID_CHARACTER_ERR === $code) {
+ echo "PASS";
+ }
+ else {
+ echo 'Wrong exception code';
+ }
+}
+catch(Exception $e) {
+ echo 'Wrong exception thrown';
+}
+
+?>
+--EXPECTF--
+PASS
diff --git a/ext/dom/tests/DOMDocument_createAttribute_error1.phpt b/ext/dom/tests/DOMDocument_createAttribute_error1.phpt
new file mode 100644
index 0000000..745873a
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_createAttribute_error1.phpt
@@ -0,0 +1,29 @@
+--TEST--
+DomDocument::createAttribute() - error test for DomDocument::createAttribute()
+--CREDITS--
+Muhammad Khalid Adnan
+# TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$node = $doc->createElement("para");
+$newnode = $doc->appendChild($node);
+
+try {
+ $failed_test_attribute = $doc->createAttribute("ha haha");
+ $node->appendChild($failed_test_attribute);
+
+ echo $doc->saveXML();
+}
+catch (DOMException $e) {
+ echo 'Test failed!', PHP_EOL;
+}
+
+?>
+--EXPECT--
+Test failed!
+
diff --git a/ext/dom/tests/DOMDocument_createAttribute_variation.phpt b/ext/dom/tests/DOMDocument_createAttribute_variation.phpt
new file mode 100644
index 0000000..ff81343
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_createAttribute_variation.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Test DOMDocument::createAttribute() for expected return value
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new DOMDocument();
+
+$attr = $dom->createAttribute('string');
+echo get_class($attr);
+
+?>
+--EXPECTF--
+DOMAttr
diff --git a/ext/dom/tests/DOMDocument_createEntityReference_basic.phpt b/ext/dom/tests/DOMDocument_createEntityReference_basic.phpt
new file mode 100644
index 0000000..4f4ddf1
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_createEntityReference_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMDocument::createEntityReference() should create a new entity reference node
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$dom = new DOMDocument('1.0');
+$ref = $dom->createEntityReference('nbsp');
+$dom->appendChild($ref);
+echo $dom->saveXML();
+?>
+--EXPECTF--
+<?xml version="1.0"?>
+&nbsp;
diff --git a/ext/dom/tests/DOMDocument_createProcessingInstruction_basic.phpt b/ext/dom/tests/DOMDocument_createProcessingInstruction_basic.phpt
new file mode 100644
index 0000000..9f45f12
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_createProcessingInstruction_basic.phpt
@@ -0,0 +1,30 @@
+--TEST--
+DomDocument::createProcessingInstruction() - basic test for DomDocument::createProcessingInstruction()
+--CREDITS--
+Muhammad Khalid Adnan
+# TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$node = $doc->createElement("para");
+$newnode = $doc->appendChild($node);
+
+$test_proc_inst0 =
+ $doc->createProcessingInstruction( "blablabla" );
+$node->appendChild($test_proc_inst0);
+
+$test_proc_inst1 =
+ $doc->createProcessingInstruction( "blablabla", "datadata" );
+$node->appendChild($test_proc_inst1);
+
+echo $doc->saveXML();
+
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<para><?blablabla?><?blablabla datadata?></para>
+
diff --git a/ext/dom/tests/DOMDocument_createProcessingInstruction_error.phpt b/ext/dom/tests/DOMDocument_createProcessingInstruction_error.phpt
new file mode 100644
index 0000000..a0c12b1
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_createProcessingInstruction_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+DomDocument::createProcessingInstruction() - error test for DomDocument::createProcessingInstruction()
+--CREDITS--
+Muhammad Khalid Adnan
+# TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$node = $doc->createElement("para");
+$newnode = $doc->appendChild($node);
+
+try {
+ $test_proc_inst =
+ $doc->createProcessingInstruction( "bla bla bla" );
+ $node->appendChild($test_proc_inst);
+
+ echo $doc->saveXML();
+}
+catch (DOMException $e)
+{
+ echo 'Test failed!', PHP_EOL;
+}
+
+?>
+--EXPECT--
+Test failed!
+
diff --git a/ext/dom/tests/DOMDocument_documentURI_basic.phpt b/ext/dom/tests/DOMDocument_documentURI_basic.phpt
new file mode 100644
index 0000000..e40a42b
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_documentURI_basic.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Tests DOMDocument::documentURI read and write
+--CREDITS--
+Chris Snyder <chsnyder@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+// create dom document
+$dom = new DOMDocument;
+$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
+<s1>foo</s1>';
+$dom->loadXML($xml);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+echo "DOMDocument created\n";
+
+$test = $dom->documentURI;
+echo "Read initial documentURI:\n";
+echo $test."\n";
+
+$dom->documentURI = 'http://dom.example.org/example.xml';
+$test = $dom->documentURI;
+echo "Set documentURI to a URL, reading again:\n";
+var_dump( $test );
+
+echo "Done\n";
+?>
+--EXPECTF--
+DOMDocument created
+Read initial documentURI:
+%s
+Set documentURI to a URL, reading again:
+string(34) "http://dom.example.org/example.xml"
+Done
diff --git a/ext/dom/tests/DOMDocument_encoding_basic.phpt b/ext/dom/tests/DOMDocument_encoding_basic.phpt
new file mode 100644
index 0000000..9fc099b
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_encoding_basic.phpt
@@ -0,0 +1,52 @@
+--TEST--
+DOMDocument::$encoding - read/write tests (dom_document_encoding_read/dom_document_encoding_write)
+--CREDITS--
+Hans Zaunere
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('dom_test.inc');
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+
+if( !$dom )
+{
+ echo "Error while parsing the document\n";
+ exit;
+}
+
+echo "Empty Encoding Read: {$dom->encoding}\n";
+
+$ret = $dom->encoding = 'NYPHP DOMinatrix';
+echo "Adding invalid encoding: $ret\n";
+
+$ret = $dom->encoding = 'ISO-8859-1';
+echo "Adding ISO-8859-1 encoding: $ret\n";
+echo "ISO-8859-1 Encoding Read: {$dom->encoding}\n";
+
+$ret = $dom->encoding = 'UTF-8';
+echo "Adding UTF-8 encoding: $ret\n";
+echo "UTF-8 Encoding Read: {$dom->encoding}\n";
+
+$ret = $dom->encoding = 'UTF-16';
+echo "Adding UTF-16 encoding: $ret\n";
+echo "UTF-16 Encoding Read: {$dom->encoding}\n";
+
+
+?>
+--EXPECTF--
+Empty Encoding Read:
+
+Warning: main(): Invalid Document Encoding in %s on line %d
+Adding invalid encoding: NYPHP DOMinatrix
+Adding ISO-8859-1 encoding: ISO-8859-1
+ISO-8859-1 Encoding Read: ISO-8859-1
+Adding UTF-8 encoding: UTF-8
+UTF-8 Encoding Read: UTF-8
+Adding UTF-16 encoding: UTF-16
+UTF-16 Encoding Read: UTF-16
+
diff --git a/ext/dom/tests/DOMDocument_implementationRead_basic.phpt b/ext/dom/tests/DOMDocument_implementationRead_basic.phpt
new file mode 100644
index 0000000..17daddf
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_implementationRead_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+DOMDocument::DOMImplementation - basic test for DomDocument::DOMImplementation
+--CREDITS--
+Lev Radin <prokurator@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+$doc->load(dirname(__FILE__)."/book.xml");
+
+var_dump($doc->implementation);
+
+
+?>
+--EXPECTF--
+object(DOMImplementation)#%d (0) {
+}
+
diff --git a/ext/dom/tests/DOMDocument_loadHTML_basic.phpt b/ext/dom/tests/DOMDocument_loadHTML_basic.phpt
new file mode 100644
index 0000000..616d1d8
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadHTML_basic.phpt
@@ -0,0 +1,18 @@
+--TEST--
+DOMDocument::loadHTML
+--CREDITS--
+Frank Cassedanne franck@ouarz.net
+#London TestFest 2008
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$doc = new DOMDocument();
+$doc->loadHTML("<html><body><p>Test<br></p></body></html>");
+echo $doc->saveHTML();
+?>
+--EXPECTF--
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html><body><p>Test<br></p></body></html>
diff --git a/ext/dom/tests/DOMDocument_loadHTML_error1.phpt b/ext/dom/tests/DOMDocument_loadHTML_error1.phpt
new file mode 100644
index 0000000..de8d349
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadHTML_error1.phpt
@@ -0,0 +1,15 @@
+--TEST--
+DOMDocument::loadHTML() should fail if no parameter is given
+--CREDITS--
+Knut Urdalen <knut@php.net>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$doc = new DOMDocument();
+$doc->loadHTML();
+?>
+--EXPECTF--
+Warning: DOMDocument::loadHTML() expects at least 1 parameter, 0 given in %s on line %d
diff --git a/ext/dom/tests/DOMDocument_loadHTML_error2.phpt b/ext/dom/tests/DOMDocument_loadHTML_error2.phpt
new file mode 100644
index 0000000..3167c01
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadHTML_error2.phpt
@@ -0,0 +1,15 @@
+--TEST--
+DOMDocument::loadHTML() should fail if empty string provided as input
+--CREDITS--
+Knut Urdalen <knut@php.net>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$doc = new DOMDocument();
+$doc->loadHTML('');
+?>
+--EXPECTF--
+Warning: DOMDocument::loadHTML(): Empty string supplied as input in %s on line %d
diff --git a/ext/dom/tests/DOMDocument_preserveWhiteSpace_basic.phpt b/ext/dom/tests/DOMDocument_preserveWhiteSpace_basic.phpt
new file mode 100644
index 0000000..a772bc8
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_preserveWhiteSpace_basic.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DOMDocument::$preserveWhiteSpace - test ability to read and write property
+--CREDITS--
+Lev Radin <prokurator@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+$doc->load(dirname(__FILE__)."/book.xml");
+
+var_dump($doc->preserveWhiteSpace);
+
+$doc->preserveWhiteSpace = false;
+var_dump($doc->preserveWhiteSpace);
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
+
diff --git a/ext/dom/tests/DOMDocument_preserveWhiteSpace_variations.phpt b/ext/dom/tests/DOMDocument_preserveWhiteSpace_variations.phpt
new file mode 100644
index 0000000..e467f56
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_preserveWhiteSpace_variations.phpt
@@ -0,0 +1,40 @@
+--TEST--
+DOMDocument::$preserveWhiteSpace - test ability to read and write property
+--CREDITS--
+Lev Radin <prokurator@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+echo "Load document with preserveWhiteSpace on\n";
+$doc = new DOMDocument;
+$doc->load(dirname(__FILE__)."/book.xml");
+echo $doc->saveXML();
+
+
+echo "\nLoad document with preserveWhiteSpace off\n";
+$doc = new DOMDocument;
+$doc->preserveWhiteSpace = false;
+$doc->load(dirname(__FILE__)."/book.xml");
+echo $doc->saveXML();
+
+?>
+--EXPECT--
+Load document with preserveWhiteSpace on
+<?xml version="1.0"?>
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
+
+Load document with preserveWhiteSpace off
+<?xml version="1.0"?>
+<books><book><title>The Grapes of Wrath</title><author>John Steinbeck</author></book><book><title>The Pearl</title><author>John Steinbeck</author></book></books>
diff --git a/ext/dom/tests/DOMDocument_relaxNGValidateSource_basic.phpt b/ext/dom/tests/DOMDocument_relaxNGValidateSource_basic.phpt
new file mode 100644
index 0000000..93b9cf7
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_relaxNGValidateSource_basic.phpt
@@ -0,0 +1,39 @@
+--TEST--
+DOMDocument::relaxNGValidateSource()
+--CREDITS--
+Knut Urdalen <knut@php.net>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$rng = <<< RNG
+<?xml version="1.0" encoding="UTF-8"?>
+<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0"
+ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+ <start>
+ <element name="apple">
+ <element name="pear">
+ <data type="NCName"/>
+ </element>
+ </element>
+ </start>
+</grammar>
+RNG;
+
+$good_xml = <<< GOOD_XML
+<?xml version="1.0"?>
+<apple>
+ <pear>Pear</pear>
+</apple>
+GOOD_XML;
+
+$doc = new DOMDocument();
+$doc->loadXML($good_xml);
+$result = $doc->relaxNGValidateSource($rng);
+var_dump($result);
+
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/dom/tests/DOMDocument_relaxNGValidateSource_error1.phpt b/ext/dom/tests/DOMDocument_relaxNGValidateSource_error1.phpt
new file mode 100644
index 0000000..7da71a5
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_relaxNGValidateSource_error1.phpt
@@ -0,0 +1,41 @@
+--TEST--
+DOMDocument::relaxNGValidateSource() should fail if document doesn't validate
+--CREDITS--
+Knut Urdalen <knut@php.net>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$rng = <<< RNG
+<?xml version="1.0" encoding="UTF-8"?>
+<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0"
+ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+ <start>
+ <element name="apple">
+ <element name="pear">
+ <data type="NCName"/>
+ </element>
+ </element>
+ </start>
+</grammar>
+RNG;
+
+$bad_xml = <<< BAD_XML
+<?xml version="1.0"?>
+<apple>
+ <pear>Pear</pear>
+ <pear>Pear</pear>
+</apple>
+BAD_XML;
+
+$doc = new DOMDocument();
+$doc->loadXML($bad_xml);
+$result = $doc->relaxNGValidateSource($rng);
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::relaxNGValidateSource(): Did not expect element pear there in %s on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_relaxNGValidateSource_error2.phpt b/ext/dom/tests/DOMDocument_relaxNGValidateSource_error2.phpt
new file mode 100644
index 0000000..d689934
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_relaxNGValidateSource_error2.phpt
@@ -0,0 +1,39 @@
+--TEST--
+DOMDocument::relaxNGValidateSource() should fail on invalid RNG schema
+--CREDITS--
+Knut Urdalen <knut@php.net>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$rng = <<< RNG
+<?xml version="1.0" encoding="UTF-8"?>
+<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0"
+ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+ <start>
+ <element name="apple">
+ </element>
+ </start>
+</grammar>
+RNG;
+
+$xml = <<< XML
+<?xml version="1.0"?>
+<apple>
+ <pear>Pear</pear>
+</apple>
+XML;
+
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$result = $doc->relaxNGValidateSource($rng);
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::relaxNGValidateSource(): xmlRelaxNGParseElement: element has no content in %s on line %d
+
+Warning: DOMDocument::relaxNGValidateSource(): Invalid RelaxNG in %s on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_relaxNGValidate_basic.phpt b/ext/dom/tests/DOMDocument_relaxNGValidate_basic.phpt
new file mode 100644
index 0000000..76a6442
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_relaxNGValidate_basic.phpt
@@ -0,0 +1,24 @@
+--TEST--
+DOMDocument::relaxNGValidate()
+--CREDITS--
+Knut Urdalen <knut@php.net>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$rng = dirname(__FILE__).'/DOMDocument_relaxNGValidate_basic.rng';
+$xml = <<< XML
+<?xml version="1.0"?>
+<apple>
+ <pear>Pear</pear>
+</apple>
+XML;
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$result = $doc->relaxNGValidate($rng);
+var_dump($result);
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/dom/tests/DOMDocument_relaxNGValidate_basic.rng b/ext/dom/tests/DOMDocument_relaxNGValidate_basic.rng
new file mode 100644
index 0000000..35e3518
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_relaxNGValidate_basic.rng
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0"
+ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+ <start>
+ <element name="apple">
+ <element name="pear">
+ <data type="NCName"/>
+ </element>
+ </element>
+ </start>
+</grammar>
diff --git a/ext/dom/tests/DOMDocument_relaxNGValidate_error1.phpt b/ext/dom/tests/DOMDocument_relaxNGValidate_error1.phpt
new file mode 100644
index 0000000..82957c3
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_relaxNGValidate_error1.phpt
@@ -0,0 +1,26 @@
+--TEST--
+DOMDocument::relaxNGValidate() should fail if document doesn't validate
+--CREDITS--
+Knut Urdalen <knut@php.net>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$rng = dirname(__FILE__).'/DOMDocument_relaxNGValidate_basic.rng';
+$xml = <<< XML
+<?xml version="1.0"?>
+<apple>
+ <pear>Pear</pear>
+ <pear>Pear</pear>
+</apple>
+XML;
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$result = $doc->relaxNGValidate($rng);
+var_dump($result);
+?>
+--EXPECTF--
+Warning: DOMDocument::relaxNGValidate(): Did not expect element pear there in %s on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_relaxNGValidate_error2.phpt b/ext/dom/tests/DOMDocument_relaxNGValidate_error2.phpt
new file mode 100644
index 0000000..7c5f890
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_relaxNGValidate_error2.phpt
@@ -0,0 +1,31 @@
+--TEST--
+DOMDocument::relaxNGValidate() should fail on invalid RelaxNG file source
+--CREDITS--
+Knut Urdalen <knut@php.net>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$rng = dirname(__FILE__).'/foo.rng';
+$xml = <<< XML
+<?xml version="1.0"?>
+<apple>
+ <pear>Pear</pear>
+ <pear>Pear</pear>
+</apple>
+XML;
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$result = $doc->relaxNGValidate($rng);
+var_dump($result);
+?>
+--EXPECTF--
+
+Warning: DOMDocument::relaxNGValidate(): I/O warning : failed to load external entity "%s/foo.rng" in %s on line %d
+
+Warning: DOMDocument::relaxNGValidate(): xmlRelaxNGParse: could not load %s/foo.rng in %s on line %d
+
+Warning: DOMDocument::relaxNGValidate(): Invalid RelaxNG in %s on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_resolveExternals_basic.phpt b/ext/dom/tests/DOMDocument_resolveExternals_basic.phpt
new file mode 100644
index 0000000..ccada3f
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_resolveExternals_basic.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Tests DOMDocument::resoleExternals get and set
+--CREDITS--
+Chris Snyder <chsnyder@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+// create dom document
+$dom = new DOMDocument;
+$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<h1>&quot;Foo&quot;</h1>';
+$dom->loadXML($xml);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+echo "DOMDocument with external entities created\n";
+
+$test = $dom->resolveExternals;
+echo "Read initial resolveExternals:\n";
+var_dump( $test );
+
+$dom->resolveExternals = TRUE;
+$test = $dom->resolveExternals;
+echo "Set resolveExternals to TRUE, reading again:\n";
+var_dump( $test );
+
+/**
+ * Don't bother testing the resolveExternals functionality here, it throws warnings on html dtd
+ *
+echo "Reloading xml with resolveExternals turned on\n";
+$dom->loadXML($xml);
+$test = $dom->saveXML();
+var_dump( $test );
+ */
+
+echo "Done";
+?>
+--EXPECT--
+DOMDocument with external entities created
+Read initial resolveExternals:
+bool(false)
+Set resolveExternals to TRUE, reading again:
+bool(true)
+Done \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_basic.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_basic.phpt
new file mode 100644
index 0000000..dd0824b
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_saveHTMLFile_basic.phpt
@@ -0,0 +1,29 @@
+--TEST--
+DOMDocument::saveHTMLFile() should dump the internal document into a file using HTML formatting
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$filename = dirname(__FILE__)."/tmp_savehtmlfile".time().".html";
+$doc = new DOMDocument('1.0');
+$root = $doc->createElement('html');
+$root = $doc->appendChild($root);
+$head = $doc->createElement('head');
+$head = $root->appendChild($head);
+$title = $doc->createElement('title');
+$title = $head->appendChild($title);
+$text = $doc->createTextNode('This is the title');
+$text = $title->appendChild($text);
+$bytes = $doc->saveHTMLFile($filename);
+var_dump($bytes);
+echo file_get_contents($filename);
+unlink($filename);
+?>
+--EXPECTF--
+int(126)
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>This is the title</title></head></html>
diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_error1.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_error1.phpt
new file mode 100644
index 0000000..d4dfbe8
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_saveHTMLFile_error1.phpt
@@ -0,0 +1,24 @@
+--TEST--
+DOMDocument::saveHTMLFile() should fail if no parameter is given
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$doc = new DOMDocument('1.0');
+$root = $doc->createElement('html');
+$root = $doc->appendChild($root);
+$head = $doc->createElement('head');
+$head = $root->appendChild($head);
+$title = $doc->createElement('title');
+$title = $head->appendChild($title);
+$text = $doc->createTextNode('This is the title');
+$text = $title->appendChild($text);
+$doc->saveHTMLFile();
+?>
+--EXPECTF--
+Warning: DOMDocument::saveHTMLFile() expects exactly 1 parameter, 0 given in %s on line %d
diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_error2.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_error2.phpt
new file mode 100644
index 0000000..33e07c6
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_saveHTMLFile_error2.phpt
@@ -0,0 +1,15 @@
+--TEST--
+DOMDocument::saveHTMLFile() should fail if called statically
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+DOMDocument::saveHTMLFile();
+?>
+--EXPECTF--
+Fatal error: Non-static method DOMDocument::saveHTMLFile() cannot be called statically in %s on line %d
diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_formatOutput.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_formatOutput.phpt
new file mode 100644
index 0000000..5aece37
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_saveHTMLFile_formatOutput.phpt
@@ -0,0 +1,33 @@
+--TEST--
+DOMDocument::saveHTMLFile() should format output on demand
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$filename = dirname(__FILE__)."/tmp_savehtmlfile".time().".html";
+$doc = new DOMDocument('1.0');
+$doc->formatOutput = true;
+$root = $doc->createElement('html');
+$root = $doc->appendChild($root);
+$head = $doc->createElement('head');
+$head = $root->appendChild($head);
+$title = $doc->createElement('title');
+$title = $head->appendChild($title);
+$text = $doc->createTextNode('This is the title');
+$text = $title->appendChild($text);
+$bytes = $doc->saveHTMLFile($filename);
+var_dump($bytes);
+echo file_get_contents($filename);
+unlink($filename);
+?>
+--EXPECTF--
+int(129)
+<html><head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>This is the title</title>
+</head></html>
diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt
new file mode 100644
index 0000000..d5c6a79
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt
@@ -0,0 +1,25 @@
+--TEST--
+DOMDocument::saveHTMLFile() should fail with invalid filename
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$filename = null;
+$doc = new DOMDocument('1.0');
+$root = $doc->createElement('html');
+$root = $doc->appendChild($root);
+$head = $doc->createElement('head');
+$head = $root->appendChild($head);
+$title = $doc->createElement('title');
+$title = $head->appendChild($title);
+$text = $doc->createTextNode('This is the title');
+$text = $title->appendChild($text);
+$bytes = $doc->saveHTMLFile($filename);
+?>
+--EXPECTF--
+Warning: DOMDocument::saveHTMLFile(): Invalid Filename in %s on line %d
diff --git a/ext/dom/tests/DOMDocument_saveHTML_basic.phpt b/ext/dom/tests/DOMDocument_saveHTML_basic.phpt
new file mode 100644
index 0000000..76f1ed0
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_saveHTML_basic.phpt
@@ -0,0 +1,24 @@
+--TEST--
+DOMDocument::saveHTML() should dump the internal document into a string using HTML formatting
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$doc = new DOMDocument('1.0');
+$root = $doc->createElement('html');
+$root = $doc->appendChild($root);
+$head = $doc->createElement('head');
+$head = $root->appendChild($head);
+$title = $doc->createElement('title');
+$title = $head->appendChild($title);
+$text = $doc->createTextNode('This is the title');
+$text = $title->appendChild($text);
+echo $doc->saveHTML();
+?>
+--EXPECTF--
+<html><head><title>This is the title</title></head></html>
diff --git a/ext/dom/tests/DOMDocument_saveHTML_error2.phpt b/ext/dom/tests/DOMDocument_saveHTML_error2.phpt
new file mode 100644
index 0000000..614605b
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_saveHTML_error2.phpt
@@ -0,0 +1,15 @@
+--TEST--
+DOMDocument::saveHTML() should fail if called statically
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+DOMDocument::saveHTML(true);
+?>
+--EXPECTF--
+Fatal error: Non-static method DOMDocument::saveHTML() cannot be called statically in %s on line %d
diff --git a/ext/dom/tests/DOMDocument_saveHTML_variant1.phpt b/ext/dom/tests/DOMDocument_saveHTML_variant1.phpt
new file mode 100644
index 0000000..d169113
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_saveHTML_variant1.phpt
@@ -0,0 +1,24 @@
+--TEST--
+DOMDocument::saveHTML() optional parameters
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$doc = new DOMDocument('1.0');
+$root = $doc->createElement('html');
+$root = $doc->appendChild($root);
+$head = $doc->createElement('head');
+$head = $root->appendChild($head);
+$title = $doc->createElement('title');
+$title = $head->appendChild($title);
+$text = $doc->createTextNode('This is the title');
+$text = $title->appendChild($text);
+echo $doc->saveHTML(NULL), "\n";
+echo $doc->saveHTML($title), "\n";
+?>
+--EXPECTF--
+<html><head><title>This is the title</title></head></html>
+
+<title>This is the title</title>
diff --git a/ext/dom/tests/DOMDocument_saveHTML_variant2.phpt b/ext/dom/tests/DOMDocument_saveHTML_variant2.phpt
new file mode 100644
index 0000000..54ccda1
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_saveHTML_variant2.phpt
@@ -0,0 +1,26 @@
+--TEST--
+DOMDocument::saveHTML() vs DOMDocumet::saveXML()
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$d = new DOMDocument();
+$str = <<<EOD
+<html>
+<head>
+</head>
+<body>
+<p>Hi.<br/>there</p>
+</body>
+</html>
+EOD;
+$d->loadHTML($str);
+$e = $d->getElementsByTagName("p");
+$e = $e->item(0);
+echo $d->saveXml($e),"\n";
+echo $d->saveHtml($e),"\n";
+--EXPECTF--
+<p>Hi.<br/>there</p>
+<p>Hi.<br>there</p>
diff --git a/ext/dom/tests/DOMDocument_save_basic.phpt b/ext/dom/tests/DOMDocument_save_basic.phpt
new file mode 100644
index 0000000..c7d1ead
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_save_basic.phpt
@@ -0,0 +1,33 @@
+--TEST--
+DOMDocument::save Test basic function of save method
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$doc = new DOMDocument('1.0');
+$doc->formatOutput = true;
+
+$root = $doc->createElement('book');
+
+$root = $doc->appendChild($root);
+
+$title = $doc->createElement('title');
+$title = $root->appendChild($title);
+
+$text = $doc->createTextNode('This is the title');
+$text = $title->appendChild($text);
+
+$temp_filename = dirname(__FILE__)."/DomDocument_save_basic.tmp";
+
+echo 'Wrote: ' . $doc->save($temp_filename) . ' bytes'; // Wrote: 72 bytes
+?>
+--CLEAN--
+<?php
+ $temp_filename = dirname(__FILE__)."/DomDocument_save_basic.tmp";
+ unlink($temp_filename);
+?>
+--EXPECTF--
+Wrote: 72 bytes
+
diff --git a/ext/dom/tests/DOMDocument_savexml_basic.phpt b/ext/dom/tests/DOMDocument_savexml_basic.phpt
new file mode 100644
index 0000000..10f748c
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_savexml_basic.phpt
@@ -0,0 +1,39 @@
+--TEST--
+DOM Document : save and saveXML
+--CREDITS--
+Sami Greenbury (sami@patabugen.co.uk)
+# TestFest 2008
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+$xml = <<< EOXML
+<?xml version="1.0" encoding="utf-8"?>
+<courses>
+ <!-- Hello World! -->
+ <aNode>
+ <childNode>
+ <childlessNode />
+ </childNode>
+ </aNode>
+</courses>
+EOXML;
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+$root = $dom->documentElement;
+$directory = dirname(__FILE__);
+
+$filename = $directory."/tmp_dom_savexml".time();
+var_dump($dom->save($filename));
+$result = file_get_contents($filename);
+var_dump($result == $dom->saveXML());
+
+unlink($filename);
+
+--EXPECTF--
+int(151)
+bool(true) \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_basic.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_basic.phpt
new file mode 100644
index 0000000..38bc3fa
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidateSource_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+DomDocument::schemaValidateSource() - basic
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$xsd = file_get_contents(dirname(__FILE__)."/book.xsd");
+
+$result = $doc->schemaValidateSource($xsd);
+var_dump($result);
+
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error1.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error1.phpt
new file mode 100644
index 0000000..51eb82e
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error1.phpt
@@ -0,0 +1,29 @@
+--TEST--
+DomDocument::schemaValidateSource() - string that is not a schema
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidateSource('string that is not a schema');
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidateSource(): Entity: line 1: parser error : Start tag expected, '<' not found in %s.php on line %d
+
+Warning: DOMDocument::schemaValidateSource(): string that is not a schema in %s.php on line %d
+
+Warning: DOMDocument::schemaValidateSource(): ^ in %s.php on line %d
+
+Warning: DOMDocument::schemaValidateSource(): Failed to parse the XML resource 'in_memory_buffer'. in %s.php on line %d
+
+Warning: DOMDocument::schemaValidateSource(): Invalid Schema in %s.php on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error2.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error2.phpt
new file mode 100644
index 0000000..41a833b
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error2.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DomDocument::schemaValidateSource() - non-conforming schema
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$xsd = file_get_contents(dirname(__FILE__)."/book-non-conforming-schema.xsd");
+
+$result = $doc->schemaValidateSource($xsd);
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidateSource(): Element 'books': No matching global declaration available for the validation root. in %s.php on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error3.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error3.phpt
new file mode 100644
index 0000000..93dd792
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error3.phpt
@@ -0,0 +1,21 @@
+--TEST--
+DomDocument::schemaValidateSource() - empty string for schema string
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidateSource('');
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidateSource(): Invalid Schema source in %s.php on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt
new file mode 100644
index 0000000..65c8d86
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt
@@ -0,0 +1,21 @@
+--TEST--
+DomDocument::schemaValidateSource() - pass no parameters
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidateSource();
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidateSource() expects exactly 1 parameter, 0 given in %s.php on line %d
+NULL
diff --git a/ext/dom/tests/DOMDocument_schemaValidate_basic.phpt b/ext/dom/tests/DOMDocument_schemaValidate_basic.phpt
new file mode 100644
index 0000000..eec790d
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidate_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+DomDocument::schemaValidate() - basic
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidate(dirname(__FILE__)."/book.xsd");
+var_dump($result);
+
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error1.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error1.phpt
new file mode 100644
index 0000000..594c3c4
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidate_error1.phpt
@@ -0,0 +1,29 @@
+--TEST--
+DomDocument::schemaValidate() - file that is not a schema
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidate(dirname(__FILE__)."/book-not-a-schema.xsd");
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidate(): %sbook-not-a-schema.xsd:1: parser error : Start tag expected, '<' not found in %s.php on line %d
+
+Warning: DOMDocument::schemaValidate(): Let's see what happens upon parsing a file that doesn't contain a schema. in %s.php on line %d
+
+Warning: DOMDocument::schemaValidate(): ^ in %s.php on line %d
+
+Warning: DOMDocument::schemaValidate(): Failed to parse the XML resource '%sbook-not-a-schema.xsd'. in %s.php on line %d
+
+Warning: DOMDocument::schemaValidate(): Invalid Schema in %s.php on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error2.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error2.phpt
new file mode 100644
index 0000000..5ffd533
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidate_error2.phpt
@@ -0,0 +1,21 @@
+--TEST--
+DomDocument::schemaValidate() - non-conforming schema file
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidate(dirname(__FILE__)."/book-non-conforming-schema.xsd");
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidate(): Element 'books': No matching global declaration available for the validation root. in %s.php on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error3.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error3.phpt
new file mode 100644
index 0000000..275204f
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidate_error3.phpt
@@ -0,0 +1,21 @@
+--TEST--
+DomDocument::schemaValidate() - empty string for schema file name
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidate('');
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidate(): Invalid Schema source in %s.php on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt
new file mode 100644
index 0000000..d4817de
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt
@@ -0,0 +1,21 @@
+--TEST--
+DomDocument::schemaValidate() - pass no parameters
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidate();
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidate() expects exactly 1 parameter, 0 given in %s.php on line %d
+NULL
diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error5.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error5.phpt
new file mode 100644
index 0000000..d3f0658
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidate_error5.phpt
@@ -0,0 +1,25 @@
+--TEST--
+DomDocument::schemaValidate() - non-existant schema file
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidate(dirname(__FILE__)."/non-existant-file");
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidate(): I/O warning : failed to load external entity "%snon-existant-file" in %s.php on line %d
+
+Warning: DOMDocument::schemaValidate(): Failed to locate the main schema resource at '%s/non-existant-file'. in %s.php on line %d
+
+Warning: DOMDocument::schemaValidate(): Invalid Schema in %s.php on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_standalone_basic.phpt b/ext/dom/tests/DOMDocument_standalone_basic.phpt
new file mode 100644
index 0000000..2316a38
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_standalone_basic.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Tests DOMDocument::standalone get, set, and functionality
+--CREDITS--
+Chris Snyder <chsnyder@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+// create dom document
+$dom = new DOMDocument;
+$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
+<s1>foo</s1>';
+$dom->loadXML($xml);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+echo "Standalone DOMDocument created\n";
+
+$test = $dom->standalone;
+echo "Read initial standalone:\n";
+var_dump( $test );
+
+$dom->standalone = FALSE;
+$test = $dom->standalone;
+echo "Set standalone to FALSE, reading again:\n";
+var_dump( $test );
+
+$test = $dom->saveXML();
+echo "Document is no longer standalone\n";
+var_dump( $test );
+
+echo "Done";
+?>
+--EXPECT--
+Standalone DOMDocument created
+Read initial standalone:
+bool(true)
+Set standalone to FALSE, reading again:
+bool(false)
+Document is no longer standalone
+string(136) "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
+<s1>foo</s1>
+"
+Done \ No newline at end of file
diff --git a/ext/dom/tests/DOMDocument_strictErrorChecking_basic.phpt b/ext/dom/tests/DOMDocument_strictErrorChecking_basic.phpt
new file mode 100644
index 0000000..9ad55a4
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_strictErrorChecking_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+DomDocument::$strictErrorChecking - basic test
+--CREDITS--
+Vincent Tsao <notes4vincent@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+$doc->load(dirname(__FILE__)."/book.xml");
+
+var_dump($doc->strictErrorChecking);
+
+$doc->strictErrorChecking = false;
+var_dump($doc->strictErrorChecking);
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_strictErrorChecking_variation.phpt b/ext/dom/tests/DOMDocument_strictErrorChecking_variation.phpt
new file mode 100644
index 0000000..b6d94f9
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_strictErrorChecking_variation.phpt
@@ -0,0 +1,59 @@
+--TEST--
+DomDocument::$strictErrorChecking - ensure turning off actually works
+--CREDITS--
+Vincent Tsao <notes4vincent@gmail.com>
+(and Dan Convissor)
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+echo "Load document\n";
+$doc = new DOMDocument;
+$doc->load(dirname(__FILE__)."/book.xml");
+
+echo "See if strictErrorChecking is on\n";
+var_dump($doc->strictErrorChecking);
+
+echo "Should throw DOMException when strictErrorChecking is on\n";
+try {
+ $attr = $doc->createAttribute(0);
+} catch (DOMException $e) {
+ echo "GOOD. DOMException thrown\n";
+ echo $e->getMessage() ."\n";
+} catch (Exception $e) {
+ echo "OOPS. Other exception thrown\n";
+}
+
+
+echo "Turn strictErrorChecking off\n";
+$doc->strictErrorChecking = false;
+
+echo "See if strictErrorChecking is off\n";
+var_dump($doc->strictErrorChecking);
+
+echo "Should raise PHP error because strictErrorChecking is off\n";
+try {
+ $attr = $doc->createAttribute(0);
+} catch (DOMException $e) {
+ echo "OOPS. DOMException thrown\n";
+ echo $e->getMessage() ."\n";
+} catch (Exception $e) {
+ echo "OOPS. Other exception thrown\n";
+}
+
+?>
+--EXPECTF--
+Load document
+See if strictErrorChecking is on
+bool(true)
+Should throw DOMException when strictErrorChecking is on
+GOOD. DOMException thrown
+Invalid Character Error
+Turn strictErrorChecking off
+See if strictErrorChecking is off
+bool(false)
+Should raise PHP error because strictErrorChecking is off
+
+Warning: DOMDocument::createAttribute(): Invalid Character Error in %sDOMDocument_strictErrorChecking_variation.php on line %d
diff --git a/ext/dom/tests/DOMDocument_validate_basic.phpt b/ext/dom/tests/DOMDocument_validate_basic.phpt
new file mode 100644
index 0000000..7c0eec8
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_validate_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+DOMDocument::validate() should validate an internal DTD declaration
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$xml = "<?xml version=\"1.0\"?>
+<!DOCTYPE note [
+<!ELEMENT note (to,from,heading,body)>
+<!ELEMENT to (#PCDATA)>
+<!ELEMENT from (#PCDATA)>
+<!ELEMENT heading (#PCDATA)>
+<!ELEMENT body (#PCDATA)>
+]>
+<note>
+<to>Tove</to>
+<from>Jani</from>
+<heading>Reminder</heading>
+<body>Don't forget me this weekend</body>
+</note>";
+$dom = new DOMDocument('1.0');
+$dom->loadXML($xml);
+var_dump($dom->validate());
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/dom/tests/DOMDocument_validate_error1.phpt b/ext/dom/tests/DOMDocument_validate_error1.phpt
new file mode 100644
index 0000000..8e1e72f
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_validate_error1.phpt
@@ -0,0 +1,16 @@
+--TEST--
+DOMDocument::validate() should fail if any parameter is given
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+$dom = new DOMDocument('1.0');
+$dom->validate(true);
+?>
+--EXPECTF--
+Warning: DOMDocument::validate() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/dom/tests/DOMDocument_validate_error2.phpt b/ext/dom/tests/DOMDocument_validate_error2.phpt
new file mode 100644
index 0000000..fe7e4fc
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_validate_error2.phpt
@@ -0,0 +1,15 @@
+--TEST--
+DOMDocument::validate() should fail if called statically
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+DOMDocument::validate();
+?>
+--EXPECTF--
+Fatal error: Non-static method DOMDocument::validate() cannot be called statically in %s on line %d
diff --git a/ext/dom/tests/DOMDocument_validate_external_dtd.phpt b/ext/dom/tests/DOMDocument_validate_external_dtd.phpt
new file mode 100644
index 0000000..51a044c
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_validate_external_dtd.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMDocument::validate() should validate an external DTD declaration
+--CREDITS--
+Knut Urdalen <knut@php.net>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--SKIPIF--
+<?php
+require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+// reusing existing xml: http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/dom.xml?view=co&content-type=text%2Fplain
+// reusing existing dtd: http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/dom.ent?view=co&content-type=text%2Fplain
+$dom = new DOMDocument('1.0');
+$dom->load(dirname(__FILE__).'/dom.xml');
+var_dump($dom->validate());
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/dom/tests/DOMDocument_validate_on_parse_basic.phpt b/ext/dom/tests/DOMDocument_validate_on_parse_basic.phpt
new file mode 100644
index 0000000..a95b0a3
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_validate_on_parse_basic.phpt
@@ -0,0 +1,38 @@
+--TEST--
+DOMDocument::$validateOnParse - read/write tests (dom_document_validate_on_parse_read/dom_document_validate_on_parse_write)
+--CREDITS--
+Hans Zaunere
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('dom_test.inc');
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+
+if( !$dom )
+{
+ echo "Error while parsing the document\n";
+ exit;
+}
+
+echo "Checking documented default value: ";
+var_dump($dom->validateOnParse);
+
+$dom->validateOnParse = TRUE;
+echo "Setting validateOnParse to TRUE: ";
+var_dump($dom->validateOnParse);
+
+$dom->validateOnParse = FALSE;
+echo "Setting validateOnParse to FALSE: ";
+var_dump($dom->validateOnParse);
+
+?>
+--EXPECT--
+Checking documented default value: bool(false)
+Setting validateOnParse to TRUE: bool(true)
+Setting validateOnParse to FALSE: bool(false)
+
diff --git a/ext/dom/tests/DOMDocument_validate_on_parse_variation.phpt b/ext/dom/tests/DOMDocument_validate_on_parse_variation.phpt
new file mode 100644
index 0000000..d0cea29
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_validate_on_parse_variation.phpt
@@ -0,0 +1,46 @@
+--TEST--
+DOMDocument::$validateOnParse - effectual determination (dom_document_validate_on_parse_read/dom_document_validate_on_parse_write)
+--CREDITS--
+Hans Zaunere
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once('dom_test.inc');
+
+chdir(__DIR__);
+$XMLStringGood = file_get_contents('note.xml');
+
+$dom = new DOMDocument;
+$dom->resolveExternals = TRUE;
+
+$dom->validateOnParse = FALSE;
+echo "validateOnParse set to FALSE: \n";
+$dom->loadXML($XMLStringGood);
+echo "No Error Report Above\n";
+
+$BogusElement = $dom->createElement('NYPHP','DOMinatrix');
+$Body = $dom->getElementsByTagName('from')->item(0);
+$Body->appendChild($BogusElement);
+$XMLStringBad = $dom->saveXML();
+
+echo "validateOnParse set to TRUE: \n";
+$dom->validateOnParse = TRUE;
+$dom->loadXML($XMLStringBad);
+echo "Error Report Above\n";
+
+?>
+--EXPECTF--
+validateOnParse set to FALSE:
+No Error Report Above
+validateOnParse set to TRUE:
+
+Warning: DOMDocument::loadXML(): No declaration for element NYPHP in Entity, line: %d in %s on line %d
+
+Warning: DOMDocument::loadXML(): Element from was declared #PCDATA but contains non text nodes in Entity, line: %d in %s on line %d
+Error Report Above
+
diff --git a/ext/dom/tests/DOMElement_hasAttributes_basic.phpt b/ext/dom/tests/DOMElement_hasAttributes_basic.phpt
new file mode 100644
index 0000000..8e804be
--- /dev/null
+++ b/ext/dom/tests/DOMElement_hasAttributes_basic.phpt
@@ -0,0 +1,49 @@
+--TEST--
+DOMNode: hasAttributes()
+--CREDITS--
+James Lewis <james@s-1.com>
+#TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+
+$element = $dom->documentElement;
+
+echo "Verify that we have a DOMElement object:\n";
+echo get_class($element), "\n";
+
+echo "\nElement should have attributes:\n";
+var_dump($element->hasAttributes());
+
+$nodelist=$dom->getElementsByTagName('tbody') ;
+$element = $nodelist->item(0);
+
+echo "\nVerify that we have a DOMElement object:\n";
+echo get_class($element), "\n";
+
+echo "\nElement should have no attributes:\n";
+var_dump($element->hasAttributes());
+
+
+?>
+--EXPECTF--
+Verify that we have a DOMElement object:
+DOMElement
+
+Element should have attributes:
+bool(true)
+
+Verify that we have a DOMElement object:
+DOMElement
+
+Element should have no attributes:
+bool(false)
diff --git a/ext/dom/tests/DOMImplementation_createDocumentType_basic.phpt b/ext/dom/tests/DOMImplementation_createDocumentType_basic.phpt
new file mode 100644
index 0000000..3b19ea4
--- /dev/null
+++ b/ext/dom/tests/DOMImplementation_createDocumentType_basic.phpt
@@ -0,0 +1,18 @@
+--TEST--
+DOMImplementation::createDocumentType()
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+$imp = new DOMImplementation();
+$doctype = $imp->createDocumentType("html",
+ "-//W3C//DTD XHTML 1.0 Strict//EN",
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
+$doc = $imp->createDocument(null, 'html', $doctype);
+echo $doc->saveHTML();
+?>
+--EXPECTF--
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html></html>
diff --git a/ext/dom/tests/DOMImplementation_createDocument_basic.phpt b/ext/dom/tests/DOMImplementation_createDocument_basic.phpt
new file mode 100644
index 0000000..78d20ae
--- /dev/null
+++ b/ext/dom/tests/DOMImplementation_createDocument_basic.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DOMImplementation::createDocument()
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+$x = new DOMImplementation();
+$doc = $x->createDocument(null, 'html');
+echo $doc->saveHTML();
+?>
+--EXPECTF--
+<html></html>
diff --git a/ext/dom/tests/DOMImplementation_hasFeature_basic.phpt b/ext/dom/tests/DOMImplementation_hasFeature_basic.phpt
new file mode 100644
index 0000000..b53e912
--- /dev/null
+++ b/ext/dom/tests/DOMImplementation_hasFeature_basic.phpt
@@ -0,0 +1,15 @@
+--TEST--
+DOMImplementation::hasFeature()
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+$imp = new DOMImplementation();
+var_dump($imp->hasFeature('Core', '1.0'));
+var_dump($imp->hasFeature('XML', '2.0'));
+?>
+--EXPECTF--
+bool(true)
+bool(true)
diff --git a/ext/dom/tests/DOMNode_C14NFile_basic.phpt b/ext/dom/tests/DOMNode_C14NFile_basic.phpt
new file mode 100644
index 0000000..6af6e3e
--- /dev/null
+++ b/ext/dom/tests/DOMNode_C14NFile_basic.phpt
@@ -0,0 +1,38 @@
+--TEST--
+DOMNode::C14NFile()
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+$xml = <<< XML
+<?xml version="1.0" ?>
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
+XML;
+
+$output = dirname(__FILE__).'/DOMNode_C14NFile_basic.tmp';
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$node = $doc->getElementsByTagName('title')->item(0);
+var_dump($node->C14NFile($output));
+$content = file_get_contents($output);
+var_dump($content);
+?>
+--CLEAN--
+<?php
+$output = dirname(__FILE__).'/DOMNode_C14NFile_basic.tmp';
+unlink($output);
+?>
+--EXPECTF--
+int(34)
+string(34) "<title>The Grapes of Wrath</title>"
diff --git a/ext/dom/tests/DOMNode_C14N_basic.phpt b/ext/dom/tests/DOMNode_C14N_basic.phpt
new file mode 100644
index 0000000..52a47a1
--- /dev/null
+++ b/ext/dom/tests/DOMNode_C14N_basic.phpt
@@ -0,0 +1,29 @@
+--TEST--
+DOMNode::C14N()
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+$xml = <<< XML
+<?xml version="1.0" ?>
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
+XML;
+
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+$node = $doc->getElementsByTagName('title')->item(0);
+var_dump($node->C14N());
+?>
+--EXPECTF--
+string(34) "<title>The Grapes of Wrath</title>"
diff --git a/ext/dom/tests/DOMNode_cloneNode_basic.phpt b/ext/dom/tests/DOMNode_cloneNode_basic.phpt
new file mode 100644
index 0000000..cba3c17
--- /dev/null
+++ b/ext/dom/tests/DOMNode_cloneNode_basic.phpt
@@ -0,0 +1,106 @@
+--TEST--
+DOM cloneNode : Basic Functionality
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--CREDITS--
+Simon Hughes <odbc3@hotmail.com>
+--FILE--
+<?php
+
+$xml = <<< EOXML
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<courses>
+ <course title="one">
+ <notes>
+ <note>c1n1</note>
+ <note>c1n2</note>
+ </notes>
+ </course>
+ <course title="two">
+ <notes>
+ <note>c2n1</note>
+ <note>c2n2</note>
+ </notes>
+ </course>
+</courses>
+EOXML;
+
+function dumpcourse($current) {
+ $title = ($current->nodeType != XML_TEXT_NODE && $current->hasAttribute('title')) ? $current->getAttribute('title'):"no title";
+ echo "Course: $title:";echo(get_class($current)), "\n";
+ echo "~";var_dump($current->textContent);
+}
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+$root = $dom->documentElement;
+
+// strip all text nodes from this tree
+$children = $root->childNodes;
+$len = $children->length;
+for ($index = $children->length - 1; $index >=0; $index--) {
+ $current = $children->item($index);
+ if ($current->nodeType == XML_TEXT_NODE) {
+ $noderemoved = $root->removeChild($current);
+ }
+}
+
+echo "Start cloneNode test\n";
+$first_course = $children->item(0);
+$cloned_first_course_default = $first_course->cloneNode();
+$first_course->setAttribute('title', 'new title1');
+
+$cloned_first_course_true = $first_course->cloneNode(true);
+$first_course->setAttribute('title', 'new title2');
+
+$cloned_first_course_false = $first_course->cloneNode(false);
+$first_course->setAttribute('title', 'new title3');
+
+$cloned_first_course_default->setAttribute('title', 'new title default');
+$cloned_first_course_true->setAttribute('title', 'new title true');
+$cloned_first_course_false->setAttribute('title', 'new title false');
+
+$root->appendChild($cloned_first_course_default);
+$root->appendChild($cloned_first_course_true);
+$root->appendChild($cloned_first_course_false);
+
+$children = $root->childNodes;
+for ($index = 0; $index < $children->length; $index++) {
+ echo "node $index\n";
+ dumpcourse($children->item($index));
+}
+
+--EXPECTF--
+Start cloneNode test
+node 0
+Course: new title3:DOMElement
+~string(24) "
+
+ c1n1
+ c1n2
+
+ "
+node 1
+Course: two:DOMElement
+~string(24) "
+
+ c2n1
+ c2n2
+
+ "
+node 2
+Course: new title default:DOMElement
+~string(0) ""
+node 3
+Course: new title true:DOMElement
+~string(24) "
+
+ c1n1
+ c1n2
+
+ "
+node 4
+Course: new title false:DOMElement
+~string(0) ""
diff --git a/ext/dom/tests/DOMNode_getLineNo_basic.phpt b/ext/dom/tests/DOMNode_getLineNo_basic.phpt
new file mode 100644
index 0000000..3f57681
--- /dev/null
+++ b/ext/dom/tests/DOMNode_getLineNo_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMNode::getLineNo()
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+$file = dirname(__FILE__).'/book.xml';
+$doc = new DOMDocument();
+$doc->load($file);
+$nodes = $doc->getElementsByTagName('title');
+foreach($nodes as $node) {
+ var_dump($node->getLineNo());
+}
+?>
+--EXPECTF--
+int(4)
+int(8)
diff --git a/ext/dom/tests/DOMNode_getNodePath_basic.phpt b/ext/dom/tests/DOMNode_getNodePath_basic.phpt
new file mode 100644
index 0000000..7c14ffa
--- /dev/null
+++ b/ext/dom/tests/DOMNode_getNodePath_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+DOMNode::getNodePath()
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+$file = dirname(__FILE__).'/book.xml';
+$doc = new DOMDocument();
+$doc->load($file);
+$nodes = $doc->getElementsByTagName('title');
+foreach($nodes as $node) {
+ var_dump($node->getNodePath());
+}
+?>
+--EXPECTF--
+string(20) "/books/book[1]/title"
+string(20) "/books/book[2]/title"
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)
diff --git a/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt b/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt
new file mode 100644
index 0000000..3a6f6b4
--- /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
diff --git a/ext/dom/tests/DOMNode_insertBefore.phpt b/ext/dom/tests/DOMNode_insertBefore.phpt
new file mode 100644
index 0000000..d371aaf
--- /dev/null
+++ b/ext/dom/tests/DOMNode_insertBefore.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Tests DOMNode::insertBefore()
+--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();
+
+$e1 = $dom->createElement("A");
+$e2 = $dom->documentElement->appendChild($dom->createElement("B"));
+
+echo "Add new node B\n";
+echo $dom->saveXML();
+
+echo "Add new node A before B\n";
+$e2->parentNode->insertBefore($e1, $e2);
+echo $dom->saveXML();
+
+?>
+--EXPECTF--
+<?xml version="1.0"?>
+<root/>
+Add new node B
+<?xml version="1.0"?>
+<root><B/></root>
+Add new node A before B
+<?xml version="1.0"?>
+<root><A/><B/></root>
diff --git a/ext/dom/tests/DOMNode_insertBefore_error1.phpt b/ext/dom/tests/DOMNode_insertBefore_error1.phpt
new file mode 100644
index 0000000..d655479
--- /dev/null
+++ b/ext/dom/tests/DOMNode_insertBefore_error1.phpt
@@ -0,0 +1,24 @@
+--TEST--
+DOMNode::insertBefore() should fail if node belongs to another document
+--CREDITS--
+Knut Urdalen <knut@php.net>
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc1 = new DOMDocument();
+$doc2 = new DOMDocument();
+
+$node_in_doc1 = $doc1->createElement("foo");
+$node_in_doc2 = $doc2->createElement("bar");
+
+try {
+ $node_in_doc2->insertBefore($node_in_doc1);
+} catch(DOMException $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Wrong Document Error
diff --git a/ext/dom/tests/DOMNode_issamenode_basic.phpt b/ext/dom/tests/DOMNode_issamenode_basic.phpt
new file mode 100644
index 0000000..e008340
--- /dev/null
+++ b/ext/dom/tests/DOMNode_issamenode_basic.phpt
@@ -0,0 +1,37 @@
+--TEST--
+DOMNode: isSameNode()
+--CREDITS--
+James Lewis <james@s-1.com>
+#TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+
+$node = $dom->documentElement;
+if($node->isSameNode($node))
+ echo "EXPECTING SAME NODE, PASSED\n" ;
+else
+ echo "EXPECTING SAME NODE, FAILED\n" ;
+
+$nodelist=$dom->getElementsByTagName('tbody') ;
+
+if($nodelist->item(0)->isSameNode($node))
+ echo "EXPECTING NOT SAME NODE, FAILED\n" ;
+else
+ echo "EXPECTING NOT SAME NODE, PASSED\n" ;
+
+?>
+===DONE===
+--EXPECT--
+EXPECTING SAME NODE, PASSED
+EXPECTING NOT SAME NODE, PASSED
+===DONE===
diff --git a/ext/dom/tests/DOMNode_normalize_basic.phpt b/ext/dom/tests/DOMNode_normalize_basic.phpt
new file mode 100644
index 0000000..e413fb0
--- /dev/null
+++ b/ext/dom/tests/DOMNode_normalize_basic.phpt
@@ -0,0 +1,64 @@
+--TEST--
+DOMNode::normalize()
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+
+/* Create an XML document
+ * with structure
+ * <book>
+ * <author></author>
+ * <title>This is the title</title>
+ * </book>
+ * Calculate the number of title text nodes (1).
+ * Add another text node to title. Calculate the number of title text nodes (2).
+ * Normalize author. Calculate the number of title text nodes (2).
+ * Normalize title. Calculate the number of title text nodes (1).
+*/
+
+$doc = new DOMDocument();
+
+$root = $doc->createElement('book');
+$doc->appendChild($root);
+
+$title = $doc->createElement('title');
+$root->appendChild($title);
+
+$author = $doc->createElement('author');
+$root->appendChild($author);
+
+$text = $doc->createTextNode('This is the first title');
+$title->appendChild($text);
+
+echo "Number of child nodes of title = ";
+var_dump($title->childNodes->length);
+
+// add a second text node to title
+$text = $doc->createTextNode('This is the second title');
+$title->appendChild($text);
+
+echo "Number of child nodes of title after adding second title = ";
+var_dump($title->childNodes->length);
+
+// should do nothing
+$author->normalize();
+
+echo "Number of child nodes of title after normalizing author = ";
+var_dump($title->childNodes->length);
+
+
+// should concatenate first and second title text nodes
+$title->normalize();
+
+echo "Number of child nodes of title after normalizing title = ";
+var_dump($title->childNodes->length);
+
+?>
+--EXPECTF--
+Number of child nodes of title = int(1)
+Number of child nodes of title after adding second title = int(2)
+Number of child nodes of title after normalizing author = int(2)
+Number of child nodes of title after normalizing title = int(1) \ No newline at end of file
diff --git a/ext/dom/tests/DOMNode_removeChild_basic.phpt b/ext/dom/tests/DOMNode_removeChild_basic.phpt
new file mode 100644
index 0000000..384eb47
--- /dev/null
+++ b/ext/dom/tests/DOMNode_removeChild_basic.phpt
@@ -0,0 +1,106 @@
+--TEST--
+DOM removeChild : Basic Functionality
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--CREDITS--
+Simon Hughes <odbc3@hotmail.com>
+--FILE--
+<?php
+
+$xml = <<< EOXML
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<courses>
+ <course title="one">
+ <notes>
+ <note>c1n1</note>
+ <note>c1n2</note>
+ </notes>
+ </course>
+ <course title="two">
+ <notes>
+ <note>c2n1</note>
+ <note>c2n2</note>
+ </notes>
+ </course>
+</courses>
+EOXML;
+
+function dumpcourse($current) {
+ $title = ($current->nodeType != XML_TEXT_NODE && $current->hasAttribute('title')) ? $current->getAttribute('title'):"no title";
+ echo "Course: $title:";echo get_class($current), "\n";
+ echo "~";var_dump($current->textContent);
+}
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+$root = $dom->documentElement;
+
+$children = $root->childNodes;
+$len = $children->length;
+echo "orignal has $len nodes\n";
+for ($index = $children->length - 1; $index >=0; $index--) {
+ echo "node $index\n";
+ $current = $children->item($index);
+ dumpcourse($current);
+ if ($current->nodeType == XML_TEXT_NODE) {
+ $noderemoved = $root->removeChild($current);
+ }
+}
+$children = $root->childNodes;
+$len = $children->length;
+echo "after text removed it now has $len nodes\n";
+for ($index = 0; $index < $children->length; $index++) {
+ echo "node $index\n";
+ $current = $children->item($index);
+ dumpcourse($current);
+}
+
+--EXPECTF--
+orignal has 5 nodes
+node 4
+Course: no title:DOMText
+~string(1) "
+"
+node 3
+Course: two:DOMElement
+~string(24) "
+
+ c2n1
+ c2n2
+
+ "
+node 2
+Course: no title:DOMText
+~string(2) "
+ "
+node 1
+Course: one:DOMElement
+~string(24) "
+
+ c1n1
+ c1n2
+
+ "
+node 0
+Course: no title:DOMText
+~string(2) "
+ "
+after text removed it now has 2 nodes
+node 0
+Course: one:DOMElement
+~string(24) "
+
+ c1n1
+ c1n2
+
+ "
+node 1
+Course: two:DOMElement
+~string(24) "
+
+ c2n1
+ c2n2
+
+ "
diff --git a/ext/dom/tests/DOMNode_replaceChild_basic.phpt b/ext/dom/tests/DOMNode_replaceChild_basic.phpt
new file mode 100644
index 0000000..49fc055
--- /dev/null
+++ b/ext/dom/tests/DOMNode_replaceChild_basic.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Replacing a child node
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--CREDITS--
+Matt Raines <matt@raines.me.uk>
+#London TestFest 2008
+--FILE--
+<?php
+$document = new DOMDocument();
+$document->loadXML('<?xml version="1.0" encoding="utf-8"?>
+<root><foo><bar/><baz/></foo><spam><eggs/><eggs/></spam></root>');
+
+// Replaces the child node oldChild with newChild in the list of children, and
+// returns the oldChild node.
+$parent = $document->getElementsByTagName('foo')->item(0);
+$new_child = $document->createElement('qux');
+$old_child = $parent->replaceChild($new_child, $parent->firstChild);
+echo "New child replaces old child:\n" . $document->saveXML();
+echo "Old child is returned:\n" . $old_child->tagName . "\n";
+
+// If the newChild is already in the tree, it is first removed.
+$parent = $document->getElementsByTagName('spam')->item(0);
+$parent->replaceChild($new_child, $parent->firstChild);
+echo "Existing child is removed from tree:\n" . $document->saveXML();
+
+// Children are inserted in the correct order.
+$new_child = $document->getElementsByTagName('spam')->item(0);
+$parent = $document->getElementsByTagName('foo')->item(0);
+$parent->replaceChild($new_child, $parent->firstChild);
+echo "Children are inserted in order:\n" . $document->saveXML();
+?>
+--EXPECT--
+New child replaces old child:
+<?xml version="1.0" encoding="utf-8"?>
+<root><foo><qux/><baz/></foo><spam><eggs/><eggs/></spam></root>
+Old child is returned:
+bar
+Existing child is removed from tree:
+<?xml version="1.0" encoding="utf-8"?>
+<root><foo><baz/></foo><spam><qux/><eggs/></spam></root>
+Children are inserted in order:
+<?xml version="1.0" encoding="utf-8"?>
+<root><foo><spam><qux/><eggs/></spam></foo></root>
diff --git a/ext/dom/tests/DOMText_appendData_basic.phpt b/ext/dom/tests/DOMText_appendData_basic.phpt
new file mode 100644
index 0000000..0eea699
--- /dev/null
+++ b/ext/dom/tests/DOMText_appendData_basic.phpt
@@ -0,0 +1,40 @@
+--TEST--
+DOMText::appendData basic functionality test
+--CREDITS--
+Mike Sullivan <mike@regexia.com>
+#TestFest 2008 (London)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$document = new DOMDocument;
+$root = $document->createElement('root');
+$document->appendChild($root);
+
+$text = $document->createElement('text');
+$root->appendChild($text);
+
+$textnode = $document->createTextNode('');
+$text->appendChild($textnode);
+$textnode->appendData('data');
+echo "Text Length (one append): " . $textnode->length . "\n";
+
+$textnode->appendData('><&"');
+echo "Text Length (two appends): " . $textnode->length . "\n";
+
+echo "Text Content: " . $textnode->data . "\n";
+
+echo "\n" . $document->saveXML();
+
+?>
+===DONE===
+--EXPECT--
+Text Length (one append): 4
+Text Length (two appends): 8
+Text Content: data><&"
+
+<?xml version="1.0"?>
+<root><text>data&gt;&lt;&amp;"</text></root>
+===DONE===
+ \ No newline at end of file
diff --git a/ext/dom/tests/book-non-conforming-schema.xsd b/ext/dom/tests/book-non-conforming-schema.xsd
new file mode 100755
index 0000000..d1ecbef
--- /dev/null
+++ b/ext/dom/tests/book-non-conforming-schema.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="make_it_fail">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="book" minOccurs="1" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="title" type="xs:string"/>
+ <xs:element name="author" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
diff --git a/ext/dom/tests/book-not-a-schema.xsd b/ext/dom/tests/book-not-a-schema.xsd
new file mode 100755
index 0000000..d89e3bb
--- /dev/null
+++ b/ext/dom/tests/book-not-a-schema.xsd
@@ -0,0 +1 @@
+Let's see what happens upon parsing a file that doesn't contain a schema.
diff --git a/ext/dom/tests/book.xml b/ext/dom/tests/book.xml
new file mode 100644
index 0000000..95de0da
--- /dev/null
+++ b/ext/dom/tests/book.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" ?>
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
diff --git a/ext/dom/tests/book.xml.gz b/ext/dom/tests/book.xml.gz
new file mode 100644
index 0000000..2c97807
--- /dev/null
+++ b/ext/dom/tests/book.xml.gz
Binary files differ
diff --git a/ext/dom/tests/book.xsd b/ext/dom/tests/book.xsd
new file mode 100755
index 0000000..45986fc
--- /dev/null
+++ b/ext/dom/tests/book.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="books">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="book" minOccurs="1" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="title" type="xs:string"/>
+ <xs:element name="author" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
diff --git a/ext/dom/tests/bug28721.phpt b/ext/dom/tests/bug28721.phpt
new file mode 100644
index 0000000..464498e
--- /dev/null
+++ b/ext/dom/tests/bug28721.phpt
@@ -0,0 +1,485 @@
+--TEST--
+Bug #28721 (appendChild() and insertBefore() unset DOMText)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function print_node(DomNode $node) {
+ echo "name (value): " . $node->nodeName . " (" . $node->nodeValue . ")\n";
+}
+
+function print_node_r(DomNode $node) {
+ static $indent = "";
+ echo "\n" . $indent;
+ print_node($node);
+
+ echo $indent . "parent: ";
+ if ( $node->parentNode )
+ print_node($node->parentNode);
+ else
+ echo "NULL\n";
+
+ echo $indent . "previousSibling: ";
+ if ( $node->previousSibling )
+ print_node($node->previousSibling);
+ else
+ echo "NULL\n";
+
+ echo $indent . "nextSibling: ";
+ if ( $node->nextSibling )
+ print_node($node->nextSibling);
+ else
+ echo "NULL\n";
+
+ if ( !$node->hasChildNodes() )
+ return;
+
+ foreach ($node->childNodes as $child) {
+
+ $old_indent = $indent;
+ $indent .= " ";
+ print_node_r($child);
+ $indent = $old_indent;
+ }
+}
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+ echo "Error ($errno) on line $errline: $errstr\n";
+}
+
+// Record 'DocumentFragment is empty' warnings
+set_error_handler("err_handler", E_WARNING);
+
+$xml = new DomDocument();
+
+$p = $xml->createElement("p");
+
+$p->appendChild($t1 = $xml->createTextNode(" t1 "));
+$p->appendChild($b = $xml->createElement("b"));
+$b->appendChild($xml->createTextNode("X"));
+$p->appendChild($t2 = $xml->createTextNode(" t2 "));
+$p->appendChild($xml->createTextNode(" xxx "));
+
+print_node_r($p);
+
+echo "\nAppend t1 to p:\n";
+$ret = $p->appendChild($t1);
+
+print_node_r($p);
+echo "\n";
+
+echo "t1 == ret: ";
+var_dump( $t1 === $ret );
+
+
+$d = $xml->createElement("div");
+$d->appendChild($t3 = $xml->createTextNode(" t3 "));
+$d->appendChild($b = $xml->createElement("b"));
+$b->appendChild($xml->createElement("X"));
+$d->appendChild($t4 = $xml->createTextNode(" t4 "));
+$d->appendChild($xml->createTextNode(" xxx "));
+
+echo "\ndiv:\n";
+print_node_r($d);
+
+echo "\nInsert t4 before t3:\n";
+
+$ret = $d->insertBefore($t4, $t3);
+
+print_node_r($d);
+echo "\n";
+
+$frag = $xml->createDocumentFragment();
+
+$t5 = $frag->appendChild($xml->createTextNode(" t5 "));
+$frag->appendChild($i = $xml->createElement("i"));
+$i->appendChild($xml->createTextNode(" frob "));
+$frag->appendChild($xml->createTextNOde(" t6 "));
+
+echo "\np:\n";
+print_node_r($p);
+echo "\nFragment:\n";
+print_node_r($frag);
+
+echo "\nAppending fragment to p:\n";
+$p->appendChild($frag);
+
+print_node_r($p);
+echo "\nFragment:\n";
+print_node_r($frag);
+
+echo "\ndiv:\n";
+print_node_r($d);
+echo "\nInserting fragment before t4\n";
+$d->insertBefore($frag, $t4);
+print_node_r($d);
+
+echo "\np:\n";
+print_node_r($p);
+
+?>
+--EXPECT--
+
+name (value): p ( t1 X t2 xxx )
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): #text ( t1 )
+ parent: name (value): p ( t1 X t2 xxx )
+ previousSibling: NULL
+ nextSibling: name (value): b (X)
+
+ name (value): b (X)
+ parent: name (value): p ( t1 X t2 xxx )
+ previousSibling: name (value): #text ( t1 )
+ nextSibling: name (value): #text ( t2 )
+
+ name (value): #text (X)
+ parent: name (value): b (X)
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( t2 )
+ parent: name (value): p ( t1 X t2 xxx )
+ previousSibling: name (value): b (X)
+ nextSibling: name (value): #text ( xxx )
+
+ name (value): #text ( xxx )
+ parent: name (value): p ( t1 X t2 xxx )
+ previousSibling: name (value): #text ( t2 )
+ nextSibling: NULL
+
+Append t1 to p:
+
+name (value): p (X t2 xxx t1 )
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): b (X)
+ parent: name (value): p (X t2 xxx t1 )
+ previousSibling: NULL
+ nextSibling: name (value): #text ( t2 )
+
+ name (value): #text (X)
+ parent: name (value): b (X)
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( t2 )
+ parent: name (value): p (X t2 xxx t1 )
+ previousSibling: name (value): b (X)
+ nextSibling: name (value): #text ( xxx )
+
+ name (value): #text ( xxx )
+ parent: name (value): p (X t2 xxx t1 )
+ previousSibling: name (value): #text ( t2 )
+ nextSibling: name (value): #text ( t1 )
+
+ name (value): #text ( t1 )
+ parent: name (value): p (X t2 xxx t1 )
+ previousSibling: name (value): #text ( xxx )
+ nextSibling: NULL
+
+t1 == ret: bool(true)
+
+div:
+
+name (value): div ( t3 t4 xxx )
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): #text ( t3 )
+ parent: name (value): div ( t3 t4 xxx )
+ previousSibling: NULL
+ nextSibling: name (value): b ()
+
+ name (value): b ()
+ parent: name (value): div ( t3 t4 xxx )
+ previousSibling: name (value): #text ( t3 )
+ nextSibling: name (value): #text ( t4 )
+
+ name (value): X ()
+ parent: name (value): b ()
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( t4 )
+ parent: name (value): div ( t3 t4 xxx )
+ previousSibling: name (value): b ()
+ nextSibling: name (value): #text ( xxx )
+
+ name (value): #text ( xxx )
+ parent: name (value): div ( t3 t4 xxx )
+ previousSibling: name (value): #text ( t4 )
+ nextSibling: NULL
+
+Insert t4 before t3:
+
+name (value): div ( t4 t3 xxx )
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): #text ( t4 )
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: NULL
+ nextSibling: name (value): #text ( t3 )
+
+ name (value): #text ( t3 )
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: name (value): #text ( t4 )
+ nextSibling: name (value): b ()
+
+ name (value): b ()
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: name (value): #text ( t3 )
+ nextSibling: name (value): #text ( xxx )
+
+ name (value): X ()
+ parent: name (value): b ()
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( xxx )
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: name (value): b ()
+ nextSibling: NULL
+
+
+p:
+
+name (value): p (X t2 xxx t1 )
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): b (X)
+ parent: name (value): p (X t2 xxx t1 )
+ previousSibling: NULL
+ nextSibling: name (value): #text ( t2 )
+
+ name (value): #text (X)
+ parent: name (value): b (X)
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( t2 )
+ parent: name (value): p (X t2 xxx t1 )
+ previousSibling: name (value): b (X)
+ nextSibling: name (value): #text ( xxx )
+
+ name (value): #text ( xxx )
+ parent: name (value): p (X t2 xxx t1 )
+ previousSibling: name (value): #text ( t2 )
+ nextSibling: name (value): #text ( t1 )
+
+ name (value): #text ( t1 )
+ parent: name (value): p (X t2 xxx t1 )
+ previousSibling: name (value): #text ( xxx )
+ nextSibling: NULL
+
+Fragment:
+
+name (value): #document-fragment ()
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): #text ( t5 )
+ parent: name (value): #document-fragment ()
+ previousSibling: NULL
+ nextSibling: name (value): i ( frob )
+
+ name (value): i ( frob )
+ parent: name (value): #document-fragment ()
+ previousSibling: name (value): #text ( t5 )
+ nextSibling: name (value): #text ( t6 )
+
+ name (value): #text ( frob )
+ parent: name (value): i ( frob )
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( t6 )
+ parent: name (value): #document-fragment ()
+ previousSibling: name (value): i ( frob )
+ nextSibling: NULL
+
+Appending fragment to p:
+
+name (value): p (X t2 xxx t1 t5 frob t6 )
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): b (X)
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: NULL
+ nextSibling: name (value): #text ( t2 )
+
+ name (value): #text (X)
+ parent: name (value): b (X)
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( t2 )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): b (X)
+ nextSibling: name (value): #text ( xxx )
+
+ name (value): #text ( xxx )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): #text ( t2 )
+ nextSibling: name (value): #text ( t1 )
+
+ name (value): #text ( t1 )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): #text ( xxx )
+ nextSibling: name (value): #text ( t5 )
+
+ name (value): #text ( t5 )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): #text ( t1 )
+ nextSibling: name (value): i ( frob )
+
+ name (value): i ( frob )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): #text ( t5 )
+ nextSibling: name (value): #text ( t6 )
+
+ name (value): #text ( frob )
+ parent: name (value): i ( frob )
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( t6 )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): i ( frob )
+ nextSibling: NULL
+
+Fragment:
+
+name (value): #document-fragment ()
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+div:
+
+name (value): div ( t4 t3 xxx )
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): #text ( t4 )
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: NULL
+ nextSibling: name (value): #text ( t3 )
+
+ name (value): #text ( t3 )
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: name (value): #text ( t4 )
+ nextSibling: name (value): b ()
+
+ name (value): b ()
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: name (value): #text ( t3 )
+ nextSibling: name (value): #text ( xxx )
+
+ name (value): X ()
+ parent: name (value): b ()
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( xxx )
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: name (value): b ()
+ nextSibling: NULL
+
+Inserting fragment before t4
+Error (2) on line 109: DOMNode::insertBefore(): Document Fragment is empty
+
+name (value): div ( t4 t3 xxx )
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): #text ( t4 )
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: NULL
+ nextSibling: name (value): #text ( t3 )
+
+ name (value): #text ( t3 )
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: name (value): #text ( t4 )
+ nextSibling: name (value): b ()
+
+ name (value): b ()
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: name (value): #text ( t3 )
+ nextSibling: name (value): #text ( xxx )
+
+ name (value): X ()
+ parent: name (value): b ()
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( xxx )
+ parent: name (value): div ( t4 t3 xxx )
+ previousSibling: name (value): b ()
+ nextSibling: NULL
+
+p:
+
+name (value): p (X t2 xxx t1 t5 frob t6 )
+parent: NULL
+previousSibling: NULL
+nextSibling: NULL
+
+ name (value): b (X)
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: NULL
+ nextSibling: name (value): #text ( t2 )
+
+ name (value): #text (X)
+ parent: name (value): b (X)
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( t2 )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): b (X)
+ nextSibling: name (value): #text ( xxx )
+
+ name (value): #text ( xxx )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): #text ( t2 )
+ nextSibling: name (value): #text ( t1 )
+
+ name (value): #text ( t1 )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): #text ( xxx )
+ nextSibling: name (value): #text ( t5 )
+
+ name (value): #text ( t5 )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): #text ( t1 )
+ nextSibling: name (value): i ( frob )
+
+ name (value): i ( frob )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): #text ( t5 )
+ nextSibling: name (value): #text ( t6 )
+
+ name (value): #text ( frob )
+ parent: name (value): i ( frob )
+ previousSibling: NULL
+ nextSibling: NULL
+
+ name (value): #text ( t6 )
+ parent: name (value): p (X t2 xxx t1 t5 frob t6 )
+ previousSibling: name (value): i ( frob )
+ nextSibling: NULL
diff --git a/ext/dom/tests/bug28817.phpt b/ext/dom/tests/bug28817.phpt
new file mode 100644
index 0000000..a250bff
--- /dev/null
+++ b/ext/dom/tests/bug28817.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #28817 (properties in extended class)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+class z extends domDocument{
+ /** variable can have name */
+ public $p_array;
+ public $p_variable;
+
+ function __construct(){
+ $this->p_array[] = 'bonus';
+ $this->p_array[] = 'vir';
+ $this->p_array[] = 'semper';
+ $this->p_array[] = 'tiro';
+
+ $this->p_variable = 'Cessante causa cessat effectus';
+ }
+}
+
+$z=new z();
+var_dump($z->p_array);
+var_dump($z->p_variable);
+?>
+--EXPECTF--
+array(4) {
+ [0]=>
+ string(5) "bonus"
+ [1]=>
+ string(3) "vir"
+ [2]=>
+ string(6) "semper"
+ [3]=>
+ string(4) "tiro"
+}
+string(30) "Cessante causa cessat effectus"
diff --git a/ext/dom/tests/bug32615.phpt b/ext/dom/tests/bug32615.phpt
new file mode 100644
index 0000000..c6f2b5b
--- /dev/null
+++ b/ext/dom/tests/bug32615.phpt
@@ -0,0 +1,84 @@
+--TEST--
+Bug #32615 (Replacing and inserting Fragments)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new DomDocument;
+$frag = $dom->createDocumentFragment();
+$frag->appendChild(new DOMElement('root'));
+$dom->appendChild($frag);
+$root = $dom->documentElement;
+
+$frag->appendChild(new DOMElement('first'));
+$root->appendChild($frag);
+
+$frag->appendChild(new DOMElement('second'));
+$root->appendChild($frag);
+
+$node = $dom->createElement('newfirst');
+$frag->appendChild($node);
+$root->replaceChild($frag, $root->firstChild);
+
+unset($frag);
+$frag = $dom->createDocumentFragment();
+
+$frag->appendChild(new DOMElement('newsecond'));
+$root->replaceChild($frag, $root->lastChild);
+
+$node = $frag->appendChild(new DOMElement('fourth'));
+$root->insertBefore($frag, NULL);
+
+$frag->appendChild(new DOMElement('third'));
+$node = $root->insertBefore($frag, $node);
+
+$frag->appendChild(new DOMElement('start'));
+$root->insertBefore($frag, $root->firstChild);
+
+$frag->appendChild(new DOMElement('newthird'));
+$root->replaceChild($frag, $node);
+
+$frag->appendChild(new DOMElement('newfourth'));
+$root->replaceChild($frag, $root->lastChild);
+
+$frag->appendChild(new DOMElement('first'));
+$root->replaceChild($frag, $root->firstChild->nextSibling);
+
+$root->removeChild($root->firstChild);
+
+echo $dom->saveXML()."\n";
+
+while ($root->hasChildNodes()) {
+ $root->removeChild($root->firstChild);
+}
+
+$frag->appendChild(new DOMElement('first'));
+$root->insertBefore($frag, $root->firstChild);
+
+$node = $frag->appendChild(new DOMElement('fourth'));
+$root->appendChild($frag);
+
+$frag->appendChild(new DOMElement('second'));
+$frag->appendChild(new DOMElement('third'));
+$root->insertBefore($frag, $node);
+
+echo $dom->saveXML()."\n";
+
+$frag = $dom->createDocumentFragment();
+$root = $dom->documentElement;
+$root->replaceChild($frag, $root->firstChild);
+
+echo $dom->saveXML();
+
+?>
+--EXPECT--
+
+<?xml version="1.0"?>
+<root><first/><newsecond/><newthird/><newfourth/></root>
+
+<?xml version="1.0"?>
+<root><first/><second/><third/><fourth/></root>
+
+<?xml version="1.0"?>
+<root><second/><third/><fourth/></root>
+
diff --git a/ext/dom/tests/bug34276.phpt b/ext/dom/tests/bug34276.phpt
new file mode 100644
index 0000000..6959d90
--- /dev/null
+++ b/ext/dom/tests/bug34276.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Bug #34276 (setAttributeNS and default namespace)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = <<<HERE
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<foo xmlns="http://www.example.com/ns/foo"
+ xmlns:fubar="http://www.example.com/ns/fubar" attra="attra" />
+HERE;
+
+function dump($elems) {
+ foreach ($elems as $elem) {
+ var_dump($elem->nodeName);
+ dump($elem->childNodes);
+ }
+}
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+$foo = $dom->documentElement;
+var_dump($foo->hasAttributeNS('http://www.example.com/ns/foo', 'attra'));
+var_dump($foo->getAttributeNS('http://www.example.com/ns/foo', 'attra'));
+
+$foo->setAttributeNS('http://www.example.com/ns/foo', 'attra', 'attranew');
+$foo->setAttributeNS('http://www.example.com/ns/fubar', 'attrb', 'attrbnew');
+$foo->setAttributeNS('http://www.example.com/ns/foo', 'attrc', 'attrc');
+
+var_dump($foo->getAttributeNS('http://www.example.com/ns/foo', 'attra'));
+var_dump($foo->getAttributeNS('http://www.example.com/ns/fubar', 'attrb'));
+var_dump($foo->getAttributeNS('http://www.example.com/ns/foo', 'attrc'));
+
+print $dom->saveXML();
+?>
+--EXPECT--
+bool(false)
+string(0) ""
+string(8) "attranew"
+string(8) "attrbnew"
+string(5) "attrc"
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<foo xmlns="http://www.example.com/ns/foo" xmlns:fubar="http://www.example.com/ns/fubar" xmlns:default="http://www.example.com/ns/foo" attra="attra" default:attra="attranew" fubar:attrb="attrbnew" default:attrc="attrc"/>
diff --git a/ext/dom/tests/bug35342.phpt b/ext/dom/tests/bug35342.phpt
new file mode 100644
index 0000000..f93c062
--- /dev/null
+++ b/ext/dom/tests/bug35342.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #35342 (isset(DOMNodeList->length) returns false)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new DOMDocument();
+$dom->loadXML("<root><foo>foobar</foo><foo>foobar#2</foo></root>");
+
+$nodelist = $dom->getElementsByTagName("foo");
+
+var_dump($nodelist->length, isset($nodelist->length), isset($nodelist->foo));
+var_dump(empty($nodelist->length), empty($nodelist->foo));
+?>
+--EXPECT--
+int(2)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
diff --git a/ext/dom/tests/bug35673.phpt b/ext/dom/tests/bug35673.phpt
new file mode 100644
index 0000000..a29ae96
--- /dev/null
+++ b/ext/dom/tests/bug35673.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #35673 (formatOutput does not work with saveHTML).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$html = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>This is the title</title></head></html>';
+
+$htmldoc = new DOMDocument();
+$htmldoc->loadHTML($html);
+$htmldoc->formatOutput = true;
+echo $htmldoc->saveHTML();
+?>
+--EXPECT--
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html><head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>This is the title</title>
+</head></html>
diff --git a/ext/dom/tests/bug36756.phpt b/ext/dom/tests/bug36756.phpt
new file mode 100644
index 0000000..4e47b86
--- /dev/null
+++ b/ext/dom/tests/bug36756.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Bug #36756 (DOMDocument::removeChild corrupts node)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+/* Node is preserved from removeChild */
+$dom = new DOMDocument();
+$dom->loadXML('<root><child/></root>');
+$xpath = new DOMXpath($dom);
+$node = $xpath->query('/root')->item(0);
+echo $node->nodeName . "\n";
+$dom->removeChild($GLOBALS['dom']->firstChild);
+echo "nodeType: " . $node->nodeType . "\n";
+
+/* Node gets destroyed during removeChild */
+$dom->loadXML('<root><child/></root>');
+$xpath = new DOMXpath($dom);
+$node = $xpath->query('//child')->item(0);
+echo $node->nodeName . "\n";
+$GLOBALS['dom']->removeChild($GLOBALS['dom']->firstChild);
+
+echo "nodeType: " . $node->nodeType . "\n";
+
+?>
+--EXPECTF--
+root
+nodeType: 1
+child
+
+Warning: Couldn't fetch DOMElement. Node no longer exists in %sbug36756.php on line %d
+
+Notice: Undefined property: DOMElement::$nodeType in %sbug36756.php on line %d
+nodeType:
diff --git a/ext/dom/tests/bug37277.phpt b/ext/dom/tests/bug37277.phpt
new file mode 100644
index 0000000..112b9f4
--- /dev/null
+++ b/ext/dom/tests/bug37277.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #37277 (cloning Dom Documents or Nodes does not work)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom1 = new DomDocument('1.0', 'UTF-8');
+
+$xml = '<foo />';
+$dom1->loadXml($xml);
+
+$node = clone $dom1->documentElement;
+
+$dom2 = new DomDocument('1.0', 'UTF-8');
+$dom2->appendChild($dom2->importNode($node->cloneNode(true), TRUE));
+
+print $dom2->saveXML();
+
+
+?>
+--EXPECT--
+
+<?xml version="1.0" encoding="UTF-8"?>
+<foo/>
+
diff --git a/ext/dom/tests/bug37456.phpt b/ext/dom/tests/bug37456.phpt
new file mode 100644
index 0000000..5f0fc28
--- /dev/null
+++ b/ext/dom/tests/bug37456.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #37456 (DOMElement->setAttribute() loops forever)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument();
+$doc->resolveExternals = true;
+$doc->load(dirname(__FILE__)."/dom.xml");
+
+$root = $doc->getElementsByTagName('foo')->item(0);
+$root->setAttribute('bar', '&gt;');
+$attr = $root->setAttribute('bar', 'newval');
+print $attr->nodeValue;
+
+
+?>
+--EXPECT--
+
+newval
+
diff --git a/ext/dom/tests/bug38438.phpt b/ext/dom/tests/bug38438.phpt
new file mode 100644
index 0000000..f512528
--- /dev/null
+++ b/ext/dom/tests/bug38438.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #38438 (DOMNodeList->item(0) segfault on empty NodeList)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$list = new DOMNodeList();
+var_dump($list->item(0));
+echo "OK\n";
+?>
+--EXPECT--
+NULL
+OK
diff --git a/ext/dom/tests/bug38474.phpt b/ext/dom/tests/bug38474.phpt
new file mode 100644
index 0000000..54226ef
--- /dev/null
+++ b/ext/dom/tests/bug38474.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Bug #38474 (getAttribute select attribute by order, even when prefixed) (OK to fail with libxml2 < 2.6.2x)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+if (version_compare(LIBXML_DOTTED_VERSION, "2.6.20", "<")) {
+ print "skip libxml version " . LIBXML_DOTTED_VERSION;
+}
+?>
+--FILE--
+<?php
+$xml = '<node xmlns:pre="http://foo.com/tr/pre"
+ xmlns:post="http://foo.com/tr/post"
+ pre:type="bar" type="foo" ><sub /></node>';
+$dom = new DomDocument();
+$dom->loadXML($xml);
+echo $dom->firstChild->getAttribute('type')."\n";
+echo $dom->firstChild->getAttribute('pre:type')."\n";
+
+$dom->firstChild->setAttribute('pre:type', 'bar2');
+$dom->firstChild->setAttribute('type', 'foo2');
+$dom->firstChild->setAttribute('post:type', 'baz');
+$dom->firstChild->setAttribute('new:type', 'baz2');
+
+echo $dom->firstChild->getAttribute('type')."\n";
+echo $dom->firstChild->getAttribute('pre:type')."\n";
+echo $dom->firstChild->getAttribute('post:type')."\n";
+
+$dom->firstChild->removeAttribute('pre:type');
+$dom->firstChild->removeAttribute('type');
+
+echo $dom->firstChild->getAttribute('type')."\n";
+echo $dom->firstChild->getAttribute('pre:type')."\n";
+echo $dom->firstChild->getAttribute('post:type')."\n";
+echo $dom->firstChild->getAttribute('new:type');
+?>
+--EXPECT--
+foo
+bar
+foo2
+bar2
+baz
+
+
+baz
+baz2
diff --git a/ext/dom/tests/bug38850.phpt b/ext/dom/tests/bug38850.phpt
new file mode 100644
index 0000000..b0de90b
--- /dev/null
+++ b/ext/dom/tests/bug38850.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #38850 (lookupNamespaceURI does not return default namespace)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = <<<HERE
+<?xml version="1.0" ?>
+<foo xmlns="http://www.example.com/ns/foo" />
+HERE;
+
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+
+$root = $doc->documentElement;
+
+print $root->lookupNamespaceURI(NULL);
+
+
+?>
+--EXPECT--
+http://www.example.com/ns/foo
diff --git a/ext/dom/tests/bug38949.phpt b/ext/dom/tests/bug38949.phpt
new file mode 100644
index 0000000..4c81d9b
--- /dev/null
+++ b/ext/dom/tests/bug38949.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #38949 (Cannot get xmlns value attribute)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument();
+$doc->load(dirname(__FILE__)."/nsdoc.xml");
+
+$root = $doc->documentElement;
+
+echo $root->getAttribute("xmlns")."\n";
+echo $root->getAttribute("xmlns:ns2")."\n";
+
+$child = $root->firstChild->nextSibling;
+echo $child->getAttribute("xmlns")."\n";
+echo $child->getAttribute("xmlns:ns2")."\n";
+
+echo "DONE\n";
+?>
+--EXPECT--
+http://ns
+http://ns2
+
+
+DONE
diff --git a/ext/dom/tests/bug40836.phpt b/ext/dom/tests/bug40836.phpt
new file mode 100644
index 0000000..b96b39c
--- /dev/null
+++ b/ext/dom/tests/bug40836.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #40836 (Segfault in insertBefore)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new DOMDocument("1.0", "UTF-8");
+$dom->preserveWhiteSpace = false;
+$xml = (binary)'<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <entry xmlns="http://www.w3.org/2005/Atom">
+ <updated>2007-02-14T00:00:00+01:00</updated>
+ <content>
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ <p>paragraph</p>
+ </div>
+ </content>
+ </entry>
+</feed>';
+$dom->loadXML($xml);
+$entry = $dom->getElementsByTagNameNS("http://www.w3.org/2005/Atom", "entry")->item(0);
+$contentNode = $entry->getElementsByTagName("content")->item(0)->firstChild;
+$dateNode = $entry->getElementsByTagName("updated")->item(0)->firstChild;
+$contentNode->firstChild->insertBefore($dateNode);
+echo $dom->saveXML();
+?>
+--EXPECT--
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom"><entry xmlns="http://www.w3.org/2005/Atom"><updated/><content><div xmlns="http://www.w3.org/1999/xhtml"><p>paragraph2007-02-14T00:00:00+01:00</p></div></content></entry></feed>
diff --git a/ext/dom/tests/bug41257.phpt b/ext/dom/tests/bug41257.phpt
new file mode 100644
index 0000000..edf62a5
--- /dev/null
+++ b/ext/dom/tests/bug41257.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #41257 (lookupNamespaceURI does not work as expected)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument();
+$doc->load(dirname(__FILE__)."/nsdoc.xml");
+
+$root = $doc->documentElement;
+
+$duri = $doc->lookupNamespaceURI("ns2")."\n";
+$euri = $root->lookupNamespaceURI("ns2")."\n";
+
+var_dump($duri == $euri);
+
+$dpref = $doc->lookupPrefix("http://ns2")."\n";
+$epref = $root->lookupPrefix("http://ns2")."\n";
+
+var_dump($dpref == $epref);
+
+$disdef = $doc->isDefaultNamespace("http://ns")."\n";
+$eisdef = $root->isDefaultNamespace("http://ns")."\n";
+
+var_dump($dpref === $epref);
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/dom/tests/bug41374.phpt b/ext/dom/tests/bug41374.phpt
new file mode 100644
index 0000000..21fc345
--- /dev/null
+++ b/ext/dom/tests/bug41374.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #41374 (wholetext concats values of wrong nodes)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = (binary)<<<EOXML
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<root>foo<child />baz</root>
+EOXML;
+
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+
+$root = $doc->documentElement;
+$foo = $root->firstChild;
+
+var_dump($foo->wholeText == "foo");
+
+$bar = $root->insertBefore($doc->createTextNode("bar"), $foo->nextSibling);
+
+var_dump($foo->wholeText == "foobar");
+var_dump($foo->wholeText == $bar->wholeText);
+$baz = $bar->nextSibling->nextSibling;
+
+var_dump($baz->wholeText === $foo->wholeText);
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(false)
diff --git a/ext/dom/tests/bug42082.phpt b/ext/dom/tests/bug42082.phpt
new file mode 100644
index 0000000..b5fc893
--- /dev/null
+++ b/ext/dom/tests/bug42082.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #42082 (NodeList length zero should be empty)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doc = new DOMDocument();
+$xpath = new DOMXPath($doc);
+$nodes = $xpath->query('*');
+echo get_class($nodes), "\n";
+var_dump($nodes->length);
+$length = $nodes->length;
+var_dump(empty($nodes->length), empty($length));
+
+$doc->loadXML("<element></element>");
+var_dump($doc->firstChild->nodeValue, empty($doc->firstChild->nodeValue), isset($doc->firstChild->nodeValue));
+var_dump(empty($doc->nodeType), empty($doc->firstChild->nodeType))
+?>
+===DONE===
+--EXPECTF--
+DOMNodeList
+int(0)
+bool(true)
+bool(true)
+string(0) ""
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+===DONE===
+
diff --git a/ext/dom/tests/bug43364.phpt b/ext/dom/tests/bug43364.phpt
new file mode 100644
index 0000000..6e08ffc
--- /dev/null
+++ b/ext/dom/tests/bug43364.phpt
@@ -0,0 +1,42 @@
+--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)
diff --git a/ext/dom/tests/bug44648.phpt b/ext/dom/tests/bug44648.phpt
new file mode 100644
index 0000000..d04f590
--- /dev/null
+++ b/ext/dom/tests/bug44648.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Bug #44648 (Attribute names not checked for wellformedness)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument();
+$doc->loadXML('<root/>');
+
+$root = $doc->documentElement;
+
+try {
+ $attr = new DOMAttr('@acb', '123');
+ $root->setAttributeNode($attr);
+} catch (DOMException $e) {
+ echo $e->getMessage()."\n";
+}
+
+try {
+ $root->setAttribute('@def', '456');
+} catch (DOMException $e) {
+ echo $e->getMessage()."\n";
+}
+
+try {
+ $root->setAttributeNS(NULL, '@ghi', '789');
+} catch (DOMException $e) {
+ echo $e->getMessage()."\n";
+}
+
+try {
+ $root->setAttributeNS('urn::test', 'a:g@hi', '789');
+} catch (DOMException $e) {
+ echo $e->getMessage()."\n";
+}
+
+echo $doc->saveXML($root);
+?>
+--EXPECT--
+Invalid Character Error
+Invalid Character Error
+Invalid Character Error
+Namespace Error
+<root/> \ No newline at end of file
diff --git a/ext/dom/tests/bug45251.phpt b/ext/dom/tests/bug45251.phpt
new file mode 100644
index 0000000..652e3b2
--- /dev/null
+++ b/ext/dom/tests/bug45251.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #45251 (double free or corruption with setAttributeNode())
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doc = new DOMDocument;
+$doc->loadXml(<<<EOF
+<?xml version="1.0" encoding="utf-8" ?>
+<aaa>
+ <bbb foo="bar"/>
+</aaa>
+EOF
+);
+
+$xpath = new DOMXPath($doc);
+
+$bbb = $xpath->query('bbb', $doc->documentElement)->item(0);
+
+$ccc = $doc->createElement('ccc');
+foreach ($bbb->attributes as $attr)
+{
+ $ccc->setAttributeNode($attr);
+}
+
+echo $attr->parentNode->localName;
+
+?>
+--EXPECT--
+ccc
diff --git a/ext/dom/tests/bug46185.phpt b/ext/dom/tests/bug46185.phpt
new file mode 100644
index 0000000..02117cd
--- /dev/null
+++ b/ext/dom/tests/bug46185.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #46185 (importNode changes the namespace of an XML element).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$aDOM = new DOMDocument();
+$aDOM->loadXML('<?xml version="1.0"?>
+<ns1:a xmlns:ns1="urn::ns"/>');
+$a= $aDOM->firstChild;
+
+$ok = new DOMDocument();
+$ok->loadXML('<?xml version="1.0"?>
+<ns1:ok xmlns:ns1="urn::ns" xmlns="urn::REAL"><watch-me xmlns:default="urn::BOGUS"/></ns1:ok>');
+
+$imported= $aDOM->importNode($ok->firstChild, true);
+$a->appendChild($imported);
+
+echo $aDOM->saveXML();
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<ns1:a xmlns:ns1="urn::ns"><ns1:ok xmlns="urn::REAL"><watch-me xmlns:default="urn::BOGUS"/></ns1:ok></ns1:a> \ No newline at end of file
diff --git a/ext/dom/tests/bug46335.phpt b/ext/dom/tests/bug46335.phpt
new file mode 100644
index 0000000..bea4ae9
--- /dev/null
+++ b/ext/dom/tests/bug46335.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Bug #46335 (DOMText::splitText doesn't handle multibyte characters).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$textascii = 'This is an "example" of using DOM splitText';
+$text = 'This is an ‘example’ of using DOM splitText';
+$start = 30;
+$length = 3;
+
+$dom = new DOMDocument('1.0', 'UTF-8');
+$node = $dom->createTextNode($textascii);
+$dom->appendChild($node);
+
+print "Text: $node->textContent\n";
+
+$matched = $node->splitText($start);
+$matched->splitText($length);
+print "splitText (ASCII): $matched->textContent\n";
+
+$node = $dom->createTextNode($text);
+$dom->appendChild($node);
+
+print "Text: $node->textContent\n";
+
+$matched = $node->splitText($start);
+$matched->splitText($length);
+print "splitText (UTF-8): $matched->textContent\n";
+?>
+--EXPECT--
+Text: This is an "example" of using DOM splitText
+splitText (ASCII): DOM
+Text: This is an ‘example’ of using DOM splitText
+splitText (UTF-8): DOM
diff --git a/ext/dom/tests/bug46849.phpt b/ext/dom/tests/bug46849.phpt
new file mode 100644
index 0000000..c51c96e
--- /dev/null
+++ b/ext/dom/tests/bug46849.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #46849 (Cloning DOMDocument doesn't clone the properties).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new DOMDocument;
+$dom->formatOutput = 1;
+var_dump($dom->formatOutput);
+
+$dom2 = clone $dom;
+var_dump($dom2->formatOutput);
+?>
+--EXPECT--
+bool(true)
+bool(true)
diff --git a/ext/dom/tests/bug47430.phpt b/ext/dom/tests/bug47430.phpt
new file mode 100644
index 0000000..243fe84
--- /dev/null
+++ b/ext/dom/tests/bug47430.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #47430 (Errors after writing to nodeValue parameter of an absent previousSibling).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = '<?xml
+version="1.0"?><html><p><i>Hello</i></p><p><i>World!</i></p></html>';
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+
+$elements = $dom->getElementsByTagName('i');
+foreach ($elements as $i) {
+ $i->previousSibling->nodeValue = '';
+}
+
+$arr = array();
+$arr[0] = 'Value';
+
+print_r($arr);
+
+?>
+--EXPECTF--
+Warning: Creating default object from empty value in %s on line %d
+
+Warning: Creating default object from empty value in %s on line %d
+Array
+(
+ [0] => Value
+)
diff --git a/ext/dom/tests/bug47848.phpt b/ext/dom/tests/bug47848.phpt
new file mode 100644
index 0000000..b4453c7
--- /dev/null
+++ b/ext/dom/tests/bug47848.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #47848 (importNode doesn't preserve attribute namespaces)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$aDOM = new DOMDocument();
+$aDOM->appendChild($aDOM->createElementNS('http://friend2friend.net/','f2f:a'));
+
+$fromdom = new DOMDocument();
+$fromdom->loadXML('<data xmlns:ai="http://altruists.org" ai:attr="namespaced" />');
+
+$attr= $fromdom->firstChild->attributes->item(0);
+
+$att = $aDOM->importNode($attr);
+
+$aDOM->documentElement->appendChild($aDOM->importNode($attr, true));
+
+echo $aDOM->saveXML();
+
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<f2f:a xmlns:f2f="http://friend2friend.net/" xmlns:ai="http://altruists.org" ai:attr="namespaced"/> \ No newline at end of file
diff --git a/ext/dom/tests/bug47849.phpt b/ext/dom/tests/bug47849.phpt
new file mode 100644
index 0000000..7e6b02c
--- /dev/null
+++ b/ext/dom/tests/bug47849.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #47849 (Non-deep import loses the namespace).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$aDOM= new DOMDocument();
+$aDOM->appendChild($aDOM->createElementNS('urn::root','r:root'));
+
+$fromdom= new DOMDocument();
+$fromdom->loadXML('<data xmlns="urn::data">aaa</data>');
+
+$data= $fromdom->documentElement;
+$aDOM->documentElement->appendChild($aDOM->importNode($data));
+
+echo $aDOM->saveXML();
+
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<r:root xmlns:r="urn::root"><data xmlns="urn::data"/></r:root>
diff --git a/ext/dom/tests/bug49463.phpt b/ext/dom/tests/bug49463.phpt
new file mode 100644
index 0000000..4f232e3
--- /dev/null
+++ b/ext/dom/tests/bug49463.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #49463 (setAttributeNS fails setting default namespace).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument('1.0', 'utf-8');
+$root = $doc->createElementNS('http://purl.org/rss/1.0/','rdf:RDF');
+$doc->appendChild($root);
+$root->setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns","http://purl.org/rss/1.0/" );
+
+echo $doc->saveXML()."\n";
+?>
+--EXPECT--
+<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF xmlns:rdf="http://purl.org/rss/1.0/" xmlns="http://purl.org/rss/1.0/"/>
diff --git a/ext/dom/tests/bug49490.phpt b/ext/dom/tests/bug49490.phpt
new file mode 100644
index 0000000..897cfee
--- /dev/null
+++ b/ext/dom/tests/bug49490.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #49490 (XPath namespace prefix conflict).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doc = new DOMDocument();
+$doc->loadXML('<prefix:root xmlns:prefix="urn:a" />');
+
+$xp = new DOMXPath($doc);
+$xp->registerNamespace('prefix', 'urn:b');
+
+echo($xp->query('//prefix:root', null, false)->length . "\n");
+
+?>
+--EXPECT--
+0
diff --git a/ext/dom/tests/bug50661.phpt b/ext/dom/tests/bug50661.phpt
new file mode 100644
index 0000000..3760db9
--- /dev/null
+++ b/ext/dom/tests/bug50661.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #50661 (DOMDocument::loadXML does not allow UTF-16).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$data = "\xFE\xFF\x00\x3C\x00\x66\x00\x6F\x00\x6F\x00\x2F\x00\x3E";
+
+$dom = new DOMDocument();
+$dom->loadXML($data);
+echo $dom->saveXML();
+
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<foo/>
diff --git a/ext/dom/tests/bug52656.phpt b/ext/dom/tests/bug52656.phpt
new file mode 100644
index 0000000..9ec2610
--- /dev/null
+++ b/ext/dom/tests/bug52656.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #52656 (DOMCdataSection does not work with splitText).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$CData = new DOMCdataSection('splithere!');
+$CDataSplit = $CData->splitText(5);
+echo get_class($CDataSplit), "\n";
+var_dump($CDataSplit->data);
+?>
+--EXPECT--
+DOMText
+string(5) "here!"
diff --git a/ext/dom/tests/bug54601.phpt b/ext/dom/tests/bug54601.phpt
new file mode 100644
index 0000000..012302b
--- /dev/null
+++ b/ext/dom/tests/bug54601.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Segfault when removing the Doctype node
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = <<< XML
+<?xml version='1.0' encoding='utf-8' ?>
+<!DOCTYPE set PUBLIC "-//OASIS//DTD DocBook XML V5.0//EN" "http://www.docbook.org/xml/5.0/dtd/docbook.dtd" [
+<!ENTITY foo '<foo>footext</foo>'>
+<!ENTITY bar '<bar>bartext</bar>'>
+]>
+<set>&foo;&bar;</set>
+XML;
+
+$doc = new DOMDocument();
+$doc->loadXML($xml, LIBXML_NOENT);
+$n = $doc->doctype;
+$doc->removeChild($n);
+echo get_class($n), "\n";
+print $doc->saveXML();
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+DOMDocumentType
+<?xml version="1.0" encoding="utf-8"?>
+<set><foo>footext</foo><bar>bartext</bar></set>
+===DONE===
diff --git a/ext/dom/tests/canonicalization.phpt b/ext/dom/tests/canonicalization.phpt
new file mode 100644
index 0000000..cf1a81f
--- /dev/null
+++ b/ext/dom/tests/canonicalization.phpt
@@ -0,0 +1,102 @@
+--TEST--
+Test: Canonicalization - C14N()
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = <<<EOXML
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<foo xmlns="http://www.example.com/ns/foo"
+ xmlns:fubar="http://www.example.com/ns/fubar" xmlns:test="urn::test"><contain>
+ <bar><test1 /></bar>
+ <bar><test2 /></bar>
+ <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3 /></fubar:bar>
+ <fubar:bar><test4 /></fubar:bar>
+<!-- this is a comment -->
+</contain>
+</foo>
+EOXML;
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+$doc = $dom->documentElement->firstChild;
+
+/* inclusive/without comments first child element of doc element is context. */
+echo $doc->C14N()."\n\n";
+
+/* exclusive/without comments first child element of doc element is context. */
+echo $doc->c14N(TRUE)."\n\n";
+
+/* inclusive/with comments first child element of doc element is context. */
+echo $doc->C14N(FALSE, TRUE)."\n\n";
+
+/* exclusive/with comments first child element of doc element is context. */
+echo $doc->C14N(TRUE, TRUE)."\n\n";
+
+/* exclusive/without comments using xpath query. */
+echo $doc->c14N(TRUE, FALSE, array('query'=>'(//. | //@* | //namespace::*)'))."\n\n";
+
+/* exclusive/without comments first child element of doc element is context.
+ using xpath query with registered namespace.
+ test namespace prefix is also included. */
+echo $doc->c14N(TRUE, FALSE,
+ array('query'=>'(//a:contain | //a:bar | .//namespace::*)',
+ 'namespaces'=>array('a'=>'http://www.example.com/ns/foo')),
+ array('test'))."\n\n";
+
+/* exclusive/without comments first child element of doc element is context.
+ test namespace prefix is also included */
+echo $doc->C14N(TRUE, FALSE, NULL, array('test'));
+?>
+--EXPECTF--
+
+<contain xmlns="http://www.example.com/ns/foo" xmlns:fubar="http://www.example.com/ns/fubar" xmlns:test="urn::test">
+ <bar><test1></test1></bar>
+ <bar><test2></test2></bar>
+ <fubar:bar><test3></test3></fubar:bar>
+ <fubar:bar><test4></test4></fubar:bar>
+
+</contain>
+
+<contain xmlns="http://www.example.com/ns/foo">
+ <bar><test1></test1></bar>
+ <bar><test2></test2></bar>
+ <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3></test3></fubar:bar>
+ <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test4></test4></fubar:bar>
+
+</contain>
+
+<contain xmlns="http://www.example.com/ns/foo" xmlns:fubar="http://www.example.com/ns/fubar" xmlns:test="urn::test">
+ <bar><test1></test1></bar>
+ <bar><test2></test2></bar>
+ <fubar:bar><test3></test3></fubar:bar>
+ <fubar:bar><test4></test4></fubar:bar>
+<!-- this is a comment -->
+</contain>
+
+<contain xmlns="http://www.example.com/ns/foo">
+ <bar><test1></test1></bar>
+ <bar><test2></test2></bar>
+ <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3></test3></fubar:bar>
+ <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test4></test4></fubar:bar>
+<!-- this is a comment -->
+</contain>
+
+<foo xmlns="http://www.example.com/ns/foo"><contain>
+ <bar><test1></test1></bar>
+ <bar><test2></test2></bar>
+ <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3></test3></fubar:bar>
+ <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test4></test4></fubar:bar>
+
+</contain>
+</foo>
+
+<contain xmlns="http://www.example.com/ns/foo" xmlns:test="urn::test"><bar></bar><bar></bar></contain>
+
+<contain xmlns="http://www.example.com/ns/foo" xmlns:test="urn::test">
+ <bar><test1></test1></bar>
+ <bar><test2></test2></bar>
+ <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3></test3></fubar:bar>
+ <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test4></test4></fubar:bar>
+
+</contain>
diff --git a/ext/dom/tests/dom.ent b/ext/dom/tests/dom.ent
new file mode 100644
index 0000000..987ff9d
--- /dev/null
+++ b/ext/dom/tests/dom.ent
@@ -0,0 +1,8 @@
+<!ENTITY amp "&#38;#38;">
+<!ENTITY gt "&#62;">
+<!ENTITY % coreattrs "title CDATA #IMPLIED">
+<!ENTITY % attrs "%coreattrs;">
+<!ATTLIST foo bar CDATA #IMPLIED>
+<!ELEMENT foo (#PCDATA)>
+<!ELEMENT root (foo)+>
+<!ATTLIST th %attrs; > \ No newline at end of file
diff --git a/ext/dom/tests/dom.xml b/ext/dom/tests/dom.xml
new file mode 100644
index 0000000..09ac674
--- /dev/null
+++ b/ext/dom/tests/dom.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE root [
+<!ENTITY % incent SYSTEM "dom.ent">
+%incent;
+]>
+<root>
+ <foo bar="" />
+</root> \ No newline at end of file
diff --git a/ext/dom/tests/dom001.phpt b/ext/dom/tests/dom001.phpt
new file mode 100644
index 0000000..a0c78fb
--- /dev/null
+++ b/ext/dom/tests/dom001.phpt
@@ -0,0 +1,275 @@
+--TEST--
+Test 1: Accessing single node
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+echo "Test 1: accessing single nodes from php\n";
+$dom = new domDocument;
+$dom->loadxml($xmlstr);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+
+// children() of of document would result in a memleak
+//$children = $dom->children();
+//print_node_list($children);
+
+echo "--------- root\n";
+$rootnode = $dom->documentElement;
+print_node($rootnode);
+
+echo "--------- children of root\n";
+$children = $rootnode->childNodes;
+print_node_list($children);
+
+// The last node should be identical with the last entry in the children array
+echo "--------- last\n";
+$last = $rootnode->lastChild;
+print_node($last);
+
+// The parent of this last node is the root again
+echo "--------- parent\n";
+$parent = $last->parentNode;
+print_node($parent);
+
+// The children of this parent are the same children as one above
+echo "--------- children of parent\n";
+$children = $parent->childNodes;
+print_node_list($children);
+
+echo "--------- creating a new attribute\n";
+//This is worthless
+//$attr = $dom->createAttribute("src", "picture.gif");
+//print_r($attr);
+
+//$rootnode->set_attributeNode($attr);
+$attr = $rootnode->setAttribute("src", "picture.gif");
+$attr = $rootnode->getAttribute("src");
+print_r($attr);
+print "\n";
+
+echo "--------- Get Attribute Node\n";
+$attr = $rootnode->getAttributeNode("src");
+print_node($attr);
+
+echo "--------- Remove Attribute Node\n";
+$attr = $rootnode->removeAttribute("src");
+print "Removed " . $attr . " attributes.\n";
+
+echo "--------- attributes of rootnode\n";
+$attrs = $rootnode->attributes;
+print_node_list($attrs);
+
+echo "--------- children of an attribute\n";
+$children = $attrs->item(0)->childNodes;
+print_node_list($children);
+
+echo "--------- Add child to root\n";
+$myelement = new domElement("Silly", "Symphony");
+$newchild = $rootnode->appendChild($myelement);
+print_node($newchild);
+print $dom->saveXML();
+print "\n";
+
+echo "--------- Find element by tagname\n";
+echo " Using dom\n";
+$children = $dom->getElementsByTagname("Silly");
+print_node_list($children);
+
+echo " Using elem\n";
+$children = $rootnode->getElementsByTagName("Silly");
+print_node_list($children);
+
+echo "--------- Unlink Node\n";
+print_node($children->item(0));
+$rootnode->removeChild($children->item(0));
+print_node_list($rootnode->childNodes);
+print $dom->savexml();
+
+echo "--------- Find element by id\n";
+print ("Not implemented\n");
+
+echo "--------- Check various node_name return values\n";
+print ("Not needed\n");
+
+?>
+--EXPECT--
+Test 1: accessing single nodes from php
+--------- root
+Node Name: chapter
+Node Type: 1
+Num Children: 4
+
+--------- children of root
+Node Name: title
+Node Type: 1
+Num Children: 1
+Node Content: Title
+
+Node Name: #text
+Node Type: 3
+Num Children: 0
+Node Content:
+
+
+Node Name: para
+Node Type: 1
+Num Children: 7
+
+Node Name: #text
+Node Type: 3
+Num Children: 0
+Node Content:
+
+
+--------- last
+Node Name: #text
+Node Type: 3
+Num Children: 0
+Node Content:
+
+
+--------- parent
+Node Name: chapter
+Node Type: 1
+Num Children: 4
+
+--------- children of parent
+Node Name: title
+Node Type: 1
+Num Children: 1
+Node Content: Title
+
+Node Name: #text
+Node Type: 3
+Num Children: 0
+Node Content:
+
+
+Node Name: para
+Node Type: 1
+Num Children: 7
+
+Node Name: #text
+Node Type: 3
+Num Children: 0
+Node Content:
+
+
+--------- creating a new attribute
+picture.gif
+--------- Get Attribute Node
+Node Name: src
+Node Type: 2
+Num Children: 1
+Node Content: picture.gif
+
+--------- Remove Attribute Node
+Removed 1 attributes.
+--------- attributes of rootnode
+Node Name: language
+Node Type: 2
+Num Children: 1
+Node Content: en
+
+--------- children of an attribute
+Node Name: #text
+Node Type: 3
+Num Children: 0
+Node Content: en
+
+--------- Add child to root
+Node Name: Silly
+Node Type: 1
+Num Children: 1
+Node Content: Symphony
+
+<?xml version="1.0" standalone="yes"?>
+<!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [
+<!ENTITY sp "spanish">
+]>
+<!-- lsfj -->
+<chapter language="en"><title language="en">Title</title>
+<para language="ge">
+&sp;
+<!-- comment -->
+<informaltable language="&sp;kkk">
+<tgroup cols="3">
+<tbody>
+<row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row>
+<row><entry>a2</entry><entry>c2</entry></row>
+<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+<Silly>Symphony</Silly></chapter>
+
+--------- Find element by tagname
+ Using dom
+Node Name: Silly
+Node Type: 1
+Num Children: 1
+Node Content: Symphony
+
+ Using elem
+Node Name: Silly
+Node Type: 1
+Num Children: 1
+Node Content: Symphony
+
+--------- Unlink Node
+Node Name: Silly
+Node Type: 1
+Num Children: 1
+Node Content: Symphony
+
+Node Name: title
+Node Type: 1
+Num Children: 1
+Node Content: Title
+
+Node Name: #text
+Node Type: 3
+Num Children: 0
+Node Content:
+
+
+Node Name: para
+Node Type: 1
+Num Children: 7
+
+Node Name: #text
+Node Type: 3
+Num Children: 0
+Node Content:
+
+
+<?xml version="1.0" standalone="yes"?>
+<!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [
+<!ENTITY sp "spanish">
+]>
+<!-- lsfj -->
+<chapter language="en"><title language="en">Title</title>
+<para language="ge">
+&sp;
+<!-- comment -->
+<informaltable language="&sp;kkk">
+<tgroup cols="3">
+<tbody>
+<row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row>
+<row><entry>a2</entry><entry>c2</entry></row>
+<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</chapter>
+--------- Find element by id
+Not implemented
+--------- Check various node_name return values
+Not needed
diff --git a/ext/dom/tests/dom002.phpt b/ext/dom/tests/dom002.phpt
new file mode 100644
index 0000000..3343a17
--- /dev/null
+++ b/ext/dom/tests/dom002.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test 2: getElementsByTagName() / getElementsByTagNameNS()
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = <<<HERE
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<foo xmlns="http://www.example.com/ns/foo"
+ xmlns:fubar="http://www.example.com/ns/fubar">
+ <bar><test1 /></bar>
+ <bar><test2 /></bar>
+ <fubar:bar><test3 /></fubar:bar>
+ <fubar:bar><test4 /></fubar:bar>
+</foo>
+HERE;
+
+function dump($elems) {
+ foreach ($elems as $elem) {
+ var_dump($elem->nodeName);
+ dump($elem->childNodes);
+ }
+}
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+$doc = $dom->documentElement;
+dump($dom->getElementsByTagName('bar'));
+dump($doc->getElementsByTagName('bar'));
+dump($dom->getElementsByTagNameNS('http://www.example.com/ns/fubar', 'bar'));
+dump($doc->getElementsByTagNameNS('http://www.example.com/ns/fubar', 'bar'));
+?>
+--EXPECT--
+string(3) "bar"
+string(5) "test1"
+string(3) "bar"
+string(5) "test2"
+string(9) "fubar:bar"
+string(5) "test3"
+string(9) "fubar:bar"
+string(5) "test4"
+string(3) "bar"
+string(5) "test1"
+string(3) "bar"
+string(5) "test2"
+string(9) "fubar:bar"
+string(5) "test3"
+string(9) "fubar:bar"
+string(5) "test4"
+string(9) "fubar:bar"
+string(5) "test3"
+string(9) "fubar:bar"
+string(5) "test4"
+string(9) "fubar:bar"
+string(5) "test3"
+string(9) "fubar:bar"
+string(5) "test4"
diff --git a/ext/dom/tests/dom003.phpt b/ext/dom/tests/dom003.phpt
new file mode 100644
index 0000000..060a2c1
--- /dev/null
+++ b/ext/dom/tests/dom003.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Test 3: Exception Test
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$dom = new domdocument;
+$dom->load(dirname(__FILE__)."/book.xml");
+$rootNode = $dom->documentElement;
+print "--- Catch exception with try/catch\n";
+try {
+ $rootNode->appendChild($rootNode);
+} catch (domexception $e) {
+ ob_start();
+ var_dump($e);
+ $contents = ob_get_contents();
+ ob_end_clean();
+ echo preg_replace('/object\(DOMElement\).+\{.*?\}/s', 'DOMElement', $contents);
+}
+print "--- Don't catch exception with try/catch\n";
+$rootNode->appendChild($rootNode);
+
+
+?>
+--EXPECTF--
+--- Catch exception with try/catch
+object(DOMException)#%d (%d) {
+ ["message":protected]=>
+ string(23) "Hierarchy Request Error"
+ ["string":"Exception":private]=>
+ string(0) ""
+ ["file":protected]=>
+ string(%d) "%sdom003.php"
+ ["line":protected]=>
+ int(8)
+ ["trace":"Exception":private]=>
+ array(1) {
+ [0]=>
+ array(6) {
+ ["file"]=>
+ string(%d) "%sdom003.php"
+ ["line"]=>
+ int(8)
+ ["function"]=>
+ string(11) "appendChild"
+ ["class"]=>
+ string(7) "DOMNode"
+ ["type"]=>
+ string(2) "->"
+ ["args"]=>
+ array(1) {
+ [0]=>
+ DOMElement
+ }
+ }
+ }
+ ["previous":"Exception":private]=>
+ NULL
+ ["code"]=>
+ int(3)
+}
+--- Don't catch exception with try/catch
+
+Fatal error: Uncaught exception 'DOMException' with message 'Hierarchy Request Error' in %sdom003.php:%d
+Stack trace:
+#0 %sdom003.php(%d): DOMNode->appendChild(Object(DOMElement))
+#1 {main}
+ thrown in %sdom003.php on line %d
diff --git a/ext/dom/tests/dom004.phpt b/ext/dom/tests/dom004.phpt
new file mode 100644
index 0000000..5b65f24
--- /dev/null
+++ b/ext/dom/tests/dom004.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test 4: Streams Test
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+in_array('compress.zlib', stream_get_wrappers()) or die('skip compress.zlib wrapper is not available');
+?>
+--FILE--
+<?php
+$dom = new domdocument;
+$dom->load("compress.zlib://".dirname(__FILE__)."/book.xml.gz");
+print $dom->saveXML();
+
+--EXPECT--
+<?xml version="1.0"?>
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
diff --git a/ext/dom/tests/dom005.phpt b/ext/dom/tests/dom005.phpt
new file mode 100644
index 0000000..715aec4
--- /dev/null
+++ b/ext/dom/tests/dom005.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test 5: HTML Test
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new domdocument;
+$dom->loadHTMLFile(dirname(__FILE__)."/test.html");
+print "--- save as XML\n";
+
+print adjustDoctype($dom->saveXML());
+print "--- save as HTML\n";
+
+print adjustDoctype($dom->saveHTML());
+
+function adjustDoctype($xml) {
+ return str_replace(array("DOCTYPE HTML",'<p>','</p>'),array("DOCTYPE html",'',''),$xml);
+}
+
+--EXPECT--
+--- save as XML
+<?xml version="1.0" standalone="yes"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html><head><title>Hello world</title></head><body>
+This is a not well-formed<br/>
+html files with undeclared entities&#xA0;
+</body></html>
+--- save as HTML
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html><head><title>Hello world</title></head><body>
+This is a not well-formed<br>
+html files with undeclared entities&nbsp;
+</body></html>
diff --git a/ext/dom/tests/dom006.phpt b/ext/dom/tests/dom006.phpt
new file mode 100644
index 0000000..b8e8ed1
--- /dev/null
+++ b/ext/dom/tests/dom006.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test 6: Extends Test
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+Class books extends domDocument {
+ function addBook($title, $author) {
+ $titleElement = $this->createElement("title");
+ $titleElement->appendChild($this->createTextNode($title));
+ $authorElement = $this->createElement("author");
+ $authorElement->appendChild($this->createTextNode($author));
+
+ $bookElement = $this->createElement("book");
+
+ $bookElement->appendChild($titleElement);
+ $bookElement->appendChild($authorElement);
+ $this->documentElement->appendChild($bookElement);
+ }
+
+}
+
+$dom = new books;
+
+$dom->load(dirname(__FILE__)."/book.xml");
+$dom->addBook("PHP de Luxe", "Richard Samar, Christian Stocker");
+print $dom->saveXML();
+--EXPECT--
+<?xml version="1.0"?>
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+<book><title>PHP de Luxe</title><author>Richard Samar, Christian Stocker</author></book></books>
diff --git a/ext/dom/tests/dom007.phpt b/ext/dom/tests/dom007.phpt
new file mode 100644
index 0000000..5d12aa3
--- /dev/null
+++ b/ext/dom/tests/dom007.phpt
@@ -0,0 +1,111 @@
+--TEST--
+Test 7: DTD tests
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$xml = <<< EOXML
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE courses [
+<!ELEMENT courses (course+)>
+<!ELEMENT course (title, description, temp*)>
+<!ATTLIST course cid ID #REQUIRED>
+<!ELEMENT title (#PCDATA)>
+<!ELEMENT description (#PCDATA)>
+<!ELEMENT temp (#PCDATA)>
+<!ATTLIST temp vid ID #REQUIRED>
+<!ENTITY test 'http://www.hpl.hp.com/semweb/2003/query_tester#'>
+<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
+<!NOTATION GIF PUBLIC "-" "image/gif">
+<!ENTITY myimage PUBLIC "-" "mypicture.gif" NDATA GIF>
+]>
+<courses>
+ <course cid="c1">
+ <title>Basic Languages</title>
+ <description>Introduction to Languages</description>
+ </course>
+ <course cid="c6">
+ <title>French I</title>
+ <description>Introduction to French</description>
+ <temp vid="c7">
+ </temp>
+ </course>
+</courses>
+EOXML;
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+
+$dtd = $dom->doctype;
+
+/* Notation Tests */
+$nots = $dtd->notations;
+
+$length = $nots->length;
+echo "Length: ".$length."\n";
+
+foreach ($nots AS $key=>$node) {
+ echo "Key $key: ".$node->nodeName." (".$node->systemId.") (".$node->publicId.")\n";
+}
+print "\n";
+for($x=0; $x < $length; $x++) {
+ echo "Index $x: ".$nots->item($x)->nodeName." (".$nots->item($x)->systemId.") (".$nots->item($x)->publicId.")\n";
+}
+
+echo "\n";
+$node = $nots->getNamedItem('xxx');
+var_dump($node);
+
+echo "\n";
+/* Entity Decl Tests */
+$ents = $dtd->entities;
+$length = $ents->length;
+echo "Length: ".$length."\n";
+
+$xkeys = array();
+foreach ($ents AS $key=>$node) {
+ $xkeys[] = "Key: $key Name: ".$node->nodeName."\n";
+}
+sort($xkeys); // fix inconsistent output ordering (bug #61810)
+foreach ($xkeys as $key => $node) {
+ echo $node;
+}
+echo "\n";
+
+$xkeys = array();
+for($x=0; $x < $length; $x++) {
+ $xkeys[] = "Index: ".$ents->item($x)->nodeName."\n";
+}
+sort($xkeys); // fix inconsistent output ordering (bug #61810)
+foreach ($xkeys as $key => $node) {
+ echo $node;
+}
+
+echo "\n";
+$node = $ents->item(3);
+var_dump($node);
+$node = $ents->getNamedItem('xxx');
+var_dump($node);
+
+
+--EXPECT--
+Length: 1
+Key GIF: GIF (image/gif) (-)
+
+Index 0: GIF (image/gif) (-)
+
+NULL
+
+Length: 3
+Key: myimage Name: myimage
+Key: rdf Name: rdf
+Key: test Name: test
+
+Index: myimage
+Index: rdf
+Index: test
+
+NULL
+NULL
diff --git a/ext/dom/tests/dom_comment_basic.phpt b/ext/dom/tests/dom_comment_basic.phpt
new file mode 100644
index 0000000..3a69705
--- /dev/null
+++ b/ext/dom/tests/dom_comment_basic.phpt
@@ -0,0 +1,43 @@
+--TEST--
+DOM Comment : Basic Functionality
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+$xml = <<< EOXML
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<courses>
+ <!-- Hello World! -->
+</courses>
+EOXML;
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+$root = $dom->documentElement;
+var_dump($root->hasChildNodes());
+$children = $root->childNodes;
+
+for ($index = 0; $index < $children->length; $index++) {
+ echo "--- child $index ---\n";
+ $current = $children->item($index);
+ echo get_class($current), "\n";
+ var_dump($current->textContent);
+}
+
+--EXPECTF--
+bool(true)
+--- child 0 ---
+DOMText
+string(2) "
+ "
+--- child 1 ---
+DOMComment
+string(14) " Hello World! "
+--- child 2 ---
+DOMText
+string(1) "
+"
+
diff --git a/ext/dom/tests/dom_comment_variation.phpt b/ext/dom/tests/dom_comment_variation.phpt
new file mode 100644
index 0000000..1f30e7c
--- /dev/null
+++ b/ext/dom/tests/dom_comment_variation.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DOM Comment : Variation
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+$xml = <<< EOXML
+<?xml version="1.0" encoding="ISO-8859-1"?><courses><!-- Hello World! --></courses>
+EOXML;
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+$root = $dom->documentElement;
+var_dump($root->hasChildNodes());
+$children = $root->childNodes;
+
+for ($index = 0; $index < $children->length; $index++) {
+ echo "--- child $index ---\n";
+ $current = $children->item($index);
+ echo get_class($current), "\n";
+ var_dump($current->textContent);
+}
+
+--EXPECTF--
+bool(true)
+--- child 0 ---
+DOMComment
+string(14) " Hello World! "
+
diff --git a/ext/dom/tests/dom_create_element.phpt b/ext/dom/tests/dom_create_element.phpt
new file mode 100644
index 0000000..3f30709
--- /dev/null
+++ b/ext/dom/tests/dom_create_element.phpt
@@ -0,0 +1,394 @@
+--TEST--
+Test 1: Creating Elements with and without Namespaces
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+print " 1 DOMDocument::createElement('valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElement('valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print " 2 DOMDocument::createElement('-invalid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElement('-invalid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print " 3 DOMDocument::createElement(' ')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElement(' ');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print " 4 DOMDocument::createElement('prefix:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElement('prefix:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print " 5 DOMDocument::createElementNS('http://valid.com', 'valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://valid.com', 'valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print " 6 DOMDocument::createElementNS('http://valid.com', 'prefix:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://valid.com', 'prefix:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print " 7 DOMDocument::createElementNS('http://valid.com', '-invalid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://valid.com', '-invalid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print " 8 DOMDocument::createElementNS('http://valid.com', 'prefix:-invalid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://valid.com', 'prefix:-invalid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print " 9 DOMDocument::createElementNS('', 'prefix:invalid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('', 'prefix:invalid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "10 DOMDocument::createElementNS('http://valid.com', 'prefix:valid:invalid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://valid.com', 'prefix:valid:invalid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "11 DOMDocument::createElementNS('http://valid.com', '-prefix:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://valid.com', '-prefix:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "12 DOMDocument::createElementNS('-', 'prefix:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('-', 'prefix:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+
+print "13 DOMElement::__construct('valid')\n";
+try {
+ $element = new DomElement('valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "14 DOMElement::__construct('-invalid')\n";
+try {
+ $element = new DomElement('-invalid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "15 DOMElement::__construct(' ')\n";
+try {
+ $element = new DomElement(' ');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "16 DOMElement::__construct('prefix:valid')\n";
+try {
+ $element = new DomElement('prefix:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "17 DOMElement::__construct('valid', '', 'http://valid.com')\n";
+try {
+ $element = new DomElement('valid', '', 'http://valid.com');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "18 DOMElement::__construct('prefix:valid', '', 'http://valid.com')\n";
+try {
+ $element = new DomElement('prefix:valid', '', 'http://valid.com');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "19 DOMElement::__construct('-invalid', '', 'http://valid.com')\n";
+try {
+ $element = new DomElement('-invalid', '', 'http://valid.com');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "20 DOMElement::__construct('prefix:-invalid', '', 'http://valid.com')\n";
+try {
+ $element = new DomElement('prefix:-invalid', '', 'http://valid.com');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "21 DOMElement::__construct('prefix:invalid', '', '')\n";
+try {
+ $element = new DomElement('prefix:invalid', '', '');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "22 DOMElement::__construct('prefix:valid:invalid', '', 'http://valid.com')\n";
+try {
+ $element = new DomElement('prefix:valid:invalid', '', 'http://valid.com');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "23 DOMElement::__construct('-prefix:valid', '', 'http://valid.com')\n";
+try {
+ $element = new DomElement('-prefix:valid', '', 'http://valid.com');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "24 DOMElement::__construct('prefix:valid', '', '-')\n";
+try {
+ $element = new DomElement('prefix:valid', '', '-');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+/* the qualifiedName has a prefix and the namespaceURI is null */
+
+print "25 DOMDocument::createElementNS('', 'prefix:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('', 'prefix:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+/* the qualifiedName has a prefix that is "xml" and the namespaceURI
+ is different from "http://www.w3.org/XML/1998/namespace" [XML Namespaces] */
+
+print "26 DOMDocument::createElementNS('http://wrong.namespaceURI.com', 'xml:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://wrong.namespaceURI.com', 'xml:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "27 DOMElement::__construct('xml:valid', '', 'http://wrong.namespaceURI.com')\n";
+try {
+ $element = new DomElement('xml:valid', '', 'http://wrong.namespaceURI.com');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+/* This is okay because we reuse the xml namespace from the document */
+print "28 DOMDocument::createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+/* This isn't because the xml namespace isn't there and we can't create it */
+print "29 DOMElement::__construct('xml:valid', '', 'http://www.w3.org/XML/1998/namespace')\n";
+try {
+ $element = new DomElement('xml:valid', '', 'http://www.w3.org/XML/1998/namespace');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+
+/* the qualifiedName or its prefix is "xmlns" and the namespaceURI is
+ different from "http://www.w3.org/2000/xmlns/" */
+
+print "30 DOMDocument::createElementNS('http://wrong.namespaceURI.com', 'xmlns:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://wrong.namespaceURI.com', 'xmlns:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "31 DOMElement::__construct('xmlns:valid', '', 'http://wrong.namespaceURI.com')\n";
+try {
+ $element = new DomElement('xmlns:valid', '', 'http://wrong.namespaceURI.com');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "32 DOMDocument::createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "33 DOMElement::__construct('xmlns:valid', '', 'http://www.w3.org/2000/xmlns/')\n";
+try {
+ $element = new DomElement('xmlns:valid', '', 'http://www.w3.org/2000/xmlns/');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+/* the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the
+ qualifiedName nor its prefix is "xmlns". */
+
+print "34 DOMDocument::createElementNS('http://www.w3.org/2000/xmlns/', 'wrongprefix:valid')\n";
+try {
+ $dom = new domDocument;
+ $dom->createElementNS('http://www.w3.org/2000/xmlns/', 'wrongprefix:valid');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+print "35 DOMElement::__construct('wrongprefix:valid', '', 'http://www.w3.org/2000/xmlns/')\n";
+try {
+ $element = new DomElement('wrongprefix:valid', '', 'http://www.w3.org/2000/xmlns/');
+ print "valid\n";
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+
+
+?>
+--EXPECT--
+ 1 DOMDocument::createElement('valid')
+valid
+ 2 DOMDocument::createElement('-invalid')
+Invalid Character Error
+ 3 DOMDocument::createElement(' ')
+Invalid Character Error
+ 4 DOMDocument::createElement('prefix:valid')
+valid
+ 5 DOMDocument::createElementNS('http://valid.com', 'valid')
+valid
+ 6 DOMDocument::createElementNS('http://valid.com', 'prefix:valid')
+valid
+ 7 DOMDocument::createElementNS('http://valid.com', '-invalid')
+Namespace Error
+ 8 DOMDocument::createElementNS('http://valid.com', 'prefix:-invalid')
+Namespace Error
+ 9 DOMDocument::createElementNS('', 'prefix:invalid')
+Namespace Error
+10 DOMDocument::createElementNS('http://valid.com', 'prefix:valid:invalid')
+Namespace Error
+11 DOMDocument::createElementNS('http://valid.com', '-prefix:valid')
+Namespace Error
+12 DOMDocument::createElementNS('-', 'prefix:valid')
+valid
+13 DOMElement::__construct('valid')
+valid
+14 DOMElement::__construct('-invalid')
+Invalid Character Error
+15 DOMElement::__construct(' ')
+Invalid Character Error
+16 DOMElement::__construct('prefix:valid')
+Namespace Error
+17 DOMElement::__construct('valid', '', 'http://valid.com')
+valid
+18 DOMElement::__construct('prefix:valid', '', 'http://valid.com')
+valid
+19 DOMElement::__construct('-invalid', '', 'http://valid.com')
+Invalid Character Error
+20 DOMElement::__construct('prefix:-invalid', '', 'http://valid.com')
+Namespace Error
+21 DOMElement::__construct('prefix:invalid', '', '')
+Namespace Error
+22 DOMElement::__construct('prefix:valid:invalid', '', 'http://valid.com')
+Namespace Error
+23 DOMElement::__construct('-prefix:valid', '', 'http://valid.com')
+Invalid Character Error
+24 DOMElement::__construct('prefix:valid', '', '-')
+valid
+25 DOMDocument::createElementNS('', 'prefix:valid')
+Namespace Error
+26 DOMDocument::createElementNS('http://wrong.namespaceURI.com', 'xml:valid')
+Namespace Error
+27 DOMElement::__construct('xml:valid', '', 'http://wrong.namespaceURI.com')
+Namespace Error
+28 DOMDocument::createElementNS('http://www.w3.org/XML/1998/namespace', 'xml:valid')
+valid
+29 DOMElement::__construct('xml:valid', '', 'http://www.w3.org/XML/1998/namespace')
+Namespace Error
+30 DOMDocument::createElementNS('http://wrong.namespaceURI.com', 'xmlns:valid')
+Namespace Error
+31 DOMElement::__construct('xmlns:valid', '', 'http://wrong.namespaceURI.com')
+Namespace Error
+32 DOMDocument::createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:valid')
+valid
+33 DOMElement::__construct('xmlns:valid', '', 'http://www.w3.org/2000/xmlns/')
+valid
+34 DOMDocument::createElementNS('http://www.w3.org/2000/xmlns/', 'wrongprefix:valid')
+Namespace Error
+35 DOMElement::__construct('wrongprefix:valid', '', 'http://www.w3.org/2000/xmlns/')
+Namespace Error
diff --git a/ext/dom/tests/dom_import_simplexml.phpt b/ext/dom/tests/dom_import_simplexml.phpt
new file mode 100644
index 0000000..81744aa
--- /dev/null
+++ b/ext/dom/tests/dom_import_simplexml.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Interop Test: Import from SimpleXML
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+<?php if (!extension_loaded('simplexml')) die('skip simplexml extension not available');?>
+--FILE--
+<?php
+$s = simplexml_load_file(dirname(__FILE__)."/book.xml");
+if(!$s) {
+ echo "Error while loading the document\n";
+ exit;
+}
+$dom = dom_import_simplexml($s);
+print $dom->ownerDocument->saveXML();
+?>
+--EXPECT--
+<?xml version="1.0"?>
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
diff --git a/ext/dom/tests/dom_set_attr_node.phpt b/ext/dom/tests/dom_set_attr_node.phpt
new file mode 100644
index 0000000..1916cd5
--- /dev/null
+++ b/ext/dom/tests/dom_set_attr_node.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Test: setAttributeNode()
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--INI--
+error_reporting = E_ALL & ~E_WARNING
+--FILE--
+<?php
+
+$xml = <<<HERE
+<?xml version="1.0" ?>
+<root a="b" />
+HERE;
+
+$xml2 = <<<HERE
+<?xml version="1.0" ?>
+<doc2 />
+HERE;
+
+$dom = new DOMDocument();
+$dom->loadXML($xml);
+$root = $dom->documentElement;
+$attr = $root->getAttributeNode('a');
+
+$dom2 = new DOMDocument();
+$dom2->loadXML($xml2);
+$root2 = $dom2->documentElement;
+try {
+ $root2->setAttributeNode($attr);
+} catch (domexception $e) {
+ob_start();
+ var_dump($e);
+ $contents = ob_get_contents();
+ ob_end_clean();
+ echo preg_replace('/object\(DOMAttr\).+\{.*?\}/s', 'DOMAttr', $contents);
+}
+
+?>
+--EXPECTF--
+object(DOMException)#%d (7) {
+ ["message":protected]=>
+ string(20) "Wrong Document Error"
+ ["string":"Exception":private]=>
+ string(0) ""
+ ["file":protected]=>
+ string(%d) "%sdom_set_attr_node.php"
+ ["line":protected]=>
+ int(%d)
+ ["trace":"Exception":private]=>
+ array(1) {
+ [0]=>
+ array(6) {
+ ["file"]=>
+ string(%d) "%sdom_set_attr_node.php"
+ ["line"]=>
+ int(%d)
+ ["function"]=>
+ string(16) "setAttributeNode"
+ ["class"]=>
+ string(10) "DOMElement"
+ ["type"]=>
+ string(2) "->"
+ ["args"]=>
+ array(1) {
+ [0]=>
+ DOMAttr
+ }
+ }
+ }
+ ["previous":"Exception":private]=>
+ NULL
+ ["code"]=>
+ int(4)
+}
diff --git a/ext/dom/tests/dom_test.inc b/ext/dom/tests/dom_test.inc
new file mode 100644
index 0000000..86b426f
--- /dev/null
+++ b/ext/dom/tests/dom_test.inc
@@ -0,0 +1,47 @@
+<?PHP
+$xmlstr = "<?xml version='1.0' standalone='yes'?>
+<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'
+[ <!ENTITY sp \"spanish\">
+]>
+<!-- lsfj -->
+<chapter language='en'><title language='en'>Title</title>
+<para language='ge'>
+&sp;
+<!-- comment -->
+<informaltable language='&sp;kkk'>
+<tgroup cols='3'>
+<tbody>
+<row><entry>a1</entry><entry morerows='1'>b1</entry><entry>c1</entry></row>
+<row><entry>a2</entry><entry>c2</entry></row>
+<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
+</tbody>
+</tgroup>
+</informaltable>
+</para>
+</chapter> ";
+
+function print_node($node)
+{
+ print "Node Name: " . $node->nodeName;
+ print "\nNode Type: " . $node->nodeType;
+ if ($node->nodeType != 3) {
+ $child_count = $node->childNodes->length;
+ } else {
+ $child_count = 0;
+ }
+ print "\nNum Children: " . $child_count;
+ if($child_count <= 1){
+ print "\nNode Content: " . $node->nodeValue;
+ }
+ print "\n\n";
+}
+
+function print_node_list($nodelist)
+{
+ foreach($nodelist as $node)
+ {
+ print_node($node);
+ }
+}
+
+?>
diff --git a/ext/dom/tests/dom_xinclude.phpt b/ext/dom/tests/dom_xinclude.phpt
new file mode 100644
index 0000000..5d8906e
--- /dev/null
+++ b/ext/dom/tests/dom_xinclude.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Test: Xinclude and Streams
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+in_array('compress.zlib', stream_get_wrappers()) or die('skip compress.zlib wrapper is not available');
+?>
+--FILE--
+<?php
+$dom = new domdocument;
+
+$data = file_get_contents(dirname(__FILE__)."/xinclude.xml");
+$reldir = str_replace(getcwd(),".",dirname(__FILE__));
+if (DIRECTORY_SEPARATOR == '\\') {
+ $reldir = str_replace('\\',"/", $reldir);
+}
+$data = str_replace('compress.zlib://ext/dom/tests/','compress.zlib://'.$reldir."/", $data);
+
+
+$dom->loadXML($data);
+$dom->xinclude();
+print $dom->saveXML()."\n";
+foreach ($dom->documentElement->childNodes as $node) {
+ print $node->nodeName."\n";
+}
+?>
+--EXPECTF--
+<?xml version="1.0"?>
+<foo xmlns:xi="http://www.w3.org/2001/XInclude">
+ <book xml:base="compress.zlib://%sbook.xml">
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book><book xml:base="compress.zlib://%sbook.xml">
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+ </foo>
+
+#text
+book
+book
+#text
diff --git a/ext/dom/tests/domattributes.phpt b/ext/dom/tests/domattributes.phpt
new file mode 100644
index 0000000..9097a88
--- /dev/null
+++ b/ext/dom/tests/domattributes.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Attributes: DOMAttribute functionality
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+
+$node = $dom->documentElement;
+
+$lang = $node->getAttributeNode('language');
+echo "Language: ".$lang->value."\n";
+
+$lang->value = 'en-US';
+echo "Language: ".$lang->value."\n";
+
+$parent = $lang->ownerElement;
+
+$chapter = new DOMAttr("num", "1");
+$parent->setAttributeNode($chapter);
+
+echo "Is ID?: ".($chapter->isId()?'YES':'NO')."\n";
+
+$top_element = $node->cloneNode();
+
+print $dom->saveXML($top_element);
+
+
+?>
+--EXPECT--
+
+Language: en
+Language: en-US
+Is ID?: NO
+<chapter language="en-US" num="1"/>
+
diff --git a/ext/dom/tests/domchardata.phpt b/ext/dom/tests/domchardata.phpt
new file mode 100644
index 0000000..6baff6d
--- /dev/null
+++ b/ext/dom/tests/domchardata.phpt
@@ -0,0 +1,76 @@
+--TEST--
+CharData: DOMCharacterData and related functionality
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+
+$node = $dom->documentElement;
+
+$charnode = $dom->createElement('charnode');
+$node->appendChild($charnode);
+
+/* DOMComment */
+$comment = new DOMComment('Testing character data and extending nodes');
+$charnode->appendChild($comment);
+
+echo "Comment Length: ".$comment->length."\n";
+
+$comment->data = 'Updated comment';
+echo "New Comment Length: ".$comment->length."\n";
+echo "New Comment Data: ".$comment->data."\n";
+
+/* DOMCDataSection */
+$cdata = new DOMCDataSection('Chars: <>&"');
+$charnode->appendChild($cdata);
+
+echo "Substring: ".$cdata->substringData(7, 4)."\n";
+$cdata->replaceData(10, 1, "'");
+echo "New Substring: ".$cdata->substringData(7, 4)."\n";
+
+/* DOMCharacterData using DOMComment */
+$comment = new DOMComment('instructions');
+echo "Comment Value: ".$comment->data."\n";
+$comment->data = 'some more instructions';
+echo "New Comment Value: ".$comment->data."\n";
+
+$comment->insertData(10, 'pi ');
+$comment->replaceData(18, 5, 'i');
+$comment->insertData(20, 'g');
+$comment->deleteData(13, 2);
+$comment->deleteData(10, 3);
+$comment->insertData(10, 'comment ');
+echo "Updated Comment Value: ".$comment->data."\n";
+
+/* DOMText */
+$text = new DOMText('some text characters');
+
+echo "Whole Text: ".$text->wholeText."\n";
+$text2 = $text->splitText(9);
+
+echo "Split text: ".$text2->wholeText."\n";
+$text3 = $text2->splitText(1);
+
+echo "Is Whitespace?: ".($text2->isElementContentWhitespace()?'YES':'NO');
+?>
+--EXPECT--
+
+Comment Length: 42
+New Comment Length: 15
+New Comment Data: Updated comment
+Substring: <>&"
+New Substring: <>&'
+Comment Value: instructions
+New Comment Value: some more instructions
+Updated Comment Value: some more comment strings
+Whole Text: some text characters
+Split text: characters
+Is Whitespace?: YES
diff --git a/ext/dom/tests/domdocument_createcomment_error_001.phpt b/ext/dom/tests/domdocument_createcomment_error_001.phpt
new file mode 100644
index 0000000..24104a1
--- /dev/null
+++ b/ext/dom/tests/domdocument_createcomment_error_001.phpt
@@ -0,0 +1,16 @@
+--TEST--
+DomDocument::CreateComment() - Incorrect Parameters
+--CREDITS--
+Clint Priest @ PhpTek09
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+ $x = new DomDocument();
+ $x->createComment();
+?>
+===DONE===
+--EXPECTF--
+Warning: DOMDocument::createComment() expects exactly 1 parameter, 0 given in %s
+===DONE===
+ \ No newline at end of file
diff --git a/ext/dom/tests/domdocument_createentityreference_001.phpt b/ext/dom/tests/domdocument_createentityreference_001.phpt
new file mode 100644
index 0000000..7343e74
--- /dev/null
+++ b/ext/dom/tests/domdocument_createentityreference_001.phpt
@@ -0,0 +1,18 @@
+--TEST--
+DomDocument::CreateEntityReference() - Creates an entity reference with the appropriate name
+--CREDITS--
+Clint Priest @ PhpTek09
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+ $objDoc = new DomDocument();
+
+ $objRef = $objDoc->createEntityReference('Test');
+ echo $objRef->nodeName . "\n";
+?>
+===DONE===
+--EXPECT--
+Test
+===DONE===
+ \ No newline at end of file
diff --git a/ext/dom/tests/domdocument_createentityreference_002.phpt b/ext/dom/tests/domdocument_createentityreference_002.phpt
new file mode 100644
index 0000000..a2416c2
--- /dev/null
+++ b/ext/dom/tests/domdocument_createentityreference_002.phpt
@@ -0,0 +1,17 @@
+--TEST--
+DomDocument::CreateEntityReference() - Empty Arguments
+--CREDITS--
+Clint Priest @ PhpTek09
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+ $objDoc = new DomDocument();
+
+ $objRef = $objDoc->createEntityReference();
+?>
+===DONE===
+--EXPECTF--
+Warning: DOMDocument::createEntityReference() expects exactly 1 parameter, 0 given in %s
+===DONE===
+ \ No newline at end of file
diff --git a/ext/dom/tests/domelement.phpt b/ext/dom/tests/domelement.phpt
new file mode 100644
index 0000000..bc69af6
--- /dev/null
+++ b/ext/dom/tests/domelement.phpt
@@ -0,0 +1,114 @@
+--TEST--
+Elements: DOMElement functionality
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+
+$node = $dom->documentElement;
+echo "Tag Name: ".$node->tagName."\n";
+
+
+$node->setAttribute('num', '1');
+echo "Chapter: ".$node->getAttribute('num')."\n";
+echo 'Attribute num exists?: '.($node->hasAttribute('num')?'Yes':'No')."\n";
+$node->removeAttribute('num');
+echo "Chapter: ".$node->getAttribute('num')."\n";
+echo 'Attribute num exists?: '.($node->hasAttribute('num')?'Yes':'No')."\n";
+
+echo "Language: ".$node->getAttribute('language')."\n";
+$lang = $node->getAttributeNode('language');
+$lang->nodeValue = 'en-US';
+$node->setAttributeNode($lang);
+echo "Language: ".$node->getAttribute('language')."\n";
+$node->removeAttributeNode($lang);
+echo "Language: ".$node->getAttribute('language')."\n";
+
+echo "\n-- xml:lang --\n";
+$node->setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang', 'en');
+echo "Language: ".$node->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')."\n";
+echo 'Attribute xml:lang exists?: '.($node->hasAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')?'Yes':'No')."\n";
+
+$node->removeAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang');
+echo "Language: ".$node->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')."\n";
+echo 'Attribute xml:lang exists?: '.($node->hasAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')?'Yes':'No')."\n";
+
+$lang = $dom->createAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang');
+$lang->nodeValue = 'en-GB';
+$node->setAttributeNodeNS($lang);
+unset($lang);
+echo "Language: ".$node->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')."\n";
+$lang = $node->getAttributeNodeNS('http://www.w3.org/XML/1998/namespace', 'lang');
+echo "Language: ".$lang->value."\n";
+
+echo "\n-- Elements --\n";
+$rows = $node->getElementsByTagName('row');
+echo "Row Count: ".$rows->length."\n";
+
+$element_ns = new DOMElement('newns:myelement', 'default content', 'urn::dummyns');
+$node->appendChild($element_ns);
+$element_ns = new DOMElement('newns2:myelement', 'second default content', 'urn::dummyns');
+$node->appendChild($element_ns);
+
+$myelements = $node->getElementsByTagNameNS('urn::dummyns', 'myelement');
+$mylen = $myelements->length;
+echo "myelements Count: ".$mylen."\n";
+
+echo "\n-- IDs --\n";
+$node->setAttribute('idatt', 'n1');
+$node->setIdAttribute('idatt', TRUE);
+
+for ($x = 0; $x < $mylen; $x++) {
+ $current = $myelements->item($x);
+ $current->setAttributeNS('urn::dummyns', 'newns:idatt', 'n'.($x+2))."\n";
+ $current->setIdAttributeNS('urn::dummyns', 'idatt', TRUE);
+}
+
+echo 'Element Name: '.(($elem = $dom->getElementByID('n1'))?$elem->localName:'Not Found')."\n";
+$idatt = $node->getAttributeNode('idatt');
+$node->setIdAttributeNode($idatt, FALSE);
+echo 'Element Name: '.(($elem = $dom->getElementByID('n1'))?$elem->localName:'Not Found')."\n";
+
+echo 'Element Name: '.(($elem = $dom->getElementByID('n3'))?$elem->nodeName:'Not Found')."\n";
+for ($x = 0; $x < $mylen; $x++) {
+ $node = $myelements->item($x);
+ $node->setIdAttributeNS('urn::dummyns', 'idatt', FALSE);
+}
+echo 'Element Name: '.(($elem = $dom->getElementByID('n3'))?$elem->nodeName:'Not Found')."\n";
+?>
+--EXPECT--
+
+Tag Name: chapter
+Chapter: 1
+Attribute num exists?: Yes
+Chapter:
+Attribute num exists?: No
+Language: en
+Language: en-US
+Language:
+
+-- xml:lang --
+Language: en
+Attribute xml:lang exists?: Yes
+Language:
+Attribute xml:lang exists?: No
+Language: en-GB
+Language: en-GB
+
+-- Elements --
+Row Count: 3
+myelements Count: 2
+
+-- IDs --
+Element Name: chapter
+Element Name: Not Found
+Element Name: newns2:myelement
+Element Name: Not Found
diff --git a/ext/dom/tests/domobject_debug_handler.phpt b/ext/dom/tests/domobject_debug_handler.phpt
new file mode 100644
index 0000000..3c9f133
--- /dev/null
+++ b/ext/dom/tests/domobject_debug_handler.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Objects of DOM extension: debug info object handler.
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = <<<XML
+<foo>
+ <bar>foobar</bar>
+</foo>
+XML;
+$d = new domdocument;
+$d->dynamicProperty = new stdclass;
+$d->loadXML($xml);
+print_r($d);
+--EXPECTF--
+DOMDocument Object
+(
+ [dynamicProperty] => stdClass Object
+ (
+ )
+
+ [doctype] =>
+ [implementation] => (object value omitted)
+ [documentElement] => (object value omitted)
+ [actualEncoding] =>
+ [encoding] =>
+ [xmlEncoding] =>
+ [standalone] => 1
+ [xmlStandalone] => 1
+ [version] => 1.0
+ [xmlVersion] => 1.0
+ [strictErrorChecking] => 1
+ [documentURI] => %s
+ [config] =>
+ [formatOutput] =>
+ [validateOnParse] =>
+ [resolveExternals] =>
+ [preserveWhiteSpace] => 1
+ [recover] =>
+ [substituteEntities] =>
+ [nodeName] => #document
+ [nodeValue] =>
+ [nodeType] => 9
+ [parentNode] =>
+ [childNodes] => (object value omitted)
+ [firstChild] => (object value omitted)
+ [lastChild] => (object value omitted)
+ [previousSibling] =>
+ [attributes] =>
+ [ownerDocument] =>
+ [namespaceURI] =>
+ [prefix] =>
+ [localName] =>
+ [baseURI] => %s
+ [textContent] =>
+ foobar
+
+)
diff --git a/ext/dom/tests/domxpath.phpt b/ext/dom/tests/domxpath.phpt
new file mode 100644
index 0000000..82396b5
--- /dev/null
+++ b/ext/dom/tests/domxpath.phpt
@@ -0,0 +1,58 @@
+--TEST--
+DOMXPath Tests
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+function MyAverage($nodelist) {
+ $count = 0;
+ $val = 0;
+ foreach ($nodelist AS $node) {
+ $count++;
+ $val += $node->textContent;
+ }
+ if ($val > 0) {
+ return $val/$count;
+ } else {
+ return 0;
+ }
+}
+
+$dom = new DOMDocument;
+$dom->loadXML(b'<root xmlns="urn::default"><child>myval</child></root>');
+
+$xpath = new DOMXPath($dom);
+
+$xpath->registerPHPFunctions('MyAverage');
+$xpath->registerNamespace("php", "http://php.net/xpath");
+
+$xpath->registerNamespace("def", "urn::default");
+$nodelist = $xpath->query("//def:child");
+if ($node = $nodelist->item(0)) {
+ print $node->textContent."\n";
+}
+
+$count = $xpath->evaluate("count(//def:child)");
+
+var_dump($count);
+
+$xpathdoc = $xpath->document;
+
+var_dump($xpathdoc instanceof DOMDocument);
+
+$root = $dom->documentElement;
+$root->appendChild($dom->createElementNS("urn::default", "testnode", 3));
+$root->appendChild($dom->createElementNS("urn::default", "testnode", 4));
+$root->appendChild($dom->createElementNS("urn::default", "testnode", 4));
+$root->appendChild($dom->createElementNS("urn::default", "testnode", 5));
+
+$avg = $xpath->evaluate('number(php:function("MyAverage", //def:testnode))');
+var_dump($avg);
+?>
+--EXPECT--
+myval
+float(1)
+bool(true)
+float(4) \ No newline at end of file
diff --git a/ext/dom/tests/note.dtd b/ext/dom/tests/note.dtd
new file mode 100644
index 0000000..c2d558e
--- /dev/null
+++ b/ext/dom/tests/note.dtd
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!ELEMENT note (to,from,heading,body)>
+<!ELEMENT to (#PCDATA)>
+<!ELEMENT from (#PCDATA)>
+<!ELEMENT heading (#PCDATA)>
+<!ELEMENT body (#PCDATA)>
diff --git a/ext/dom/tests/note.xml b/ext/dom/tests/note.xml
new file mode 100644
index 0000000..49614a1
--- /dev/null
+++ b/ext/dom/tests/note.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE note SYSTEM "note.dtd">
+<note>
+<to>PHP User Group</to>
+<from>Shane</from>
+<heading>Reminder</heading>
+<body>Don't forget the meeting tonight!</body>
+</note>
diff --git a/ext/dom/tests/nsdoc.xml b/ext/dom/tests/nsdoc.xml
new file mode 100644
index 0000000..9503fd8
--- /dev/null
+++ b/ext/dom/tests/nsdoc.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<root xmlns="http://ns" xmlns:ns2="http://ns2">
+ <ns2:child />
+</root> \ No newline at end of file
diff --git a/ext/dom/tests/regsiter_node_class.phpt b/ext/dom/tests/regsiter_node_class.phpt
new file mode 100644
index 0000000..c632c61
--- /dev/null
+++ b/ext/dom/tests/regsiter_node_class.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test: registerNodeClass()
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+class myAttribute extends DOMAttr {
+ function testit() { return "HELLO Attribute"; }
+}
+
+class myElement extends DOMElement {
+ function testit() { return "HELLO Element"; }
+}
+
+$doc = new DOMDocument();
+$doc->registerNodeClass('DOMAttr', 'myAttribute');
+$doc->registerNodeClass('DOMElement', 'myElement');
+$doc->appendChild(new DOMElement('root'));
+$root = $doc->documentElement;
+$root->setAttribute('a', 'a1');
+echo get_class($root), "\n";
+print $root->testit()."\n";
+$attr = $root->getAttributeNode('a');
+echo get_class($attr), "\n";
+print $attr->testit()."\n";
+unset($attr);
+$doc->registerNodeClass('DOMAttr', NULL);
+$attr = $root->getAttributeNode('a');
+echo get_class($attr), "\n";
+print $attr->testit()."\n";
+?>
+--EXPECTF--
+
+myElement
+HELLO Element
+myAttribute
+HELLO Attribute
+DOMAttr
+
+Fatal error: Call to undefined method DOMAttr::testit() in %s on line 25
diff --git a/ext/dom/tests/skipif.inc b/ext/dom/tests/skipif.inc
new file mode 100644
index 0000000..08fd695
--- /dev/null
+++ b/ext/dom/tests/skipif.inc
@@ -0,0 +1 @@
+<?php if (!extension_loaded('dom')) die('skip dom extension not available');?> \ No newline at end of file
diff --git a/ext/dom/tests/test.html b/ext/dom/tests/test.html
new file mode 100644
index 0000000..fe6d0d3
--- /dev/null
+++ b/ext/dom/tests/test.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+<title>Hello world</title>
+</head>
+<body>
+This is a not well-formed<br>
+html files with undeclared entities&nbsp;
+</body>
+</html>
diff --git a/ext/dom/tests/xinclude.xml b/ext/dom/tests/xinclude.xml
new file mode 100644
index 0000000..27efa91
--- /dev/null
+++ b/ext/dom/tests/xinclude.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<foo xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="compress.zlib://ext/dom/tests/book.xml#xpointer(/books/book)"/>
+ </foo>