summaryrefslogtreecommitdiff
path: root/ext/dom/tests
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:37 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:37 -0400
commit10f5b47dc7c1cf2b9a00991629f43652710322d3 (patch)
tree3b727a16f652b8042d573e90f003868ffb3b56c7 /ext/dom/tests
parent0e920280a2e04b110827bb766b9f29e3d581c4ee (diff)
downloadphp-10f5b47dc7c1cf2b9a00991629f43652710322d3.tar.gz
Imported Upstream version 5.0.5upstream/5.0.5
Diffstat (limited to 'ext/dom/tests')
-rw-r--r--ext/dom/tests/bug32615.phpt84
-rw-r--r--ext/dom/tests/dom003.phpt26
2 files changed, 107 insertions, 3 deletions
diff --git a/ext/dom/tests/bug32615.phpt b/ext/dom/tests/bug32615.phpt
new file mode 100644
index 000000000..e48973429
--- /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/dom003.phpt b/ext/dom/tests/dom003.phpt
index e8c1db2ce..3c4e243c4 100644
--- a/ext/dom/tests/dom003.phpt
+++ b/ext/dom/tests/dom003.phpt
@@ -27,11 +27,30 @@ object(DOMException)#%d (6) {
["string:private"]=>
string(0) ""
["file:protected"]=>
- string(%d) "%s/ext/dom/tests/dom003.php"
+ string(%d) "%sdom003.php"
["line:protected"]=>
int(8)
["trace:private"]=>
- array(0) {
+ 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]=>
+ object(DOMElement)#%d (0) {
+ }
+ }
+ }
}
["code"]=>
int(3)
@@ -40,5 +59,6 @@ object(DOMException)#%d (6) {
Fatal error: Uncaught exception 'DOMException' with message 'Hierarchy Request Error' in %sdom003.php:%d
Stack trace:
-#0 {main}
+#0 %sdom003.php(%d): DOMNode->appendChild(Object(DOMElement))
+#1 {main}
thrown in %sdom003.php on line %d