Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 public function testGetSetRegistrationDate()
 {
     $this->user->setRegistrationDate(new DateTime('1970-01-01'));
     $this->assertInstanceOf('DateTime', $this->user->getRegistrationDate());
     $this->assertEquals('1970-01-01', $this->user->getRegistrationDate()->format('Y-m-d'));
 }