1
0
mirror of synced 2025-01-18 06:21:40 +03:00

Merge branch 'DDC-1659'

This commit is contained in:
Benjamin Eberlei 2012-02-20 09:36:51 +01:00
commit 85d1707a2b
2 changed files with 39 additions and 4 deletions

View File

@ -1395,6 +1395,7 @@ class UnitOfWork implements PropertyChangedListener
if (isset($this->identityMap[$className][$idHash])) { if (isset($this->identityMap[$className][$idHash])) {
unset($this->identityMap[$className][$idHash]); unset($this->identityMap[$className][$idHash]);
unset($this->readOnlyObjects[$oid]);
//$this->entityStates[$oid] = self::STATE_DETACHED; //$this->entityStates[$oid] = self::STATE_DETACHED;
@ -2209,6 +2210,7 @@ class UnitOfWork implements PropertyChangedListener
$this->collectionDeletions = $this->collectionDeletions =
$this->collectionUpdates = $this->collectionUpdates =
$this->extraUpdates = $this->extraUpdates =
$this->readOnlyObjects =
$this->orphanRemovals = array(); $this->orphanRemovals = array();
if ($this->commitOrderCalculator !== null) { if ($this->commitOrderCalculator !== null) {

View File

@ -15,9 +15,12 @@ class ReadOnlyTest extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
$this->_schemaTool->createSchema(array( try {
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\ReadOnlyEntity'), $this->_schemaTool->createSchema(array(
)); $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\ReadOnlyEntity'),
));
} catch(\Exception $e) {
}
} }
public function testReadOnlyEntityNeverChangeTracked() public function testReadOnlyEntityNeverChangeTracked()
@ -36,6 +39,36 @@ class ReadOnlyTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals("Test1", $dbReadOnly->name); $this->assertEquals("Test1", $dbReadOnly->name);
$this->assertEquals(1234, $dbReadOnly->numericValue); $this->assertEquals(1234, $dbReadOnly->numericValue);
} }
/**
* @group DDC-1659
*/
public function testClearReadOnly()
{
$readOnly = new ReadOnlyEntity("Test1", 1234);
$this->_em->persist($readOnly);
$this->_em->flush();
$this->_em->getUnitOfWork()->markReadOnly($readOnly);
$this->_em->clear();
$this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly));
}
/**
* @group DDC-1659
*/
public function testClearEntitiesReadOnly()
{
$readOnly = new ReadOnlyEntity("Test1", 1234);
$this->_em->persist($readOnly);
$this->_em->flush();
$this->_em->getUnitOfWork()->markReadOnly($readOnly);
$this->_em->clear(get_class($readOnly));
$this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly));
}
} }
/** /**