[Solar-svn] Revision 2790

pmjones at solarphp.com pmjones at solarphp.com
Fri Sep 28 20:07:50 CDT 2007


branch: updated Model-related tests to conform to new Model code (forthcoming)



Modified: branches/orm/tests/Test/Solar/Sql/Model/Collection.php
===================================================================
--- branches/orm/tests/Test/Solar/Sql/Model/Collection.php	2007-09-26 12:45:43 UTC (rev 2789)
+++ branches/orm/tests/Test/Solar/Sql/Model/Collection.php	2007-09-29 01:07:50 UTC (rev 2790)
@@ -62,9 +62,9 @@
         $this->_sql = Solar::factory('Solar_Sql');
         $this->_sql->setProfiling(true);
         
-        $this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', array(
-            'sql' => $this->_sql
-        ));
+        // $this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', array(
+        //     'sql' => $this->_sql
+        // ));
         
         $this->_dropAll();
         

Modified: branches/orm/tests/Test/Solar/Sql/Model.php
===================================================================
--- branches/orm/tests/Test/Solar/Sql/Model.php	2007-09-26 12:45:43 UTC (rev 2789)
+++ branches/orm/tests/Test/Solar/Sql/Model.php	2007-09-29 01:07:50 UTC (rev 2790)
@@ -49,7 +49,11 @@
     protected $_Test_Solar_Sql_Model = array(
     );
     
-    // the SQL connection
+    /**
+     * 
+     * The SQL connection.
+     * 
+     */
     protected $_sql;
     
     // -----------------------------------------------------------------
@@ -90,15 +94,8 @@
     public function setup()
     {
         parent::setup();
-        
         $this->_sql = Solar::factory('Solar_Sql');
-        
         $this->_sql->setProfiling(true);
-        
-        $this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', array(
-            'sql' => $this->_sql
-        ));
-        
         $this->_dropAll();
     }
     
@@ -140,10 +137,6 @@
         foreach ($drop as $name) {
             $this->_sql->dropSequence("test_solar_$name");
         }
-        
-        // reset the catalog, so that new model instances re-create
-        // the tables correctly
-        $this->_catalog->reset();
     }
     
     protected function _populateSpecialColsTable()
