X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=vendor%2Fdoctrine%2Form%2Ftests%2FDoctrine%2FTests%2FORM%2FFunctional%2FOneToManyOrphanRemovalTest.php;fp=vendor%2Fdoctrine%2Form%2Ftests%2FDoctrine%2FTests%2FORM%2FFunctional%2FOneToManyOrphanRemovalTest.php;h=28101ccc7cd92d2a924664bb2ed677b216803843;hb=8b04b2d11798dee4f3e1358e4f43e97a6df851f6;hp=0000000000000000000000000000000000000000;hpb=73568cf05a785a45f94ca3f2351d9e07bf917958;p=zf2.biz%2Fapplication_blanche.git diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php new file mode 100644 index 0000000..28101cc --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php @@ -0,0 +1,75 @@ +useModelSet('cms'); + + parent::setUp(); + + $user = new CmsUser; + $user->status = 'dev'; + $user->username = 'romanb'; + $user->name = 'Roman B.'; + + $phone = new CmsPhonenumber; + $phone->phonenumber = '123456'; + + $user->addPhonenumber($phone); + + $this->_em->persist($user); + $this->_em->flush(); + + $this->userId = $user->getId(); + $this->_em->clear(); + } + + public function testOrphanRemoval() + { + $userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + + $this->_em->remove($userProxy); + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); + $result = $query->getResult(); + + $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); + + $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); + $result = $query->getResult(); + + $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + } + + /** + * @group DDC-1496 + */ + public function testOrphanRemovalUnitializedCollection() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + + $user->phonenumbers->clear(); + $this->_em->flush(); + + $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); + $result = $query->getResult(); + + $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + } +} \ No newline at end of file