Example #1
0
 public function testUpdate()
 {
     $id = DM\Users::toId($this->testName);
     $params = array('id' => $id, 'first_name' => '123', 'last_name' => '231', 'sex' => 'f', 'email' => 'f', 'password' => 'a', 'photo' => '/tmp/q.jpg', 'language_id' => 2, 'recover_hash' => '---', 'enabled' => 0, 'cid' => 1);
     DM\Users::update($params);
     $data = DM\Users::read($id);
     $params['password'] = md5('aero' . $params['password']);
     $this->assertArraySubset($params, $data);
     //updateByName
     unset($params['id']);
     $params['name'] = $this->testName;
     $params['password'] = '******';
     $params['enabled'] = 1;
     DM\Users::updateByName($params);
     $data = DM\Users::read($id);
     $params['password'] = md5('aero' . $params['password']);
     $this->assertArraySubset($params, $data);
     //verify password
     $this->assertTrue(DM\Users::verifyPassword($id, 'b'), 'Wrong password');
     //check id by mail
     $id = DM\Users::getIdByEmail('f');
     $this->assertTrue(is_numeric($id), 'Cant get Id by mail');
     //check id by recover hash
     $id = DM\Users::getIdByRecoveryHash('---');
     $this->assertTrue(is_numeric($id), 'Cant get Id by recover hash');
     //check owner
     $this->assertTrue(DM\Users::getOwnerId($id) == 1, 'different owner set');
 }
Example #2
0
 /**
  * Check if current loged user is owner for given user id
  *
  * @param  int     $userId
  * @return boolean
  */
 public static function isUsersOwner($userId)
 {
     return User::getId() == DM\Users::getOwnerId($userId);
 }