#1169 DDC-3343 - additional test cases: removing proxies from an extra-lazy collection still updates the owning side values
This commit is contained in:
parent
6a2b7c2a8e
commit
d443d4f3b6
@ -109,7 +109,83 @@ class OneToManyExtraLazyTest extends OrmFunctionalTestCase
|
||||
/**
|
||||
* @group DDC-3343
|
||||
*/
|
||||
public function testEntityNotDeletedWhenRemovedFromExtraLazyAssociation()
|
||||
public function testRemovesManagedElementFromOneToManyExtraLazyCollection()
|
||||
{
|
||||
list($userId, $tweetId) = $this->loadTweetFixture();
|
||||
|
||||
/* @var $user User */
|
||||
$user = $this->_em->find(User::CLASSNAME, $userId);
|
||||
|
||||
$user->tweets->removeElement($this->_em->find(Tweet::CLASSNAME, $tweetId));
|
||||
|
||||
$this->_em->clear();
|
||||
|
||||
/* @var $user User */
|
||||
$user = $this->_em->find(User::CLASSNAME, $userId);
|
||||
|
||||
$this->assertCount(0, $user->tweets);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3343
|
||||
*/
|
||||
public function testRemovesManagedElementFromOneToManyExtraLazyCollectionWithoutDeletingTheTargetEntityEntry()
|
||||
{
|
||||
list($userId, $tweetId) = $this->loadTweetFixture();
|
||||
|
||||
/* @var $user User */
|
||||
$user = $this->_em->find(User::CLASSNAME, $userId);
|
||||
|
||||
$user->tweets->removeElement($this->_em->find(Tweet::CLASSNAME, $tweetId));
|
||||
|
||||
$this->_em->clear();
|
||||
|
||||
/* @var $tweet Tweet */
|
||||
$tweet = $this->_em->find(Tweet::CLASSNAME, $tweetId);
|
||||
$this->assertInstanceOf(
|
||||
Tweet::CLASSNAME,
|
||||
$tweet,
|
||||
'Even though the collection is extra lazy, the tweet should not have been deleted'
|
||||
);
|
||||
|
||||
$this->assertNull($tweet->author, 'Tweet author link has been removed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3343
|
||||
*/
|
||||
public function testRemovingManagedLazyProxyFromExtraLazyOneToManyDoesRemoveTheAssociationButNotTheEntity()
|
||||
{
|
||||
list($userId, $tweetId) = $this->loadTweetFixture();
|
||||
|
||||
/* @var $user User */
|
||||
$user = $this->_em->find(User::CLASSNAME, $userId);
|
||||
$tweet = $this->_em->getReference(Tweet::CLASSNAME, $tweetId);
|
||||
|
||||
$user->tweets->removeElement($this->_em->getReference(Tweet::CLASSNAME, $tweetId));
|
||||
|
||||
$this->_em->clear();
|
||||
|
||||
/* @var $tweet Tweet */
|
||||
$tweet = $this->_em->find(Tweet::CLASSNAME, $tweet->id);
|
||||
$this->assertInstanceOf(
|
||||
Tweet::CLASSNAME,
|
||||
$tweet,
|
||||
'Even though the collection is extra lazy, the tweet should not have been deleted'
|
||||
);
|
||||
|
||||
$this->assertNull($tweet->author);
|
||||
|
||||
/* @var $user User */
|
||||
$user = $this->_em->find(User::CLASSNAME, $userId);
|
||||
|
||||
$this->assertCount(0, $user->tweets);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[] ordered tuple: user id and tweet id
|
||||
*/
|
||||
private function loadTweetFixture()
|
||||
{
|
||||
$user = new User();
|
||||
$tweet = new Tweet();
|
||||
@ -124,24 +200,6 @@ class OneToManyExtraLazyTest extends OrmFunctionalTestCase
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
/* @var $user User */
|
||||
$user = $this->_em->find(User::CLASSNAME, $user->id);
|
||||
$tweet = $this->_em->find(Tweet::CLASSNAME, $tweet->id);
|
||||
|
||||
$user->tweets->removeElement($tweet);
|
||||
|
||||
$this->assertCount(0, $user->tweets);
|
||||
|
||||
$this->_em->clear();
|
||||
|
||||
/* @var $tweet Tweet */
|
||||
$tweet = $this->_em->find(Tweet::CLASSNAME, $tweet->id);
|
||||
$this->assertInstanceOf(
|
||||
Tweet::CLASSNAME,
|
||||
$tweet,
|
||||
'Even though the collection is extra lazy, the tweet should not have been deleted'
|
||||
);
|
||||
|
||||
$this->assertNull($tweet->author);
|
||||
return array($user->id, $tweet->id);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user