@@ -154,6 +147,12 @@
             $record->name = chr($i+96); //ascii 'a', 'b', etc
             $record->save();
         }
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     // -----------------------------------------------------------------
@@ -169,13 +168,19 @@
      */
     public function test__construct()
     {
-        $obj = $this->_newModel('TestSolarSpecialCols');
-        $this->assertInstance($obj, 'Solar_Sql_Model');
-        $this->assertInstance($obj, 'Solar_Example_Model_TestSolarSpecialCols');
+        $model = $this->_newModel('TestSolarSpecialCols');
+        $this->assertInstance($model, 'Solar_Sql_Model');
+        $this->assertInstance($model, 'Solar_Example_Model_TestSolarSpecialCols');
         
         // did it create the table automatically?
         $list = $this->_sql->fetchTableList();
         $this->assertTrue(in_array('test_solar_special_cols', $list));
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -276,6 +281,12 @@
             $this->assertEquals($record->name, 'z');
             $this->assertEquals($record->seq_foo, 88);
         }
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -299,6 +310,12 @@
         } catch (Solar_Exception $e) {
             // do nothing, this is the expected case :-)
         }
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -322,6 +339,12 @@
         $actual = $model->countPages(array('where' => $where));
         $expect = array('count' => 5, 'pages' => 2);
         $this->assertEquals($actual, $expect);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -349,6 +372,12 @@
         // should not be able to retrieve the record
         $record = $model->fetch(7);
         $this->assertNull($record);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -378,6 +407,12 @@
             // make sure they're the right ones ;-)
             $this->assertEquals($record->name, chr($record->id + 96));
         }
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -402,6 +437,12 @@
             // make sure they're the right ones ;-)
             $this->assertEquals($record->name, chr($record->id + 96));
         }
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -434,6 +475,12 @@
         $actual = array_keys($array);
         $expect = array('f', 'g', 'h', 'i', 'j');
         $this->assertSame($actual, $expect);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -458,6 +505,12 @@
         
         $expect = array('f', 'g', 'h', 'i', 'j');
         $this->assertSame($actual, $expect);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -476,6 +529,12 @@
         $this->assertEquals($record->test_default_integer, 7);
         $this->assertEquals($record->test_default_numeric, 1234.567);
         $this->assertNull($record->test_default_ignore);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -497,6 +556,12 @@
         $this->assertInstance($record, 'Solar_Sql_Model_Record');
         $this->assertInstance($record, 'Solar_Example_Model_TestSolarSpecialCols_Record');
         $this->assertEquals($record->name, 'c'); // make sure it's the right one ;-)
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -528,6 +593,12 @@
             'j' => '10',
         );
         $this->assertEquals($actual, $expect);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -544,6 +615,12 @@
         
         $actual = $model->getPaging();
         $this->assertEquals($actual, $expect);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -573,6 +650,12 @@
         $this->assertEquals($record->email, $email);
         $this->assertEquals($record->uri, $uri);
         $this->assertEquals($record->name, $name);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -604,6 +687,12 @@
         // insert should pass
         $record->email = 'nobody at example.com';
         $model->insert($record);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -631,6 +720,12 @@
         } catch (Exception $e) {
             $this->assertInstance($e, 'Solar_Sql_Adapter_Exception_QueryFailed');
         }
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -651,6 +746,12 @@
         $record->inherit = null;
         $model->insert($record);
         $this->assertEquals($record->inherit, 'Bar');
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -677,6 +778,12 @@
         $model = $this->_newModel('TestSolarDib');
         $collection = $model->newCollection($data);
         $this->assertInstance($collection, 'Solar_Sql_Model_Collection');
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -718,6 +825,12 @@
         $model = $this->_newModel('TestSolarDib');
         $record = $model->newRecord($data);
         $this->assertInstance($record, 'Solar_Sql_Model_Record');
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -764,6 +877,12 @@
         $collection = $model->fetchAll(array('order' => 'id', 'page' => 4));
         $this->assertEquals(count($collection), 1);
         $this->assertEquals($collection[0]->id, 10);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -817,6 +936,12 @@
         $this->assertEquals($record->email, $email);
         $this->assertEquals($record->uri, $uri);
         $this->assertEquals($record->name, $name);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -852,6 +977,12 @@
         // update should pass
         $record->email = 'another at example.com';
         $model->update($record, null);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -883,6 +1014,12 @@
         } catch (Exception $e) {
             $this->assertInstance($e, 'Solar_Sql_Adapter_Exception_QueryFailed');
         }
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -912,6 +1049,12 @@
         $this->assertEquals($record->inherit, 'Bar');
         $record = $model->fetch(1);
         $this->assertEquals($record->inherit, 'Bar');
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
     
     /**
@@ -987,6 +1130,12 @@
         $this->assertEquals($record->id, 2);
         $this->assertEquals($record->seq_foo, 2);
         $this->assertEquals($record->seq_bar, 3);
+        
+        /**
+         * recover memory
+         */
+        $model->__destruct();
+        unset($model);
     }
 
 

