Author: dr
Date: Tue Jul 31 09:56:55 2007
New Revision: 5764

Log:
- Added a test for setRootNode and fixed XML Tree implementation.

Modified:
    trunk/Tree/src/backends/xml.php
    trunk/Tree/tests/tree.php

Modified: trunk/Tree/src/backends/xml.php
==============================================================================
--- trunk/Tree/src/backends/xml.php [iso-8859-1] (original)
+++ trunk/Tree/src/backends/xml.php [iso-8859-1] Tue Jul 31 09:56:55 2007
@@ -285,7 +285,11 @@
         // remove old root node(s)
         foreach ( $document->childNodes as $child )
         {
-            echo $child->tagName, "\n";
+            if ( $child->nodeType == XML_ELEMENT_NODE && $child->tagName === 
'node' )
+            {
+                $id = substr( $child->getAttribute( 'id' ), 2 );
+                $this->delete( $id );
+            }
         }
 
         // Create new root node

Modified: trunk/Tree/tests/tree.php
==============================================================================
--- trunk/Tree/tests/tree.php [iso-8859-1] (original)
+++ trunk/Tree/tests/tree.php [iso-8859-1] Tue Jul 31 09:56:55 2007
@@ -543,6 +543,24 @@
             self::assertSame( "Node $id", $data );
         }
     }
+
+    public function testSetRootNode()
+    {
+        $tree = $this->setUpTestTree();
+
+        for ( $i = 1; $i < 10; ++$i )
+        {
+            self::assertSame( true, $tree->nodeExists( $i ) );
+        }
+
+        $tree->setRootNode( $root = $tree->createNode( 42, 'New Node' ) );
+
+        for ( $i = 1; $i < 10; ++$i )
+        {
+            self::assertSame( false, $tree->nodeExists( $i ) );
+        }
+        self::assertSame( true, $tree->nodeExists( '42' ) );
+    }
 }
 
 ?>


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to