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