Modified: branches/orm/tests/Test/Solar/Sql/ModelRelated/BelongsTo.php
===================================================================
--- branches/orm/tests/Test/Solar/Sql/ModelRelated/BelongsTo.php	2007-09-26 12:45:43 UTC (rev 2789)
+++ branches/orm/tests/Test/Solar/Sql/ModelRelated/BelongsTo.php	2007-09-29 01:07:50 UTC (rev 2790)
@@ -19,13 +19,14 @@
         $expect = array (
             'name' => 'area',
             'type' => 'belongs_to',
-            'foreign_model' => 'Solar_Example_Model_Areas',
+            'foreign_class' => 'Solar_Example_Model_Areas',
             'foreign_table' => 'test_solar_areas',
             'foreign_alias' => 'area',
             'foreign_col' => 'id',
             'foreign_inherit_col' => NULL,
             'foreign_inherit_val' => NULL,
             'foreign_primary_col' => 'id',
+            'native_class' => 'Solar_Example_Model_Nodes',
             'native_table' => 'test_solar_nodes',
             'native_alias' => 'nodes',
             'native_col' => 'area_id',
@@ -34,13 +35,12 @@
             'through_alias' => NULL,
             'through_native_col' => NULL,
             'through_foreign_col' => NULL,
-            'distinct' => NULL,
-            'where' => array(),
+            'distinct' => false,
+            'where' => NULL,
             'group' => NULL,
             'having' => NULL,
             'order' =>  array('area.id'),
             'paging' => 10,
-            'page' => 0,
             'cols' =>  array(
                 0 => 'id',
                 1 => 'created',
@@ -48,9 +48,16 @@
                 3 => 'user_id',
                 4 => 'name',
             ),
+            'fetch' => 'one',
         );
         
-        $this->assertSame($nodes->related['area'], $expect);
+        $actual = $nodes->getRelated('area')->toArray();
+        
+        $this->assertSame($actual, $expect);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testLazyFetchOne()
@@ -83,6 +90,10 @@
         $this->assertEquals($node->area_id, $area->id);
         $count_final = count($this->_sql->getProfile());
         $this->assertEquals($count_final, $count_after);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testLazyFetchAll()
@@ -114,6 +125,10 @@
         
         $count_final = count($this->_sql->getProfile());
         $this->assertEquals($count_final, $count_after);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testEagerFetchOne()
@@ -140,6 +155,10 @@
         // **should not** have been an extra SQL call
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testEagerFetchAll()
@@ -163,5 +182,9 @@
         // **should not** have been extra SQL calls
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
 }

Modified: branches/orm/tests/Test/Solar/Sql/ModelRelated/HasMany.php
===================================================================
--- branches/orm/tests/Test/Solar/Sql/ModelRelated/HasMany.php	2007-09-26 12:45:43 UTC (rev 2789)
+++ branches/orm/tests/Test/Solar/Sql/ModelRelated/HasMany.php	2007-09-29 01:07:50 UTC (rev 2790)
@@ -14,13 +14,14 @@
         $expect = array (
             'name' => 'nodes',
             'type' => 'has_many',
-            'foreign_model' => 'Solar_Example_Model_Nodes',
+            'foreign_class' => 'Solar_Example_Model_Nodes',
             'foreign_table' => 'test_solar_nodes',
             'foreign_alias' => 'nodes',
             'foreign_col' => 'area_id',
             'foreign_inherit_col' => NULL,
             'foreign_inherit_val' => NULL,
             'foreign_primary_col' => 'id',
+            'native_class' => 'Solar_Example_Model_Areas',
             'native_table' => 'test_solar_areas',
             'native_alias' => 'areas',
             'native_col' => 'id',
@@ -29,13 +30,12 @@
             'through_alias' => NULL,
             'through_native_col' => NULL,
             'through_foreign_col' => NULL,
-            'distinct' => NULL,
-            'where' => array(),
+            'distinct' => false,
+            'where' => NULL,
             'group' => NULL,
             'having' => NULL,
             'order' => array('nodes.id'),
             'paging' => 10,
-            'page' => 0,
             'cols' => array (
                 0 => 'id',
                 1 => 'created',
@@ -47,9 +47,15 @@
                 7 => 'subj',
                 8 => 'body',
             ),
+            'fetch' => 'all',
         );
         
-        $this->assertSame($areas->related['nodes'], $expect);
+        $actual = $areas->getRelated('nodes')->toArray();
+        $this->assertSame($actual, $expect);
+        
+        // recover memory
+        $areas->__destruct();
+        unset($areas);
     }
     
     public function testLazyFetchOne()
