Author: dr
Date: Tue Jul 31 10:12:30 2007
New Revision: 5767

Log:
- Added a test for multiple-field data records and fixed implementation.

Modified:
    trunk/Tree/src/stores/db_external.php
    trunk/Tree/tests/db_parent_child_tree.php

Modified: trunk/Tree/src/stores/db_external.php
==============================================================================
--- trunk/Tree/src/stores/db_external.php [iso-8859-1] (original)
+++ trunk/Tree/src/stores/db_external.php [iso-8859-1] Tue Jul 31 10:12:30 2007
@@ -95,14 +95,10 @@
      */
     public function fetchDataForNode( ezcTreeNode $node )
     {
-        $id = $node->id;
-        if ( $this->table === null || $this->idField === null )
-        {
-            throw new Exception( "Not initialized" );
-        }
         $db = $this->dbHandler;
         $q = $db->createSelectQuery();
 
+        $id = $node->id;
         $q->select( '*' )
           ->from( $db->quoteIdentifier( $this->table ) )
           ->where( $q->expr->eq( $db->quoteIdentifier( $this->idField ), $id ) 
);

Modified: trunk/Tree/tests/db_parent_child_tree.php
==============================================================================
--- trunk/Tree/tests/db_parent_child_tree.php [iso-8859-1] (original)
+++ trunk/Tree/tests/db_parent_child_tree.php [iso-8859-1] Tue Jul 31 10:12:30 
2007
@@ -107,6 +107,20 @@
         self::assertSame( true, $tree->nodeExists( '3' ) );
     }
 
+    public function testMultipleDataFields()
+    {
+        $store = new ezcTreeDbExternalTableDataStore( $this->dbh, 'data', 'id' 
);
+        $tree = new ezcTreeDbParentChild(
+            $this->dbh,
+            'parent_child',
+            $store
+        );
+        $node8 = $tree->fetchNodeById( 8 ); // returns 8
+        self::assertType( 'ezcTreeNode', $node8 );
+        self::assertSame( '8', $node8->id );
+        self::assertSame( array( 'data' => 'Node 8', 0 => 'Node 8', 'id' => 
'8', 1 => '8' ), $node8->data );
+    }
+
     public static function suite()
     {
          return new PHPUnit_Framework_TestSuite( "ezcTreeDbParentChildTest" );


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

Reply via email to