/** * Tests the deserialize method */ public function testDeserialize() { $username = "******"; $password = "******"; $hashedPassword = md5($password); $input = array("username" => $username, "password" => $password); $user = new User(); $user->deserialize($input); $this->assertEquals($username, $user->getUsername()); $this->assertEquals($hashedPassword, $user->getHashedPassword()); }
/** * Creates a new user. * * @see PartKeepr\Service.RestfulService::create() */ public function create() { if (!SessionManager::getCurrentSession()->getUser()->isAdmin()) { throw new \Exception("Permission denied"); } $this->requireParameter("username"); $user = new User(); $user->deserialize($this->getParameters()); UserManager::getInstance()->createUser($user); return array("data" => $user->serialize()); }