@@ 43-60 (lines=18) @@ | ||
40 | $this->_em->clear(); |
|
41 | } |
|
42 | ||
43 | public function testOrphanRemoval() |
|
44 | { |
|
45 | $userProxy = $this->_em->getReference(CmsUser::class, $this->userId); |
|
46 | ||
47 | $this->_em->remove($userProxy); |
|
48 | $this->_em->flush(); |
|
49 | $this->_em->clear(); |
|
50 | ||
51 | $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); |
|
52 | $result = $query->getResult(); |
|
53 | ||
54 | $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); |
|
55 | ||
56 | $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); |
|
57 | $result = $query->getResult(); |
|
58 | ||
59 | $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * @group DDC-3382 |
@@ 55-76 (lines=22) @@ | ||
52 | $this->_em->clear(); |
|
53 | } |
|
54 | ||
55 | public function testOrphanRemovalIsPurelyOrnemental() |
|
56 | { |
|
57 | $person = $this->_em->getReference(Person::class, $this->personId); |
|
58 | ||
59 | $this->_em->remove($person); |
|
60 | $this->_em->flush(); |
|
61 | $this->_em->clear(); |
|
62 | ||
63 | $query = $this->_em->createQuery( |
|
64 | 'SELECT u FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\Person u' |
|
65 | ); |
|
66 | $result = $query->getResult(); |
|
67 | ||
68 | $this->assertEquals(0, count($result), 'Person should be removed by EntityManager'); |
|
69 | ||
70 | $query = $this->_em->createQuery( |
|
71 | 'SELECT p FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\PhoneNumber p' |
|
72 | ); |
|
73 | $result = $query->getResult(); |
|
74 | ||
75 | $this->assertEquals(2, count($result), 'Orphan removal should not kick in'); |
|
76 | } |
|
77 | ||
78 | protected function _getEntityManager( |
|
79 | Connection $connection = null, |