1
0
mirror of synced 2024-12-14 15:16:04 +03:00

Merge pull request #523 from jankramer/DDC-2074

[DDC-2074] Bugfix regarding clearing cloned PersistentCollections
This commit is contained in:
Benjamin Eberlei 2012-11-25 11:13:28 -08:00
commit 46e6753649
2 changed files with 30 additions and 1 deletions

View File

@ -655,7 +655,7 @@ final class PersistentCollection implements Collection, Selectable
$this->initialized = true; // direct call, {@link initialize()} is too expensive $this->initialized = true; // direct call, {@link initialize()} is too expensive
if ($this->association['isOwningSide']) { if ($this->association['isOwningSide'] && $this->owner) {
$this->changed(); $this->changed();
$uow->scheduleCollectionDeletion($this); $uow->scheduleCollectionDeletion($this);

View File

@ -0,0 +1,29 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Tests\Models\ECommerce\ECommerceCategory;
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
/**
* @group DDC-2074
*/
class DDC2074Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function testShouldNotScheduleDeletionOnClonedInstances()
{
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct');
$product = new ECommerceProduct();
$category = new ECommerceCategory();
$collection = new PersistentCollection($this->_em, $class, new ArrayCollection(array($category)));
$collection->setOwner($product, $class->associationMappings['categories']);
$uow = $this->_em->getUnitOfWork();
$clonedCollection = clone $collection;
$clonedCollection->clear();
$this->assertEquals(0, count($uow->getScheduledCollectionDeletions()));
}
}