Exemple #1
0
 /** 
  * @param array $data
  * @return User
  */
 public function createFromArray(array $data)
 {
     $user = new User();
     $person = isset($data['person']) ? $data['person'] : new Person();
     $user->setPerson($person);
     isset($data['id']) ? $user->setId($data['id']) : null;
     isset($data['email']) ? $user->setEmail($data['email']) : null;
     isset($data['password']) ? $user->setPassword($data['password']) : null;
     isset($data['state']) ? $user->setState(new State($data['state'])) : null;
     isset($data['registrationDate']) ? $user->setRegistrationDate(new DateTime($data['registrationDate'])) : null;
     isset($data['lastLogin']) ? $user->setLastLogin(new DateTime($data['lastLogin'])) : null;
     return $user;
 }
 public function testUpdate()
 {
     $collection = new Users();
     $user = new User();
     $user->setId(1);
     $collection->append($user);
     $user = new User();
     $user->setId(2);
     $collection->append($user);
     $user = new User();
     $user->setId(3);
     $collection->append($user);
     $collection->first();
     $collection->next();
     $user = $collection->current();
     //id 2
     $user->setEmail('*****@*****.**');
     $collection->update($user);
     $this->assertEquals('*****@*****.**', $collection[1]->getEmail());
     $user = new User();
     $user->setId(4);
     $this->setExpectedException('LogicException');
     $collection->update($user);
 }
Exemple #3
0
 public function testGetSetId()
 {
     $this->user->setId(100);
     $this->assertEquals(100, $this->user->getId());
 }