@@ -83,6 +89,10 @@
         $this->assertInstance($nodes, 'Solar_Example_Model_Nodes_Collection');
         $count_final = count($this->_sql->getProfile());
         $this->assertEquals($count_final, $count_after);
+        
+        // recover memory
+        $areas->__destruct();
+        unset($areas);
     }
     
     public function testLazyFetchAll()
@@ -117,6 +127,10 @@
         
         $count_final = count($this->_sql->getProfile());
         $this->assertEquals($count_final, $count_after);
+        
+        // recover memory
+        $areas->__destruct();
+        unset($areas);
     }
     
     public function testEagerFetchOne()
@@ -146,6 +160,10 @@
         // **should not** have been an extra SQL call
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
+        
+        // recover memory
+        $areas->__destruct();
+        unset($areas);
     }
     
     public function testEagerFetchAll()
@@ -172,5 +190,9 @@
         // **should not** have been extra SQL calls
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
+        
+        // recover memory
+        $areas->__destruct();
+        unset($areas);
     }
 }

Modified: branches/orm/tests/Test/Solar/Sql/ModelRelated/HasManyThrough.php
===================================================================
--- branches/orm/tests/Test/Solar/Sql/ModelRelated/HasManyThrough.php	2007-09-26 12:45:43 UTC (rev 2789)
+++ branches/orm/tests/Test/Solar/Sql/ModelRelated/HasManyThrough.php	2007-09-29 01:07:50 UTC (rev 2790)
@@ -14,13 +14,14 @@
         $expect = array (
             'name' => 'taggings',
             'type' => 'has_many',
-            'foreign_model' => 'Solar_Example_Model_Taggings',
+            'foreign_class' => 'Solar_Example_Model_Taggings',
             'foreign_table' => 'test_solar_taggings',
             'foreign_alias' => 'taggings',
             'foreign_col' => 'node_id',
             'foreign_inherit_col' => NULL,
             'foreign_inherit_val' => NULL,
             'foreign_primary_col' => 'id',
+            'native_class' => 'Solar_Example_Model_Nodes',
             'native_table' => 'test_solar_nodes',
             'native_alias' => 'nodes',
             'native_col' => 'id',
@@ -29,35 +30,37 @@
             'through_alias' => NULL,
             'through_native_col' => NULL,
             'through_foreign_col' => NULL,
-            'distinct' => NULL,
-            'where' => array(),
+            'distinct' => false,
+            'where' => NULL,
             'group' => NULL,
             'having' => NULL,
             'order' => array(
                 0 => 'taggings.id',
             ),
             'paging' => 10,
-            'page' => 0,
             'cols' => array(
                 0 => 'id',
                 1 => 'node_id',
                 2 => 'tag_id',
             ),
+            'fetch' => 'all',
         );
         
-        $this->assertSame($nodes->related['taggings'], $expect);
+        $actual = $nodes->getRelated('taggings')->toArray();
+        $this->assertSame($actual, $expect);
         
         // make sure that nodes has-many tags through taggings
         $expect = array (
             'name' => 'tags',
             'type' => 'has_many',
-            'foreign_model' => 'Solar_Example_Model_Tags',
+            'foreign_class' => 'Solar_Example_Model_Tags',
             'foreign_table' => 'test_solar_tags',
             'foreign_alias' => 'tags',
             'foreign_col' => 'id',
             'foreign_inherit_col' => NULL,
             'foreign_inherit_val' => NULL,
             'foreign_primary_col' => 'id',
+            'native_class' => 'Solar_Example_Model_Nodes',
             'native_table' => 'test_solar_nodes',
             'native_alias' => 'nodes',
             'native_col' => 'id',
@@ -66,23 +69,28 @@
             'through_alias' => 'taggings',
             'through_native_col' => 'node_id',
             'through_foreign_col' => 'tag_id',
-            'distinct' => NULL,
-            'where' => array(),
+            'distinct' => false,
+            'where' => NULL,
             'group' => NULL,
             'having' => NULL,
             'order' => array(
                 0 => 'tags.id',
             ),
             'paging' => 10,
-            'page' => 0,
             'cols' => array(
                 0 => 'id',
                 1 => 'name',
                 2 => 'summ',
             ),
+            'fetch' => 'all',
         );
         
-        $this->assertSame($nodes->related['tags'], $expect);
+        $actual = $nodes->getRelated('tags')->toArray();
+        $this->assertSame($actual, $expect);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testLazyFetchOne()
@@ -138,6 +146,10 @@
         $this->assertInstance($tags, 'Solar_Example_Model_Tags_Collection');
         $count3 = count($this->_sql->getProfile());
         $this->assertEquals($count3, $count2);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testLazyFetchAll()
@@ -198,6 +210,10 @@
         
         $count_final = count($this->_sql->getProfile());
         $this->assertEquals($count_final, $count_after);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testEagerFetchOne()
@@ -226,6 +242,10 @@
         // should have been no extra SQL calls
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testEagerFetchAll()
@@ -250,6 +270,10 @@
         // should have been no extra SQL calls
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testEagerFetchOne_noneRelated()
@@ -284,5 +308,13 @@
         // should have been no extra SQL calls
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
+        
+        // recover memory
+        $taggings->__destruct();
+        unset($taggings);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
 }

Modified: branches/orm/tests/Test/Solar/Sql/ModelRelated/HasOne.php
===================================================================
--- branches/orm/tests/Test/Solar/Sql/ModelRelated/HasOne.php	2007-09-26 12:45:43 UTC (rev 2789)
+++ branches/orm/tests/Test/Solar/Sql/ModelRelated/HasOne.php	2007-09-29 01:07:50 UTC (rev 2790)
@@ -14,13 +14,14 @@
         $expect = array(
             'name' => 'meta',
             'type' => 'has_one',
-            'foreign_model' => 'Solar_Example_Model_Metas',
+            'foreign_class' => 'Solar_Example_Model_Metas',
             'foreign_table' => 'test_solar_metas',
             'foreign_alias' => 'meta',
             'foreign_col' => 'node_id',
             'foreign_inherit_col' => NULL,
             'foreign_inherit_val' => NULL,
             'foreign_primary_col' => 'id',
+            'native_class' => 'Solar_Example_Model_Nodes',
             'native_table' => 'test_solar_nodes',
             'native_alias' => 'nodes',
             'native_col' => 'id',
@@ -29,13 +30,12 @@
             'through_alias' => NULL,
             'through_native_col' => NULL,
             'through_foreign_col' => NULL,
-            'distinct' => NULL,
-            'where' => array(),
+            'distinct' => false,
+            'where' => NULL,
             'group' => NULL,
             'having' => NULL,
             'order' => array('meta.id'),
             'paging' => 10,
-            'page' => 0,
             'cols' => array(
                 0 => 'id',
                 1 => 'node_id',
@@ -44,9 +44,11 @@
                 4 => 'last_comment_at',
                 5 => 'comment_count',
             ),
+            'fetch' => 'one',
         );
         
-        $this->assertSame($nodes->related['meta'], $expect);
+        $actual = $nodes->getRelated('meta')->toArray();
+        $this->assertSame($actual, $expect);
     }
     
     public function testLazyFetchOne()
@@ -79,6 +81,10 @@
         $this->assertEquals($meta->node_id, $node->id);
         $count_final = count($this->_sql->getProfile());
         $this->assertEquals($count_final, $count_after);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testLazyFetchAll()
@@ -110,6 +116,10 @@
         
         $count_final = count($this->_sql->getProfile());
         $this->assertEquals($count_final, $count_after);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testEagerFetchOne()
