예제 #1
0
 /**
  * Sets the value of zip.
  *
  * @param string $zip the zip
  */
 public function setZip($zip)
 {
     if ($this->zip !== $zip) {
         $this->profile->addressChanged('zip', $this->zip, $zip);
         $this->zip = $zip;
     }
 }
예제 #2
0
 /**
  * @see PersistableInterface
  *
  * @return array
  */
 public function preparePersistChangeSet()
 {
     $changeSet = array('username' => $this->username, 'password' => $this->password);
     if ($this->profile !== null) {
         $changeSet['profileId'] = $this->profile->getId();
     }
     if ($this->groups) {
         $groupIds = $this->groups->map(function (Group $group) {
             return $group->getId();
         })->toArray();
         $changeSet['groupIds'] = implode(',', $groupIds);
     }
     if ($this->id !== null) {
         $changeSet['_id'] = (int) $this->id;
     }
     return $changeSet;
 }
 public function testEmbeddedAddress()
 {
     $user = $this->objectManager->find($this->userClassName, 1);
     $profile = new Profile();
     $address = new Address($profile);
     $address->setAddress1('273 Lake Terrace Dr.');
     $address->setCity('Hendersonville');
     $address->setState('TN');
     $address->setZip('37075');
     $profile->setAddress($address);
     $profile->setName('Jonathan H. Wage');
     $user->setProfile($profile);
     $this->objectManager->persist($profile);
     $this->objectManager->flush();
     $this->objectManager->clear();
     $user = $this->objectManager->find($this->userClassName, 1);
     $this->assertNotNull($user->getProfile()->getAddress());
     $this->assertEquals($address, $user->getProfile()->getAddress());
     $user->getProfile()->getAddress()->setState('Tennessee');
     $this->objectManager->flush();
     $this->objectManager->clear();
     $user = $this->objectManager->find($this->userClassName, 1);
     $this->assertEquals('Tennessee', $user->getProfile()->getAddress()->getState());
 }
 public function testSelectProfileData()
 {
     $user = $this->objectManager->find($this->userClassName, 1);
     $profile = new Profile();
     $profile->setName('Jonathan H. Wage');
     $user->setProfile($profile);
     $this->objectManager->persist($profile);
     $this->objectManager->flush();
     $this->objectManager->clear();
     $userRepository = $this->objectManager->getRepository($this->userClassName);
     $user = $userRepository->findUserWithProfileData(1);
     $this->assertEquals('Jonathan H. Wage', $user->getProfile()->getName());
     $profile = $this->objectManager->find($this->profileClassName, 1);
     $this->assertSame($profile, $user->getProfile());
 }