#1169 DDC-3343 - moved tests to correct test class
This commit is contained in:
parent
d443d4f3b6
commit
b7b716a6bb
@ -5,13 +5,16 @@ namespace Doctrine\Tests\ORM\Functional;
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||
use Doctrine\Tests\Models\DDC2504\DDC2504ChildClass;
|
||||
use Doctrine\Tests\Models\DDC2504\DDC2504OtherClass;
|
||||
use Doctrine\Tests\Models\Tweet\Tweet;
|
||||
use Doctrine\Tests\Models\Tweet\User;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* Description of ExtraLazyCollectionTest
|
||||
*
|
||||
* @author beberlei
|
||||
*/
|
||||
class ExtraLazyCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
class ExtraLazyCollectionTest extends OrmFunctionalTestCase
|
||||
{
|
||||
private $userId;
|
||||
private $userId2;
|
||||
@ -27,6 +30,7 @@ class ExtraLazyCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->useModelSet('tweet');
|
||||
$this->useModelSet('cms');
|
||||
$this->useModelSet('ddc2504');
|
||||
parent::setUp();
|
||||
@ -1027,4 +1031,101 @@ class ExtraLazyCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->phonenumber = $phonenumber1->phonenumber;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3343
|
||||
*/
|
||||
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();
|
||||
|
||||
$user->name = 'ocramius';
|
||||
$tweet->content = 'The cat is on the table';
|
||||
|
||||
$user->addTweet($tweet);
|
||||
|
||||
$this->_em->persist($user);
|
||||
$this->_em->persist($tweet);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
return array($user->id, $tweet->id);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ class OneToManyExtraLazyTest extends OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->useModelSet('tweet');
|
||||
$this->useModelSet('vct_onetomany_extralazy');
|
||||
|
||||
parent::setUp();
|
||||
@ -105,101 +104,4 @@ class OneToManyExtraLazyTest extends OrmFunctionalTestCase
|
||||
|
||||
$this->assertCount(2, $inversed->associatedEntities->slice(0, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3343
|
||||
*/
|
||||
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();
|
||||
|
||||
$user->name = 'ocramius';
|
||||
$tweet->content = 'The cat is on the table';
|
||||
|
||||
$user->addTweet($tweet);
|
||||
|
||||
$this->_em->persist($user);
|
||||
$this->_em->persist($tweet);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
return array($user->id, $tweet->id);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user