1
0
mirror of synced 2025-02-13 10:49:25 +03:00

Merge pull request #6550 from alcaeus/fix-persistent-collection-return

Fix return value of removeElement for extra lazy collections
This commit is contained in:
Marco Pivetta 2017-07-22 09:26:15 +02:00 committed by GitHub
commit 668ad4cc29
2 changed files with 4 additions and 6 deletions

View File

@ -373,11 +373,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec
$persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association); $persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association);
if ($persister->removeElement($this, $element)) { return $persister->removeElement($this, $element);
return $element;
}
return null;
} }
$removed = parent::removeElement($element); $removed = parent::removeElement($element);

View File

@ -640,11 +640,13 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
$group = $this->_em->find(CmsGroup::class, $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$user->groups->removeElement($group); $this->assertTrue($user->groups->removeElement($group));
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a persisted entity should cause one query to be executed."); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a persisted entity should cause one query to be executed.");
$this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized.");
$this->assertFalse($user->groups->removeElement($group), "Removing an already removed element returns false");
// Test Many to Many removal with Entity state as new // Test Many to Many removal with Entity state as new
$group = new CmsGroup(); $group = new CmsGroup();
$group->name = "A New group!"; $group->name = "A New group!";