Commit 1278934f authored by zYne's avatar zYne

Fixed #108

Ticket: 108
parent d94d5ec1
......@@ -381,6 +381,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$record = $this->tables[$name]->getRecord();
if($name == $root) {
// add record into root collection
$coll->add($record);
unset($previd);
......@@ -400,8 +401,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
case Doctrine_Relation::ONE_AGGREGATE:
// one-to-one relation
$last->internalSet($fk->getLocal(), $record->getIncremented());
$last->rawSet($fk->getLocal(), $record->getIncremented());
$last->initSingleReference($record, $fk);
......
......@@ -23,32 +23,42 @@ class Doctrine_RelationAccessTestCase extends Doctrine_UnitTestCase {
$this->tables = array("File_Owner", "Data_File");
parent::prepareTables();
}
public function testOneToOneAggregateRelationFetching() {
$coll = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner1'");
$this->assertTrue(count($coll) == 1);
$this->assertTrue($coll[0] instanceof Doctrine_Record);
$this->assertEqual($coll[0]->id, 1);
}
public function testAccessOneToOneFromForeignSide() {
$check = $this->connection->query("FROM File_Owner WHERE File_Owner.name = 'owner1'");
$owner1 = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner1'");
$owner2 = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner2'");
$this->assertTrue(count($check) == 1);
$this->assertTrue(count($owner1) == 1);
$this->assertTrue(count($owner2) == 1);
$check = $check[0];
$owner1 = $owner1[0];
$owner2 = $owner2[0];
$this->assertEqual($owner1->name, 'owner1');
$this->assertEqual($owner1->id, 1);
$check2 = $this->connection->query("FROM File_Owner WHERE File_Owner.id = ".$owner1->get('id'));
$this->assertEqual(1, count($check2));
$check2 = $check2[0];
$this->assertEqual('owner1', $check2->get('name'));
$this->assertTrue(isset($owner1->Data_File));
$this->assertFalse(isset($owner2->Data_File));
$this->assertEqual(1, $check->get('id'));
$this->assertEqual(1, $owner1->get('id'));
$this->assertEqual($owner1->get('id'), $check->get('id'));
$this->assertEqual(2, $owner2->get('id'));
}
public function testAccessOneToOneFromLocalSide() {
$check = $this->connection->query("FROM Data_File WHERE Data_File.filename = 'file4'");
$file1 = $this->connection->query("FROM Data_File.File_Owner WHERE Data_File.filename = 'file4'");
......@@ -74,5 +84,6 @@ class Doctrine_RelationAccessTestCase extends Doctrine_UnitTestCase {
$this->assertEqual(1, $file2->get('id'));
}
}
?>
......@@ -25,7 +25,7 @@ require_once("FilterTestCase.php");
require_once("ValueHolderTestCase.php");
require_once("QueryLimitTestCase.php");
require_once("QueryReferenceModelTestCase.php");
//require_once("DBTestCase.php");
require_once("DBTestCase.php");
require_once("SchemaTestCase.php");
require_once("ImportTestCase.php");
require_once("BooleanTestCase.php");
......@@ -37,7 +37,7 @@ error_reporting(E_ALL);
$test = new GroupTest("Doctrine Framework Unit Tests");
//$test->addTestCase(new Doctrine_DB_TestCase());
$test->addTestCase(new Doctrine_DB_TestCase());
$test->addTestCase(new Doctrine_ConnectionTestCase());
......
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