diff --git a/tests/Query/JoinTestCase.php b/tests/Query/JoinTestCase.php index 8f60fa21a..efc75a1a4 100644 --- a/tests/Query/JoinTestCase.php +++ b/tests/Query/JoinTestCase.php @@ -57,8 +57,27 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase $this->connection->clear(); } + public function testRecordHydrationWorksWithDeeplyNestedStructuresAndArrayFetching() + { + $q = new Doctrine_Query(); + + $q->select('c.*, c2.*, d.*') + ->from('Record_Country c')->leftJoin('c.City c2')->leftJoin('c2.District d') + ->where('c.id = ?', array(1)); + + $countries = $q->execute(array(), Doctrine::FETCH_ARRAY); + + $c = $countries[0]; + $this->assertEqual($c['City'][0]['name'], 'City 1'); + $this->assertEqual($c['City'][1]['name'], 'City 2'); + $this->assertEqual($c['City'][2]['name'], 'City 3'); + + $this->assertEqual($c['City'][0]['District']['name'], 'District 1'); + $this->assertEqual($c['City'][2]['District']['name'], 'District 2'); + } + public function testRecordHydrationWorksWithDeeplyNestedStructures() - { print "
";
+    {
         $q = new Doctrine_Query();
 
         $q->select('c.*, c2.*, d.*')
@@ -68,6 +87,7 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase
         $this->assertEqual($q->getQuery(), "SELECT r.id AS r__id, r.name AS r__name, r2.id AS r2__id, r2.name AS r2__name, r2.country_id AS r2__country_id, r2.district_id AS r2__district_id, r3.id AS r3__id, r3.name AS r3__name FROM record__country r LEFT JOIN record__city r2 ON r.id = r2.country_id LEFT JOIN record__district r3 ON r2.district_id = r3.id WHERE r.id = ?");
 
         $countries = $q->execute();
+
         $c = $countries[0];
         $this->assertEqual($c->City[0]->name, 'City 1');
         $this->assertEqual($c->City[1]->name, 'City 2');
@@ -76,7 +96,6 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase
         $this->assertEqual($c->City[0]->District->name, 'District 1');
         $this->assertEqual($c->City[2]->District->name, 'District 2');
     }
-    /**
     public function testManyToManyJoinUsesProperTableAliases()
     {
         $q = new Doctrine_Query();
@@ -122,5 +141,5 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase
             $this->fail();
         }
     }
-    */
+
 }