1
0
mirror of synced 2025-01-31 12:32:59 +03:00

DDC-2704 - data should be merged only into initialized proxies

This commit is contained in:
Marco Pivetta 2015-01-20 15:48:00 +01:00
parent 21995a8b10
commit 91f4ed8b92

View File

@ -83,6 +83,35 @@ class MergeProxiesTest extends OrmFunctionalTestCase
$this->assertFalse($managed->__isInitialized());
}
/**
* @group DDC-1392
* @group DDC-1734
* @group DDC-3368
* @group #1172
*
* Bug discovered while working on DDC-2704 - merging towards un-initialized proxies does not initialize them,
* causing merged data to be lost when they are actually initialized
*/
public function testMergeWithExistingUninitializedManagedProxy()
{
$date = new DateTimeModel();
$this->_em->persist($date);
$this->_em->flush($date);
$this->_em->clear();
$managed = $this->_em->getReference(DateTimeModel::CLASSNAME, $date->id);
$this->assertInstanceOf('Doctrine\Common\Proxy\Proxy', $managed);
$this->assertFalse($managed->__isInitialized());
$date->date = $dateTime = new \DateTime();
$this->assertSame($managed, $this->_em->merge($date));
$this->assertTrue($managed->__isInitialized());
$this->assertSame($dateTime, $managed->date, 'Data was merged into the proxy after initialization');
}
/**
* @group DDC-1392
* @group DDC-1734