@@ -136,6 +146,10 @@
         // **should not** have been an extra SQL call
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     public function testEagerFetchAll()
@@ -159,5 +173,9 @@
         // **should not** have been extra SQL calls
         $count_after = count($this->_sql->getProfile());
         $this->assertEquals($count_after, $count_before);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
 }

Modified: branches/orm/tests/Test/Solar/Sql/ModelRelated.php
===================================================================
--- branches/orm/tests/Test/Solar/Sql/ModelRelated.php	2007-09-26 12:45:43 UTC (rev 2789)
+++ branches/orm/tests/Test/Solar/Sql/ModelRelated.php	2007-09-29 01:07:50 UTC (rev 2790)
@@ -11,7 +11,11 @@
     protected $_Test_Solar_Sql_Model = array(
     );
     
-    // the SQL connection
+    /**
+     * 
+     * The SQL connection.
+     * 
+     */
     protected $_sql;
     
     // -----------------------------------------------------------------
@@ -52,15 +56,8 @@
     public function setup()
     {
         parent::setup();
-        
         $this->_sql = Solar::factory('Solar_Sql');
-        
         $this->_sql->setProfiling(true);
-        
-        $this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', array(
-            'sql' => $this->_sql
-        ));
-        
         $this->_dropAll();
     }
     
@@ -87,16 +84,6 @@
         return $model;
     }
     
-    protected function _newModels()
-    {
-        $model = new StdClass();
-        $model->areas = $this->_newModel('areas');
-        $model->nodes = $this->_newModel('nodes');
-        $model->taggings = $this->_newModel('taggings');
-        $model->tags = $this->_newModel('tags');
-        return $model;
-    }
-    
     protected function _dropAll()
     {
         // remove test_solar_* tables
@@ -112,10 +99,6 @@
         foreach ($drop as $name) {
             $this->_sql->dropSequence("test_solar_$name");
         }
-        
-        // reset the catalog, so that new model instances re-create
-        // the tables correctly
-        $this->_catalog->reset();
     }
     
     protected function _populateAll()
@@ -137,6 +120,10 @@
             $user->handle = $val;
             $user->save();
         }
+        
+        // recover memory
+        $users->__destruct();
+        unset($users);
     }
     
     protected function _populateAreas()
@@ -149,6 +136,10 @@
             $area->name = $val;
             $area->save();
         }   
+        
+        // recover memory
+        $areas->__destruct();
+        unset($areas);
     }
     
     protected function _populateNodes()
@@ -165,6 +156,10 @@
             $node->user_id = ($i + 1) % 2 + 1; // sometimes 2, sometimes 1
             $node->save();
         }
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
     }
     
     protected function _populateMetas()
@@ -178,6 +173,14 @@
             $meta->node_id = $node->id;
             $meta->save();
         }
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
+        
+        // recover memory
+        $metas->__destruct();
+        unset($metas);
     }
     
     protected function _populateTags()
@@ -192,19 +195,23 @@
             $tag->name = $name;
             $tag->save();
         }
+        
+        // recover memory
+        $tags->__destruct();
+        unset($tags);
     }
     
     protected function _populateTaggings()
     {
         $tags = $this->_newModel('tags');
+        $nodes = $this->_newModel('nodes');
+        $taggings = $this->_newModel('taggings');
+        
         $tag_coll = $tags->fetchAll();
         $tag_last = count($tag_coll) - 1;
         
-        $nodes = $this->_newModel('nodes');
         $node_coll = $nodes->fetchAll();
         
-        $taggings = $this->_newModel('taggings');
-        
         // add some tags on each node through taggings
         foreach ($node_coll as $node) {
             
@@ -235,5 +242,17 @@
                 $tagging->save();
             }
         }
+        
+        // recover memory
+        $tags->__destruct();
+        unset($tags);
+        
+        // recover memory
+        $nodes->__destruct();
+        unset($nodes);
+        
+        // recover memory
+        $taggings->__destruct();
+        unset($taggings);
     }
 }
\ No newline at end of file




More information about the Solar-svn mailing list