예제 #1
0
 /**
  * Converts an array to a user object.
  *
  * @param $array the array
  * @return User the user
  */
 private function arrayToUser(array $array)
 {
     $user = new User($array['id']);
     $user->setUsername($array['username']);
     $user->setFullName($array['fullName']);
     $user->setEmail($array['email']);
     $user->setBirthdate($array['birthdate']);
     $user->setGender($array['gender']);
     $user->setTimezoneOffset($array['timezoneOffset']);
     $user->setLocale($array['locale']);
     $user->setLastLogin($array['lastLogin']);
     $user->setSecret($array['secret']);
     return $user;
 }
예제 #2
0
 /**
  * Fetches a user by a unique property (ID, e-mail address, username).
  *
  * @param string $property the name of the property
  * @param mixed $value the value
  * @return User null user object or <code>null</code>
  */
 private function fetchByProperty($property, $value)
 {
     if (!$this->db->tableExists($this->table)) {
         return null;
     }
     $query = "SELECT * FROM :::table WHERE ::field=:value";
     $bindings = array(':::table' => $this->table, '::field' => $property, ':value' => $value);
     $result = $this->db->fetch($query, $bindings);
     if (count($result) !== 1) {
         return null;
     }
     $user = new User($result[0]['id']);
     $user->setUsername($result[0]['username']);
     $user->setFullName($result[0]['fullName']);
     $user->setEmail($result[0]['email']);
     $user->setBirthdate($result[0]['birthdate']);
     $user->setGender($result[0]['gender']);
     $user->setTimezoneOffset($result[0]['timezoneOffset']);
     $user->setLocale($result[0]['locale']);
     $user->setLastLogin($result[0]['lastLogin']);
     $user->setSecret($result[0]['secret']);
     return $user;
 }
예제 #3
0
 /**
  * Tests removing the storage.
  *
  * @covers empire\framework\user\storage\DbUserStorage::remove
  */
 public function testRemove()
 {
     $haenschen = new User(12);
     $haenschen->setUsername('root');
     $haenschen->setFullName('Hänschen Oberschmitt');
     $haenschen->setEmail('*****@*****.**');
     $haenschen->setGender('transfemale');
     $haenschen->setBirthdate('1910-12-05');
     $haenschen->setTimezoneOffset(-4);
     $haenschen->setLocale('de-DE');
     $haenschen->setLastLogin(1394456400);
     $haenschen->setSecret('my hidden secret');
     $this->instance->store($haenschen);
     $this->instance->remove();
     $this->assertNull($this->instance->fetch(12));
 }