PHP User::updateScope Examples

PHP User::updateScope - 2 examples found. These are the top rated real world PHP examples of User::updateScope extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 /**
  * @covers User::updateScope
  */
 public function testUpdateScopeOnUnknownUser()
 {
     $scope = 'admin user';
     $this->object->id = null;
     $this->assertFalse($this->object->updateScope($scope), 'Scope was updated on unknown user');
 }
Example #2
0
            //indicate the requester do not have the required scope for creating another user
            return;
        }
        $user = new User();
        //adapt and validate object received
        $requestedUser = $api->query['body'];
        if ($requestedUser !== null) {
            $requestedUser->status = 1;
        }
        if (!$user->validateModel($requestedUser, $errorMessage)) {
            $api->output(400, 'User is not valid: ' . $errorMessage);
            //provided user is not valid
            return;
        }
        //create user
        if (!$user->create($requestedUser, $errorMessage)) {
            $api->output(500, 'Error during creation: ' . $errorMessage);
            //something gone wrong :(
            return;
        }
        //add scope
        if (property_exists($requestedUser, 'scope')) {
            if (!$user->updateScope($requestedUser->scope)) {
                $api->output(500, 'User is created but not his scope');
                //something gone wrong :(
                return;
            }
        }
        $api->output(201, $user->getProfile());
        break;
}