Commit 240fdee5 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 0f108288
...@@ -57,8 +57,27 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase ...@@ -57,8 +57,27 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase
$this->connection->clear(); $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() public function testRecordHydrationWorksWithDeeplyNestedStructures()
{ print "<pre>"; {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$q->select('c.*, c2.*, d.*') $q->select('c.*, c2.*, d.*')
...@@ -68,6 +87,7 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase ...@@ -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 = ?"); $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(); $countries = $q->execute();
$c = $countries[0]; $c = $countries[0];
$this->assertEqual($c->City[0]->name, 'City 1'); $this->assertEqual($c->City[0]->name, 'City 1');
$this->assertEqual($c->City[1]->name, 'City 2'); $this->assertEqual($c->City[1]->name, 'City 2');
...@@ -76,7 +96,6 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase ...@@ -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[0]->District->name, 'District 1');
$this->assertEqual($c->City[2]->District->name, 'District 2'); $this->assertEqual($c->City[2]->District->name, 'District 2');
} }
/**
public function testManyToManyJoinUsesProperTableAliases() public function testManyToManyJoinUsesProperTableAliases()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
...@@ -122,5 +141,5 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase ...@@ -122,5 +141,5 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase
$this->fail(); $this->fail();
} }
} }
*/
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment