-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert CRLF to LF in test file (#8276)
* Convert CRLF to LF in test file * fix cs
- Loading branch information
Showing
1 changed file
with
65 additions
and
61 deletions.
There are no files selected for viewing
126 changes: 65 additions & 61 deletions
126
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 |
---|---|---|
@@ -1,61 +1,65 @@ | ||
<?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 setUp() | ||
{ | ||
$this->useModelSet('ecommerce'); | ||
parent::setUp(); | ||
} | ||
|
||
public function testShouldNotScheduleDeletionOnClonedInstances() | ||
{ | ||
$class = $this->_em->getClassMetadata(ECommerceProduct::class); | ||
$product = new ECommerceProduct(); | ||
$category = new ECommerceCategory(); | ||
$collection = new PersistentCollection($this->_em, $class, new ArrayCollection([$category])); | ||
$collection->setOwner($product, $class->associationMappings['categories']); | ||
|
||
$uow = $this->_em->getUnitOfWork(); | ||
$clonedCollection = clone $collection; | ||
$clonedCollection->clear(); | ||
|
||
$this->assertEquals(0, count($uow->getScheduledCollectionDeletions())); | ||
} | ||
|
||
public function testSavingClonedPersistentCollection() | ||
{ | ||
$product = new ECommerceProduct(); | ||
$category = new ECommerceCategory(); | ||
$category->setName('foo'); | ||
$product->addCategory($category); | ||
|
||
$this->_em->persist($product); | ||
$this->_em->persist($category); | ||
$this->_em->flush(); | ||
|
||
$newProduct = clone $product; | ||
|
||
$this->_em->persist($newProduct); | ||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
|
||
$product1 = $this->_em->find(ECommerceProduct::class, $product->getId()); | ||
$product2 = $this->_em->find(ECommerceProduct::class, $newProduct->getId()); | ||
|
||
$this->assertCount(1, $product1->getCategories()); | ||
$this->assertCount(1, $product2->getCategories()); | ||
|
||
$this->assertSame($product1->getCategories()->get(0), $product2->getCategories()->get(0)); | ||
} | ||
} | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
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; | ||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
use function count; | ||
|
||
/** | ||
* @group DDC-2074 | ||
*/ | ||
class DDC2074Test extends OrmFunctionalTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->useModelSet('ecommerce'); | ||
parent::setUp(); | ||
} | ||
|
||
public function testShouldNotScheduleDeletionOnClonedInstances() | ||
{ | ||
$class = $this->_em->getClassMetadata(ECommerceProduct::class); | ||
$product = new ECommerceProduct(); | ||
$category = new ECommerceCategory(); | ||
$collection = new PersistentCollection($this->_em, $class, new ArrayCollection([$category])); | ||
$collection->setOwner($product, $class->associationMappings['categories']); | ||
|
||
$uow = $this->_em->getUnitOfWork(); | ||
$clonedCollection = clone $collection; | ||
$clonedCollection->clear(); | ||
|
||
$this->assertEquals(0, count($uow->getScheduledCollectionDeletions())); | ||
} | ||
|
||
public function testSavingClonedPersistentCollection() | ||
{ | ||
$product = new ECommerceProduct(); | ||
$category = new ECommerceCategory(); | ||
$category->setName('foo'); | ||
$product->addCategory($category); | ||
|
||
$this->_em->persist($product); | ||
$this->_em->persist($category); | ||
$this->_em->flush(); | ||
|
||
$newProduct = clone $product; | ||
|
||
$this->_em->persist($newProduct); | ||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
|
||
$product1 = $this->_em->find(ECommerceProduct::class, $product->getId()); | ||
$product2 = $this->_em->find(ECommerceProduct::class, $newProduct->getId()); | ||
|
||
$this->assertCount(1, $product1->getCategories()); | ||
$this->assertCount(1, $product2->getCategories()); | ||
|
||
$this->assertSame($product1->getCategories()->get(0), $product2->getCategories()->get(0)); | ||
} | ||
} |