-
-
Save doctrinebot/24c53dc10454cb82b1ec to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-1630 - https://github.com/doctrine/doctrine2/issues/2272
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
<?php | |
namespace Doctrine\Tests\ORM\Functional\Ticket; | |
use Doctrine\Tests\Models\CMS\CmsUser; | |
use Doctrine\Tests\Models\CMS\CmsGroup; | |
/** | |
* @group DDC-1630 | |
*/ | |
class DDC1630Test extends \Doctrine\Tests\OrmFunctionalTestCase | |
{ | |
public function setUp() | |
{ | |
$this->useModelSet('cms'); | |
parent::setUp(); | |
} | |
public function testIssueGetDeleteDiff() | |
{ | |
$group = new CmsGroup(); | |
$group->name = "test"; | |
$this->_em->persist($group); | |
$this->_em->flush(); | |
$user = new CmsUser(); | |
$user->username = "beberlei"; | |
$user->name = "Benjamin"; | |
$user->status = "active"; | |
$user->groups[] = $group; | |
$this->_em->persist($user); | |
$this->_em->flush(); | |
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->groups); | |
$user = $this->_em->find(get_class($user), $user->id); | |
$user->groups->removeElement($group); | |
$this->assertEquals(1, count($user->groups->getDeleteDiff())); | |
$this->assertEquals(1, count($user->groups->getSnapshot())); | |
$group = new CmsGroup(); | |
$group->name = "test"; | |
$user->groups[] = $group; | |
$this->_em->persist($group); | |
$this->_em->flush(); | |
$user = $this->_em->find(get_class($user), $user->id); | |
$this->assertEquals(1, count($user->groups), "We removed and added one, so the result should be one (not two!)"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment