zoe             Fri May 16 17:14:58 2008 UTC

  Modified files:              
    /php-src/ext/dom/tests      DOMNode_replaceChild_basic.phpt 
                                DOMDocument_loadHTML_basic.phpt 
                                
DOMDocumentFragment_appendXML_hasChildNodes_basic.phpt 
                                DOMDocument_save_basic.phpt 
                                DOMNode_hasChildNodes_basic.phpt 
  Log:
  Tests from Testfest 2008
  
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/DOMNode_replaceChild_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/dom/tests/DOMNode_replaceChild_basic.phpt
diff -u /dev/null php-src/ext/dom/tests/DOMNode_replaceChild_basic.phpt:1.2
--- /dev/null   Fri May 16 17:14:58 2008
+++ php-src/ext/dom/tests/DOMNode_replaceChild_basic.phpt       Fri May 16 
17:14:57 2008
@@ -0,0 +1,44 @@
+--TEST--
+Replacing a child node
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--CREDITS--
+Matt Raines <[EMAIL PROTECTED]>
+#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>
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/DOMDocument_loadHTML_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/dom/tests/DOMDocument_loadHTML_basic.phpt
diff -u /dev/null php-src/ext/dom/tests/DOMDocument_loadHTML_basic.phpt:1.2
--- /dev/null   Fri May 16 17:14:58 2008
+++ php-src/ext/dom/tests/DOMDocument_loadHTML_basic.phpt       Fri May 16 
17:14:57 2008
@@ -0,0 +1,18 @@
+--TEST--
+DOMDocument::loadHTML 
+--CREDITS--
+Frank Cassedanne [EMAIL PROTECTED]
+#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>
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/DOMDocumentFragment_appendXML_hasChildNodes_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: 
php-src/ext/dom/tests/DOMDocumentFragment_appendXML_hasChildNodes_basic.phpt
diff -u /dev/null 
php-src/ext/dom/tests/DOMDocumentFragment_appendXML_hasChildNodes_basic.phpt:1.2
--- /dev/null   Fri May 16 17:14:58 2008
+++ 
php-src/ext/dom/tests/DOMDocumentFragment_appendXML_hasChildNodes_basic.phpt    
    Fri May 16 17:14:57 2008
@@ -0,0 +1,21 @@
+--TEST--
+Testing DOMDocumentFragment::appendXML and DOMDocumentFragment::hasChildNodes
+--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
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/DOMDocument_save_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/dom/tests/DOMDocument_save_basic.phpt
diff -u /dev/null php-src/ext/dom/tests/DOMDocument_save_basic.phpt:1.2
--- /dev/null   Fri May 16 17:14:58 2008
+++ php-src/ext/dom/tests/DOMDocument_save_basic.phpt   Fri May 16 17:14:57 2008
@@ -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
+
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt
diff -u /dev/null php-src/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt:1.2
--- /dev/null   Fri May 16 17:14:58 2008
+++ php-src/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt      Fri May 16 
17:14:57 2008
@@ -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



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to