예제 #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;
 }
예제 #2
0
 public function testGetSetLastLoginDate()
 {
     $this->user->setLastLogin(new DateTime('2015-01-12'));
     $this->assertInstanceOf('DateTime', $this->user->getLastLoginDate());
     $this->assertEquals('2015-01-12', $this->user->getLastLoginDate()->format('Y-m-d'));
 }