1
0
mirror of synced 2025-03-21 15:33:51 +03:00

#1245 DDC-2504 - extracting test:

Removing an unmanaged/persisted/new item from a one-to-many extra-lazy association to a JTI does not initialize the collection
This commit is contained in:
Marco Pivetta 2015-01-12 21:55:57 +01:00
parent 25d40caf1e
commit ebf5811761

View File

@ -532,6 +532,67 @@ class ExtraLazyCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertFalse($otherClass->childClasses->contains($childClass));
}
/**
* @group DDC-2504
*/
public function testRemovalOfNonManagedElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt()
{
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId);
$queryCount = $this->getCurrentQueryCount();
$otherClass->childClasses->removeElement(new DDC2504ChildClass());
$this->assertEquals(
$queryCount,
$this->getCurrentQueryCount(),
'Removing an unmanaged entity should cause no query to be executed.'
);
}
/**
* @group DDC-2504
*/
public function testRemovalOfNewElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt()
{
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId);
$childClass = new DDC2504ChildClass();
$this->_em->persist($childClass);
$queryCount = $this->getCurrentQueryCount();
$otherClass->childClasses->removeElement($childClass);
$this->assertEquals(
$queryCount,
$this->getCurrentQueryCount(),
'Removing a new entity should cause no query to be executed.'
);
}
/**
* @group DDC-2504
*/
public function testRemovalOfNewManagedElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt()
{
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId);
$childClass = new DDC2504ChildClass();
$this->_em->persist($childClass);
$this->_em->flush();
$queryCount = $this->getCurrentQueryCount();
$otherClass->childClasses->removeElement($childClass);
$this->assertEquals(
$queryCount + 2,
$this->getCurrentQueryCount(),
'Removing a persisted entity should cause two queries to be executed.'
);
$this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.');
}
/**
* @group DDC-2504
*/