~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/dom/tests/bug32615.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Bug # 32615: (Replacing and inserting Fragments)
 
3
--SKIPIF--
 
4
<?php require_once('skipif.inc'); ?>
 
5
--FILE--
 
6
<?php
 
7
$dom = new DomDocument;
 
8
$frag = $dom->createDocumentFragment();
 
9
$frag->appendChild(new DOMElement('root'));
 
10
$dom->appendChild($frag);
 
11
$root = $dom->documentElement;
 
12
 
 
13
$frag->appendChild(new DOMElement('first'));
 
14
$root->appendChild($frag);
 
15
 
 
16
$frag->appendChild(new DOMElement('second'));
 
17
$root->appendChild($frag);
 
18
 
 
19
$node = $dom->createElement('newfirst');
 
20
$frag->appendChild($node);
 
21
$root->replaceChild($frag, $root->firstChild);
 
22
 
 
23
unset($frag);
 
24
$frag = $dom->createDocumentFragment();
 
25
 
 
26
$frag->appendChild(new DOMElement('newsecond'));
 
27
$root->replaceChild($frag, $root->lastChild);
 
28
 
 
29
$node = $frag->appendChild(new DOMElement('fourth'));
 
30
$root->insertBefore($frag, NULL);
 
31
 
 
32
$frag->appendChild(new DOMElement('third'));
 
33
$node = $root->insertBefore($frag, $node);
 
34
 
 
35
$frag->appendChild(new DOMElement('start'));
 
36
$root->insertBefore($frag, $root->firstChild);
 
37
 
 
38
$frag->appendChild(new DOMElement('newthird'));
 
39
$root->replaceChild($frag, $node);
 
40
 
 
41
$frag->appendChild(new DOMElement('newfourth'));
 
42
$root->replaceChild($frag, $root->lastChild);
 
43
 
 
44
$frag->appendChild(new DOMElement('first'));
 
45
$root->replaceChild($frag, $root->firstChild->nextSibling);
 
46
 
 
47
$root->removeChild($root->firstChild);
 
48
 
 
49
echo $dom->saveXML()."\n";
 
50
 
 
51
while ($root->hasChildNodes()) {
 
52
   $root->removeChild($root->firstChild);
 
53
}
 
54
 
 
55
$frag->appendChild(new DOMElement('first'));
 
56
$root->insertBefore($frag, $root->firstChild);
 
57
 
 
58
$node = $frag->appendChild(new DOMElement('fourth'));
 
59
$root->appendChild($frag);
 
60
 
 
61
$frag->appendChild(new DOMElement('second'));
 
62
$frag->appendChild(new DOMElement('third'));
 
63
$root->insertBefore($frag, $node);
 
64
 
 
65
echo $dom->saveXML()."\n";
 
66
 
 
67
$frag = $dom->createDocumentFragment();
 
68
$root = $dom->documentElement;
 
69
$root->replaceChild($frag, $root->firstChild);
 
70
 
 
71
echo $dom->saveXML();
 
72
 
 
73
?>
 
74
--EXPECT--
 
75
 
 
76
<?xml version="1.0"?>
 
77
<root><first/><newsecond/><newthird/><newfourth/></root>
 
78
 
 
79
<?xml version="1.0"?>
 
80
<root><first/><second/><third/><fourth/></root>
 
81
 
 
82
<?xml version="1.0"?>
 
83
<root><second/><third/><fourth/></root>
 
84