[Solar-svn] Revision 2754

pmjones at solarphp.com pmjones at solarphp.com
Mon Sep 17 09:08:01 CDT 2007


updated tests


Modified: branches/orm/tests/Test/Solar/Sql/ModelRelated/HasManyThrough.php
===================================================================
--- branches/orm/tests/Test/Solar/Sql/ModelRelated/HasManyThrough.php	2007-09-17 14:07:24 UTC (rev 2753)
+++ branches/orm/tests/Test/Solar/Sql/ModelRelated/HasManyThrough.php	2007-09-17 14:08:01 UTC (rev 2754)
@@ -247,4 +247,38 @@
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
     }
+    
+    public function testEagerFetchOne_noneRelated()
+    {
+        $this->_populateAll();
+        
+        // remove taggings on one of the nodes
+        $node_id = rand(1,10);
+        $taggings = $this->_newModel('taggings');
+        $table = $taggings->table_name;
+        $cmd = "DELETE FROM $table WHERE node_id = $node_id";
+        $this->_sql->query($cmd);
+        
+        // fetch one node with an eager tags
+        // then see how many sql calls so far
+        $nodes = $this->_newModel('nodes');
+        $params = array(
+            'where' => array(
+                'id = ?' => $node_id,
+            ),
+            'eager' => 'tags',
+        );
+        
+        $node = $nodes->fetchOne($params);
+        $count_before = count($this->_sql->getProfile());
+        
+        // get the tags, make sure there aren't any.
+        $tags = $node->tags;
+        $this->assertInstance($tags, 'Solar_Example_Model_Tags_Collection');
+        $this->assertTrue(count($tags) == 0);
+        
+        // should have been no extra SQL calls
+        $count_after = count($this->_sql->getProfile());
+        $this->assertEquals($count_after, $count_before);
+    }
 }




More information about the Solar-svn mailing list