parent
d94d5ec1cb
commit
1278934f83
@ -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,18 +23,27 @@ 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));
|
||||
@ -47,6 +56,7 @@ class Doctrine_RelationAccessTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual(1, $owner1->get('id'));
|
||||
$this->assertEqual($owner1->get('id'), $check->get('id'));
|
||||
$this->assertEqual(2, $owner2->get('id'));
|
||||
|
||||
}
|
||||
|
||||
public function testAccessOneToOneFromLocalSide() {
|
||||
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user