public function testGivenOrphanRemovalOneToOne_WhenReplacing_ThenNoUniqueConstraintError() { $user = new CmsUser(); $user->name = "Benjamin"; $user->username = "******"; $user->status = "something"; $user->setEmail($email = new CmsEmail()); $email->setEmail("*****@*****.**"); $this->_em->persist($user); $this->_em->flush(); $this->assertTrue($this->_em->contains($email)); $user->setEmail($newEmail = new CmsEmail()); $newEmail->setEmail("*****@*****.**"); $this->_em->flush(); $this->assertFalse($this->_em->contains($email)); }
public function setEmail(CmsEmail $email = null) { if ($this->email !== $email) { $this->email = $email; if ($email) { $email->setUser($this); } } }
private function loadFixture() { $user = new CmsUser(); $user->name = 'Roman'; $user->username = '******'; $user->status = 'developer'; $address = new CmsAddress(); $address->country = 'Germany'; $address->city = 'Berlin'; $address->zip = '12345'; $user->setAddress($address); $email = new CmsEmail(); $email->setEmail('*****@*****.**'); $user->setEmail($email); $ph1 = new CmsPhonenumber(); $ph1->phonenumber = "0301234"; $ph2 = new CmsPhonenumber(); $ph2->phonenumber = "987654321"; $user->addPhonenumber($ph1); $user->addPhonenumber($ph2); $this->_em->persist($user); $this->_em->flush(); $this->userId = $user->getId(); $this->_em->clear(); }