1
0
mirror of synced 2025-02-01 04:51:45 +03:00

59 lines
1.4 KiB
PHP
Raw Normal View History

2014-10-24 23:10:37 +02:00
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Tests\Models\Tweet\Tweet;
use Doctrine\Tests\Models\Tweet\User;
2014-10-24 23:10:37 +02:00
/**
* @group DDC-3343
*/
class DDC3343Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
/**
* {@inheritDoc}
*/
protected function setUp()
{
$this->useModelSet('tweet');
parent::setUp();
}
2014-10-24 23:10:37 +02:00
public function testEntityNotDeletedWhenRemovedFromExtraLazyAssociation()
{
$user = new User();
$tweet = new Tweet();
2014-10-24 23:10:37 +02:00
$user->name = 'ocramius';
$tweet->content = 'The cat is on the table';
2014-10-24 23:10:37 +02:00
$user->addTweet($tweet);
2014-10-24 23:10:37 +02:00
$this->_em->persist($user);
$this->_em->persist($tweet);
2014-10-24 23:10:37 +02:00
$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);
2014-10-24 23:10:37 +02:00
$user->tweets->removeElement($tweet);
2014-10-24 23:10:37 +02:00
$this->assertCount(0, $user->tweets);
$this->_em->clear();
2014-10-24 23:10:37 +02:00
/* @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'
);
2014-10-24 23:10:37 +02:00
$this->assertNull($tweet->author);
2014-10-24 23:10:37 +02:00
}
}