Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DDC-2074] Added test for PersistentCollection#clear.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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())); | ||
} | ||
} |