コード例 #1
0
 private function populateUserWithSubmitedDatas()
 {
     $this->newUser = new User();
     if (isset($this->submitDatas['enabled'])) {
         $this->newUser->setEnabled($this->submitDatas['enabled']);
     }
     $this->newUser->setNickname($this->submitDatas['first_name']);
     $this->newUser->setName($this->submitDatas['last_name']);
     $this->newUser->setEmail($this->submitDatas['email']);
     //
     $this->newUser->addRole($this->submitDatas['connexion']['role']);
     $this->newUser->setUsername($this->submitDatas['connexion']['username']);
     $this->newUser->setPlainPassword($this->submitDatas['connexion']['password']);
     if (isset($this->submitDatas['location'])) {
         $this->newUser->setAddress($this->submitDatas['location']['address']);
         $this->newUser->setZipCode($this->submitDatas['location']['cp']);
         $this->newUser->setCity($this->submitDatas['location']['city']);
         if (isset($this->submitDatas['location']['country'])) {
             $this->newUser->setCountry($this->submitDatas['location']['country']);
         }
     }
     if (isset($this->submitDatas['birthday'])) {
         $this->newUser->setBirthday($this->submitDatas['birthday']);
     }
     if (isset($this->submitDatas['global_optin'])) {
         $this->newUser->setGlobalOptIn($this->submitDatas['global_optin']);
     }
     if (isset($this->submitDatas['site_optin'])) {
         $this->newUser->setSiteOptIn($this->submitDatas['site_optin']);
     }
 }
コード例 #2
0
ファイル: UserTest.php プロジェクト: pigroupe/SfynxAuthBundle
 /**
  * @dataProvider getInvalidData
  */
 public function testRegistrationValidator($data, $field)
 {
     $user = new User();
     $user->fromArray($data);
     $user->setPlainPassword($data['PlainPassword']);
     $errors = $this->getValidator()->validate($user, array('registration'));
     $this->assertCount(1, $errors, (string) $errors);
     $this->assertRegExp('/' . $field . '/', (string) $errors);
 }