Merge branch 'DDC-2267'
This commit is contained in:
commit
937473329f
@ -421,13 +421,15 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
*/
|
*/
|
||||||
private function computeSingleEntityChangeSet($entity)
|
private function computeSingleEntityChangeSet($entity)
|
||||||
{
|
{
|
||||||
if ( $this->getEntityState($entity) !== self::STATE_MANAGED) {
|
$state = $this->getEntityState($entity);
|
||||||
throw new \InvalidArgumentException("Entity has to be managed for single computation " . self::objToStr($entity));
|
|
||||||
|
if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) {
|
||||||
|
throw new \InvalidArgumentException("Entity has to be managed or scheduled for removal for single computation " . self::objToStr($entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = $this->em->getClassMetadata(get_class($entity));
|
$class = $this->em->getClassMetadata(get_class($entity));
|
||||||
|
|
||||||
if ($class->isChangeTrackingDeferredImplicit()) {
|
if ($state === self::STATE_MANAGED && $class->isChangeTrackingDeferredImplicit()) {
|
||||||
$this->persist($entity);
|
$this->persist($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1118,7 +1118,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$user->username = 'domnikl';
|
$user->username = 'domnikl';
|
||||||
$user->status = 'developer';
|
$user->status = 'developer';
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException', 'Entity has to be managed for single computation');
|
$this->setExpectedException('InvalidArgumentException', 'Entity has to be managed or scheduled for removal for single computation');
|
||||||
$this->_em->flush($user);
|
$this->_em->flush($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1202,8 +1202,9 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
/**
|
/**
|
||||||
* @group DDC-720
|
* @group DDC-720
|
||||||
* @group DDC-1612
|
* @group DDC-1612
|
||||||
|
* @group DDC-2267
|
||||||
*/
|
*/
|
||||||
public function testFlushSingleNewEntity()
|
public function testFlushSingleNewEntityThenRemove()
|
||||||
{
|
{
|
||||||
$user = new CmsUser;
|
$user = new CmsUser;
|
||||||
$user->name = 'Dominik';
|
$user->name = 'Dominik';
|
||||||
@ -1212,6 +1213,14 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
|
|
||||||
$this->_em->persist($user);
|
$this->_em->persist($user);
|
||||||
$this->_em->flush($user);
|
$this->_em->flush($user);
|
||||||
|
|
||||||
|
$userId = $user->id;
|
||||||
|
|
||||||
|
$this->_em->remove($user);
|
||||||
|
$this->_em->flush($user);
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$this->assertNull($this->_em->find(get_class($user), $userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user