3 namespace Doctrine\Tests\ORM\Functional\Ticket;
8 class DDC1654Test extends \Doctrine\Tests\OrmFunctionalTestCase
10 public function setUp()
13 $this->setUpEntitySchema(array(
14 __NAMESPACE__ . '\\DDC1654Post',
15 __NAMESPACE__ . '\\DDC1654Comment',
19 public function testManyToManyRemoveFromCollectionOrphanRemoval()
21 $post = new DDC1654Post();
22 $post->comments[] = new DDC1654Comment();
23 $post->comments[] = new DDC1654Comment();
25 $this->_em->persist($post);
28 $post->comments->remove(0);
29 $post->comments->remove(1);
34 $comments = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1654Comment')->findAll();
35 $this->assertEquals(0, count($comments));
38 public function testManyToManyRemoveElementFromCollectionOrphanRemoval()
40 $post = new DDC1654Post();
41 $post->comments[] = new DDC1654Comment();
42 $post->comments[] = new DDC1654Comment();
44 $this->_em->persist($post);
47 $post->comments->removeElement($post->comments[0]);
48 $post->comments->removeElement($post->comments[1]);
53 $comments = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1654Comment')->findAll();
54 $this->assertEquals(0, count($comments));
57 public function testManyToManyClearCollectionOrphanRemoval()
59 $post = new DDC1654Post();
60 $post->comments[] = new DDC1654Comment();
61 $post->comments[] = new DDC1654Comment();
63 $this->_em->persist($post);
66 $post->comments->clear();
71 $comments = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1654Comment')->findAll();
72 $this->assertEquals(0, count($comments));
83 * @Id @Column(type="integer") @GeneratedValue
88 * @ManyToMany(targetEntity="DDC1654Comment", orphanRemoval=true,
89 * cascade={"persist"})
91 public $comments = array();
100 * @Id @Column(type="integer") @GeneratedValue