namespace OCA\Provisioning_API;
-use \OC_OCS_Result;
use \OC_Helper;
use OCP\Files\NotFoundException;
use OCP\IConfig;
/**
* returns a list of users
*
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function getUsers() {
$search = !empty($_GET['search']) ? $_GET['search'] : '';
// Check if user is logged in
$user = $this->userSession->getUser();
if ($user === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
// Admin? Or SubAdmin?
$users = array_slice($users, $offset, $limit);
} else {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
$users = array_keys($users);
- return new OC_OCS_Result([
+ return new \OC\OCS\Result([
'users' => $users
]);
}
/**
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function addUser() {
$userId = isset($_POST['userid']) ? $_POST['userid'] : null;
$subAdminManager = $this->groupManager->getSubAdmin();
if (!$isAdmin && !$subAdminManager->isSubAdmin($user)) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
if($this->userManager->userExists($userId)) {
$this->logger->error('Failed addUser attempt: User already exists.', ['app' => 'ocs_api']);
- return new OC_OCS_Result(null, 102, 'User already exists');
+ return new \OC\OCS\Result(null, 102, 'User already exists');
}
if(is_array($groups)) {
foreach ($groups as $group) {
if(!$this->groupManager->groupExists($group)){
- return new OC_OCS_Result(null, 104, 'group '.$group.' does not exist');
+ return new \OC\OCS\Result(null, 104, 'group '.$group.' does not exist');
}
if(!$isAdmin && !$subAdminManager->isSubAdminofGroup($user, $this->groupManager->get($group))) {
- return new OC_OCS_Result(null, 105, 'insufficient privileges for group '. $group);
+ return new \OC\OCS\Result(null, 105, 'insufficient privileges for group '. $group);
}
}
} else {
if(!$isAdmin) {
- return new OC_OCS_Result(null, 106, 'no group specified (required for subadmins)');
+ return new \OC\OCS\Result(null, 106, 'no group specified (required for subadmins)');
}
}
$this->logger->info('Added userid '.$userId.' to group '.$group, ['app' => 'ocs_api']);
}
}
- return new OC_OCS_Result(null, 100);
+ return new \OC\OCS\Result(null, 100);
} catch (\Exception $e) {
$this->logger->error('Failed addUser attempt with exception: '.$e->getMessage(), ['app' => 'ocs_api']);
- return new OC_OCS_Result(null, 101, 'Bad request');
+ return new \OC\OCS\Result(null, 101, 'Bad request');
}
}
* gets user info
*
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function getUser($parameters) {
$userId = $parameters['userid'];
// Check if user is logged in
$currentLoggedInUser = $this->userSession->getUser();
if ($currentLoggedInUser === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
$data = [];
// Check if the target user exists
$targetUserObject = $this->userManager->get($userId);
if($targetUserObject === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested user could not be found');
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested user could not be found');
}
// Admin? Or SubAdmin?
} else {
// Check they are looking up themselves
if($currentLoggedInUser->getUID() !== $userId) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
}
$data['email'] = $targetUserObject->getEMailAddress();
$data['displayname'] = $targetUserObject->getDisplayName();
- return new OC_OCS_Result($data);
+ return new \OC\OCS\Result($data);
}
/**
* edit users
*
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function editUser($parameters) {
/** @var string $targetUserId */
// Check if user is logged in
$currentLoggedInUser = $this->userSession->getUser();
if ($currentLoggedInUser === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
$targetUser = $this->userManager->get($targetUserId);
if($targetUser === null) {
- return new OC_OCS_Result(null, 997);
+ return new \OC\OCS\Result(null, 997);
}
+ $permittedFields = [];
if($targetUserId === $currentLoggedInUser->getUID()) {
// Editing self (display, email)
$permittedFields[] = 'display';
$permittedFields[] = 'email';
} else {
// No rights
- return new OC_OCS_Result(null, 997);
+ return new \OC\OCS\Result(null, 997);
}
}
// Check if permitted to edit this field
if(!in_array($parameters['_put']['key'], $permittedFields)) {
- return new OC_OCS_Result(null, 997);
+ return new \OC\OCS\Result(null, 997);
}
// Process the edit
switch($parameters['_put']['key']) {
$quota = \OCP\Util::computerFileSize($quota);
}
if ($quota === false) {
- return new OC_OCS_Result(null, 103, "Invalid quota value {$parameters['_put']['value']}");
+ return new \OC\OCS\Result(null, 103, "Invalid quota value {$parameters['_put']['value']}");
}
if($quota === 0) {
$quota = 'default';
if(filter_var($parameters['_put']['value'], FILTER_VALIDATE_EMAIL)) {
$targetUser->setEMailAddress($parameters['_put']['value']);
} else {
- return new OC_OCS_Result(null, 102);
+ return new \OC\OCS\Result(null, 102);
}
break;
default:
- return new OC_OCS_Result(null, 103);
- break;
+ return new \OC\OCS\Result(null, 103);
}
- return new OC_OCS_Result(null, 100);
+ return new \OC\OCS\Result(null, 100);
}
/**
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function deleteUser($parameters) {
// Check if user is logged in
$currentLoggedInUser = $this->userSession->getUser();
if ($currentLoggedInUser === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
$targetUser = $this->userManager->get($parameters['userid']);
if($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) {
- return new OC_OCS_Result(null, 101);
+ return new \OC\OCS\Result(null, 101);
}
// If not permitted
$subAdminManager = $this->groupManager->getSubAdmin();
if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
- return new OC_OCS_Result(null, 997);
+ return new \OC\OCS\Result(null, 997);
}
// Go ahead with the delete
if($targetUser->delete()) {
- return new OC_OCS_Result(null, 100);
+ return new \OC\OCS\Result(null, 100);
} else {
- return new OC_OCS_Result(null, 101);
+ return new \OC\OCS\Result(null, 101);
}
}
/**
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function disableUser($parameters) {
return $this->setEnabled($parameters, false);
/**
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function enableUser($parameters) {
return $this->setEnabled($parameters, true);
/**
* @param array $parameters
* @param bool $value
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
private function setEnabled($parameters, $value) {
// Check if user is logged in
$currentLoggedInUser = $this->userSession->getUser();
if ($currentLoggedInUser === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
$targetUser = $this->userManager->get($parameters['userid']);
if($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) {
- return new OC_OCS_Result(null, 101);
+ return new \OC\OCS\Result(null, 101);
}
// If not permitted
$subAdminManager = $this->groupManager->getSubAdmin();
if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
- return new OC_OCS_Result(null, 997);
+ return new \OC\OCS\Result(null, 997);
}
// enable/disable the user now
$targetUser->setEnabled($value);
- return new OC_OCS_Result(null, 100);
+ return new \OC\OCS\Result(null, 100);
}
/**
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function getUsersGroups($parameters) {
// Check if user is logged in
$loggedInUser = $this->userSession->getUser();
if ($loggedInUser === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
$targetUser = $this->userManager->get($parameters['userid']);
if($targetUser === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_NOT_FOUND);
}
if($targetUser->getUID() === $loggedInUser->getUID() || $this->groupManager->isAdmin($loggedInUser->getUID())) {
// Self lookup or admin lookup
- return new OC_OCS_Result([
+ return new \OC\OCS\Result([
'groups' => $this->groupManager->getUserGroupIds($targetUser)
]);
} else {
$getSubAdminsGroups,
$this->groupManager->getUserGroupIds($targetUser)
);
- return new OC_OCS_Result(array('groups' => $groups));
+ return new \OC\OCS\Result(array('groups' => $groups));
} else {
// Not permitted
- return new OC_OCS_Result(null, 997);
+ return new \OC\OCS\Result(null, 997);
}
}
/**
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function addToGroup($parameters) {
// Check if user is logged in
$user = $this->userSession->getUser();
if ($user === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
// Check they're an admin
if(!$this->groupManager->isAdmin($user->getUID())) {
// This user doesn't have rights to add a user to this group
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
$groupId = !empty($_POST['groupid']) ? $_POST['groupid'] : null;
if($groupId === null) {
- return new OC_OCS_Result(null, 101);
+ return new \OC\OCS\Result(null, 101);
}
$group = $this->groupManager->get($groupId);
$targetUser = $this->userManager->get($parameters['userid']);
if($group === null) {
- return new OC_OCS_Result(null, 102);
+ return new \OC\OCS\Result(null, 102);
}
if($targetUser === null) {
- return new OC_OCS_Result(null, 103);
+ return new \OC\OCS\Result(null, 103);
}
// Add user to group
$group->addUser($targetUser);
- return new OC_OCS_Result(null, 100);
+ return new \OC\OCS\Result(null, 100);
}
/**
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function removeFromGroup($parameters) {
// Check if user is logged in
$loggedInUser = $this->userSession->getUser();
if ($loggedInUser === null) {
- return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
+ return new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
$group = !empty($parameters['_delete']['groupid']) ? $parameters['_delete']['groupid'] : null;
if($group === null) {
- return new OC_OCS_Result(null, 101);
+ return new \OC\OCS\Result(null, 101);
}
$group = $this->groupManager->get($group);
if($group === null) {
- return new OC_OCS_Result(null, 102);
+ return new \OC\OCS\Result(null, 102);
}
$targetUser = $this->userManager->get($parameters['userid']);
if($targetUser === null) {
- return new OC_OCS_Result(null, 103);
+ return new \OC\OCS\Result(null, 103);
}
// If they're not an admin, check they are a subadmin of the group in question
$subAdminManager = $this->groupManager->getSubAdmin();
if(!$this->groupManager->isAdmin($loggedInUser->getUID()) && !$subAdminManager->isSubAdminofGroup($loggedInUser, $group)) {
- return new OC_OCS_Result(null, 104);
+ return new \OC\OCS\Result(null, 104);
}
// Check they aren't removing themselves from 'admin' or their 'subadmin; group
if($parameters['userid'] === $loggedInUser->getUID()) {
if($this->groupManager->isAdmin($loggedInUser->getUID())) {
if($group->getGID() === 'admin') {
- return new OC_OCS_Result(null, 105, 'Cannot remove yourself from the admin group');
+ return new \OC\OCS\Result(null, 105, 'Cannot remove yourself from the admin group');
}
} else {
// Not an admin, check they are not removing themself from their subadmin group
}
if(in_array($group->getGID(), $subAdminGroups, true)) {
- return new OC_OCS_Result(null, 105, 'Cannot remove yourself from this group as you are a SubAdmin');
+ return new \OC\OCS\Result(null, 105, 'Cannot remove yourself from this group as you are a SubAdmin');
}
}
}
// Remove user from group
$group->removeUser($targetUser);
- return new OC_OCS_Result(null, 100);
+ return new \OC\OCS\Result(null, 100);
}
/**
* Creates a subadmin
*
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function addSubAdmin($parameters) {
$group = $this->groupManager->get($_POST['groupid']);
// Check if the user exists
if($user === null) {
- return new OC_OCS_Result(null, 101, 'User does not exist');
+ return new \OC\OCS\Result(null, 101, 'User does not exist');
}
// Check if group exists
if($group === null) {
- return new OC_OCS_Result(null, 102, 'Group:'.$_POST['groupid'].' does not exist');
+ return new \OC\OCS\Result(null, 102, 'Group:'.$_POST['groupid'].' does not exist');
}
// Check if trying to make subadmin of admin group
if(strtolower($_POST['groupid']) === 'admin') {
- return new OC_OCS_Result(null, 103, 'Cannot create subadmins for admin group');
+ return new \OC\OCS\Result(null, 103, 'Cannot create subadmins for admin group');
}
$subAdminManager = $this->groupManager->getSubAdmin();
// We cannot be subadmin twice
if ($subAdminManager->isSubAdminofGroup($user, $group)) {
- return new OC_OCS_Result(null, 100);
+ return new \OC\OCS\Result(null, 100);
}
// Go
if($subAdminManager->createSubAdmin($user, $group)) {
- return new OC_OCS_Result(null, 100);
+ return new \OC\OCS\Result(null, 100);
} else {
- return new OC_OCS_Result(null, 103, 'Unknown error occurred');
+ return new \OC\OCS\Result(null, 103, 'Unknown error occurred');
}
}
* Removes a subadmin from a group
*
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function removeSubAdmin($parameters) {
$group = $this->groupManager->get($parameters['_delete']['groupid']);
// Check if the user exists
if($user === null) {
- return new OC_OCS_Result(null, 101, 'User does not exist');
+ return new \OC\OCS\Result(null, 101, 'User does not exist');
}
// Check if the group exists
if($group === null) {
- return new OC_OCS_Result(null, 101, 'Group does not exist');
+ return new \OC\OCS\Result(null, 101, 'Group does not exist');
}
// Check if they are a subadmin of this said group
if(!$subAdminManager->isSubAdminofGroup($user, $group)) {
- return new OC_OCS_Result(null, 102, 'User is not a subadmin of this group');
+ return new \OC\OCS\Result(null, 102, 'User is not a subadmin of this group');
}
// Go
if($subAdminManager->deleteSubAdmin($user, $group)) {
- return new OC_OCS_Result(null, 100);
+ return new \OC\OCS\Result(null, 100);
} else {
- return new OC_OCS_Result(null, 103, 'Unknown error occurred');
+ return new \OC\OCS\Result(null, 103, 'Unknown error occurred');
}
}
* Get the groups a user is a subadmin of
*
* @param array $parameters
- * @return OC_OCS_Result
+ * @return \OC\OCS\Result
*/
public function getUserSubAdminGroups($parameters) {
$user = $this->userManager->get($parameters['userid']);
// Check if the user exists
if($user === null) {
- return new OC_OCS_Result(null, 101, 'User does not exist');
+ return new \OC\OCS\Result(null, 101, 'User does not exist');
}
// Get the subadmin groups
}
if(!$groups) {
- return new OC_OCS_Result(null, 102, 'Unknown error occurred');
+ return new \OC\OCS\Result(null, 102, 'Unknown error occurred');
} else {
- return new OC_OCS_Result($groups);
+ return new \OC\OCS\Result($groups);
}
}
protected function setUp() {
parent::setUp();
- $this->userManager = $this->getMock('OCP\IUserManager');
- $this->config = $this->getMock('OCP\IConfig');
+ $this->userManager = $this->getMockBuilder('OCP\IUserManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->config = $this->getMockBuilder('OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->groupManager = $this->getMockBuilder('OC\Group\Manager')
->disableOriginalConstructor()
->getMock();
- $this->userSession = $this->getMock('OCP\IUserSession');
- $this->logger = $this->getMock('OCP\ILogger');
+ $this->userSession = $this->getMockBuilder('OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->logger = $this->getMockBuilder('OCP\ILogger')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->api = $this->getMockBuilder('OCA\Provisioning_API\Users')
->setConstructorArgs([
$this->userManager,
->method('getUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED);
+ $expected = new \OC\OCS\Result(null, API::RESPOND_UNAUTHORISED);
$this->assertEquals($expected, $this->api->getUsers());
}
public function testGetUsersAsAdmin() {
$_GET['search'] = 'MyCustomSearch';
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with('MyCustomSearch', null, null)
->will($this->returnValue(['Admin' => [], 'Foo' => [], 'Bar' => []]));
- $expected = new \OC_OCS_Result([
+ $expected = new \OC\OCS\Result([
'users' => [
'Admin',
'Foo',
public function testGetUsersAsSubAdmin() {
$_GET['search'] = 'MyCustomSearch';
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->expects($this->once())
->method('isAdmin')
->will($this->returnValue(false));
- $firstGroup = $this->getMock('OCP\IGroup');
+ $firstGroup = $this->getMockBuilder('OCP\IGroup')
+ ->disableOriginalConstructor()
+ ->getMock();
$firstGroup
->expects($this->once())
->method('getGID')
->will($this->returnValue('FirstGroup'));
- $secondGroup = $this->getMock('OCP\IGroup');
+ $secondGroup = $this->getMockBuilder('OCP\IGroup')
+ ->disableOriginalConstructor()
+ ->getMock();
$secondGroup
->expects($this->once())
->method('getGID')
->method('displayNamesInGroup')
->will($this->onConsecutiveCalls(['AnotherUserInTheFirstGroup' => []], ['UserInTheSecondGroup' => []]));
- $expected = new \OC_OCS_Result([
+ $expected = new \OC\OCS\Result([
'users' => [
'AnotherUserInTheFirstGroup',
'UserInTheSecondGroup',
public function testGetUsersAsRegularUser() {
$_GET['search'] = 'MyCustomSearch';
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED);
+ $expected = new \OC\OCS\Result(null, API::RESPOND_UNAUTHORISED);
$this->assertEquals($expected, $this->api->getUsers());
}
->expects($this->once())
->method('error')
->with('Failed addUser attempt: User already exists.', ['app' => 'ocs_api']);
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with('adminUser')
->willReturn(true);
- $expected = new \OC_OCS_Result(null, 102, 'User already exists');
+ $expected = new \OC\OCS\Result(null, 102, 'User already exists');
$this->assertEquals($expected, $this->api->addUser());
}
->method('userExists')
->with('NewUser')
->willReturn(false);
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with('NonExistingGroup')
->willReturn(false);
- $expected = new \OC_OCS_Result(null, 104, 'group NonExistingGroup does not exist');
+ $expected = new \OC\OCS\Result(null, 104, 'group NonExistingGroup does not exist');
$this->assertEquals($expected, $this->api->addUser());
}
->method('userExists')
->with('NewUser')
->willReturn(false);
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
['NonExistingGroup', false]
]));
- $expected = new \OC_OCS_Result(null, 104, 'group NonExistingGroup does not exist');
+ $expected = new \OC\OCS\Result(null, 104, 'group NonExistingGroup does not exist');
$this->assertEquals($expected, $this->api->addUser());
}
->expects($this->once())
->method('info')
->with('Successful addUser call with userid: NewUser', ['app' => 'ocs_api']);
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with('adminUser')
->willReturn(true);
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->addUser());
}
->method('userExists')
->with('NewUser')
->willReturn(false);
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->method('groupExists')
->with('ExistingGroup')
->willReturn(true);
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userManager
->expects($this->once())
->method('createUser')
->with('NewUser', 'PasswordOfTheNewUser')
->willReturn($user);
- $group = $this->getMock('OCP\IGroup');
+ $group = $this->getMockBuilder('OCP\IGroup')
+ ->disableOriginalConstructor()
+ ->getMock();
$group
->expects($this->once())
->method('addUser')
['Added userid NewUser to group ExistingGroup', ['app' => 'ocs_api']]
);
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->addUser());
}
->expects($this->once())
->method('error')
->with('Failed addUser attempt with exception: User backend not found.', ['app' => 'ocs_api']);
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with('adminUser')
->willReturn(true);
- $expected = new \OC_OCS_Result(null, 101, 'Bad request');
+ $expected = new \OC\OCS\Result(null, 101, 'Bad request');
$this->assertEquals($expected, $this->api->addUser());
}
public function testAddUserAsRegularUser() {
$_POST['userid'] = 'NewUser';
$_POST['password'] = 'PasswordOfTheNewUser';
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with()
->willReturn($subAdminManager);
- $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED);
+ $expected = new \OC\OCS\Result(null, API::RESPOND_UNAUTHORISED);
$this->assertEquals($expected, $this->api->addUser());
}
public function testAddUserAsSubAdminNoGroup() {
$_POST['userid'] = 'NewUser';
$_POST['password'] = 'PasswordOfTheNewUser';
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with()
->willReturn($subAdminManager);
- $expected = new \OC_OCS_Result(null, 106, 'no group specified (required for subadmins)');
+ $expected = new \OC\OCS\Result(null, 106, 'no group specified (required for subadmins)');
$this->assertEquals($expected, $this->api->addUser());
}
$_POST['userid'] = 'NewUser';
$_POST['password'] = 'PasswordOfTheNewUser';
$_POST['groups'] = ['ExistingGroup'];
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->method('isAdmin')
->with('regularUser')
->willReturn(false);
- $existingGroup = $this->getMock('OCP\IGroup');
+ $existingGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->groupManager
->expects($this->once())
->method('get')
->with('ExistingGroup')
->willReturn(true);
- $expected = new \OC_OCS_Result(null, 105, 'insufficient privileges for group ExistingGroup');
+ $expected = new \OC\OCS\Result(null, 105, 'insufficient privileges for group ExistingGroup');
$this->assertEquals($expected, $this->api->addUser());
}
->method('userExists')
->with('NewUser')
->willReturn(false);
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
['ExistingGroup2']
)
->willReturn(true);
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userManager
->expects($this->once())
->method('createUser')
->with('NewUser', 'PasswordOfTheNewUser')
->willReturn($user);
- $existingGroup1 = $this->getMock('OCP\IGroup');
- $existingGroup2 = $this->getMock('OCP\IGroup');
+ $existingGroup1 = $this->getMockBuilder('OCP\IGroup')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $existingGroup2 = $this->getMockBuilder('OCP\IGroup')
+ ->disableOriginalConstructor()
+ ->getMock();
$existingGroup1
->expects($this->once())
->method('addUser')
->willReturn(true);
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->addUser());
}
->method('getUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED);
+ $expected = new \OC\OCS\Result(null, API::RESPOND_UNAUTHORISED);
$this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet']));
}
public function testGetUserTargetDoesNotExist() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->with('UserToGet')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, API::RESPOND_NOT_FOUND, 'The requested user could not be found');
+ $expected = new \OC\OCS\Result(null, API::RESPOND_NOT_FOUND, 'The requested user could not be found');
$this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet']));
}
public function testGetUserAsAdmin() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->will($this->returnValue('admin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$targetUser->expects($this->once())
->method('getEMailAddress')
->willReturn('demo@owncloud.org');
->method('getDisplayName')
->will($this->returnValue('Demo User'));
- $expected = new \OC_OCS_Result(
+ $expected = new \OC\OCS\Result(
[
'enabled' => 'true',
'quota' => ['DummyValue'],
}
public function testGetUserAsSubAdminAndUserIsAccessible() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$targetUser
->expects($this->once())
->method('getEMailAddress')
->method('getDisplayName')
->will($this->returnValue('Demo User'));
- $expected = new \OC_OCS_Result(
+ $expected = new \OC\OCS\Result(
[
'enabled' => 'true',
'quota' => ['DummyValue'],
}
public function testGetUserAsSubAdminAndUserIsNotAccessible() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED);
+ $expected = new \OC\OCS\Result(null, API::RESPOND_UNAUTHORISED);
$this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet']));
}
public function testGetUserAsSubAdminSelfLookup() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->method('getEMailAddress')
->will($this->returnValue('subadmin@owncloud.org'));
- $expected = new \OC_OCS_Result([
+ $expected = new \OC\OCS\Result([
'quota' => ['DummyValue'],
'email' => 'subadmin@owncloud.org',
'displayname' => 'Subadmin User',
->method('getUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED);
+ $expected = new \OC\OCS\Result(null, API::RESPOND_UNAUTHORISED);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit']));
}
public function testEditUserRegularUserSelfEditChangeDisplayName() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('UserToEdit'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->method('setDisplayName')
->with('NewDisplayName');
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'display', 'value' => 'NewDisplayName']]));
}
public function testEditUserRegularUserSelfEditChangeEmailValid() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('UserToEdit'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->method('setEMailAddress')
->with('demo@owncloud.org');
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'email', 'value' => 'demo@owncloud.org']]));
}
public function testEditUserRegularUserSelfEditChangeEmailInvalid() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('UserToEdit'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->with('UserToEdit')
->will($this->returnValue($targetUser));
- $expected = new \OC_OCS_Result(null, 102);
+ $expected = new \OC\OCS\Result(null, 102);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'email', 'value' => 'demo.org']]));
}
public function testEditUserRegularUserSelfEditChangePassword() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('UserToEdit'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->method('setPassword')
->with('NewPassword');
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'password', 'value' => 'NewPassword']]));
}
public function testEditUserRegularUserSelfEditChangeQuota() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('UserToEdit'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->with('UserToEdit')
->will($this->returnValue($targetUser));
- $expected = new \OC_OCS_Result(null, 997);
+ $expected = new \OC\OCS\Result(null, 997);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => 'NewQuota']]));
}
public function testEditUserAdminUserSelfEditChangeValidQuota() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();;
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('UserToEdit'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser->expects($this->once())
->method('setQuota')
->with('2.9 MB');
->with('UserToEdit')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
}
public function testEditUserAdminUserSelfEditChangeInvalidQuota() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('UserToEdit'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->with('UserToEdit')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 103, 'Invalid quota value ABC');
+ $expected = new \OC\OCS\Result(null, 103, 'Invalid quota value ABC');
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => 'ABC']]));
}
public function testEditUserAdminUserEditChangeValidQuota() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('admin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser->expects($this->once())
->method('setQuota')
->with('2.9 MB');
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
}
public function testEditUserSubadminUserAccessible() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser->expects($this->once())
->method('setQuota')
->with('2.9 MB');
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
}
public function testEditUserSubadminUserInaccessible() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 997);
+ $expected = new \OC\OCS\Result(null, 997);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
}
->method('getUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 997);
+ $expected = new \OC\OCS\Result(null, 997);
$this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete']));
}
public function testDeleteUserNotExistingUser() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->with('UserToDelete')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 101);
+ $expected = new \OC\OCS\Result(null, 101);
$this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete']));
}
public function testDeleteUserSelf() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('UserToDelete'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->with('UserToDelete')
->will($this->returnValue($targetUser));
- $expected = new \OC_OCS_Result(null, 101);
+ $expected = new \OC\OCS\Result(null, 101);
$this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete']));
}
public function testDeleteSuccessfulUserAsAdmin() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('admin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->method('delete')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete']));
}
public function testDeleteUnsuccessfulUserAsAdmin() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('admin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->method('delete')
->will($this->returnValue(false));
- $expected = new \OC_OCS_Result(null, 101);
+ $expected = new \OC\OCS\Result(null, 101);
$this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete']));
}
public function testDeleteSuccessfulUserAsSubadmin() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->method('delete')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete']));
}
public function testDeleteUnsuccessfulUserAsSubadmin() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->method('delete')
->will($this->returnValue(false));
- $expected = new \OC_OCS_Result(null, 101);
+ $expected = new \OC\OCS\Result(null, 101);
$this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete']));
}
public function testDeleteUserAsSubAdminAndUserIsNotAccessible() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 997);
+ $expected = new \OC\OCS\Result(null, 997);
$this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete']));
}
->method('getUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 997);
+ $expected = new \OC\OCS\Result(null, 997);
$this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup']));
}
public function testGetUsersGroupsTargetUserNotExisting() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->will($this->returnValue($loggedInUser));
- $expected = new \OC_OCS_Result(null, 998);
+ $expected = new \OC\OCS\Result(null, 998);
$this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup']));
}
public function testGetUsersGroupsSelfTargetted() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->will($this->returnValue('UserToLookup'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->with($targetUser)
->will($this->returnValue(['DummyValue']));
- $expected = new \OC_OCS_Result(['groups' => ['DummyValue']]);
+ $expected = new \OC\OCS\Result(['groups' => ['DummyValue']]);
$this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup']));
}
public function testGetUsersGroupsForAdminUser() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('admin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->with('admin')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(['groups' => ['DummyValue']]);
+ $expected = new \OC\OCS\Result(['groups' => ['DummyValue']]);
$this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup']));
}
public function testGetUsersGroupsForSubAdminUserAndUserIsAccessible() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->expects($this->once())
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $group1 = $this->getMock('OCP\IGroup');
+ $group1 = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$group1
->expects($this->any())
->method('getGID')
->will($this->returnValue('Group1'));
- $group2 = $this->getMock('OCP\IGroup');
+ $group2 = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$group2
->expects($this->any())
->method('getGID')
->with($targetUser)
->will($this->returnValue(['Group1']));
- $expected = new \OC_OCS_Result(['groups' => ['Group1']]);
+ $expected = new \OC\OCS\Result(['groups' => ['Group1']]);
$this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup']));
}
public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
->with($targetUser)
->will($this->returnValue(['Group1']));
- $expected = new \OC_OCS_Result(null, 997);
+ $expected = new \OC\OCS\Result(null, 997);
$this->assertEquals($expected, $this->api->getUsersGroups(['userid' => 'UserToLookup']));
}
->method('getUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 997);
+ $expected = new \OC\OCS\Result(null, 997);
$this->assertEquals($expected, $this->api->addToGroup([]));
}
public function testAddToGroupWithTargetGroupNotExisting() {
$_POST['groupid'] = 'GroupToAddTo';
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with('admin')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 102);
+ $expected = new \OC\OCS\Result(null, 102);
$this->assertEquals($expected, $this->api->addToGroup(['userid' => 'TargetUser']));
}
public function testAddToGroupWithNoGroupSpecified() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with('admin')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 101);
+ $expected = new \OC\OCS\Result(null, 101);
$this->assertEquals($expected, $this->api->addToGroup(['userid' => 'TargetUser']));
}
public function testAddToGroupWithTargetUserNotExisting() {
$_POST['groupid'] = 'GroupToAddTo';
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->will($this->returnValue('admin'));
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->with('admin')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 103);
+ $expected = new \OC\OCS\Result(null, 103);
$this->assertEquals($expected, $this->api->addToGroup(['userid' => 'TargetUser']));
}
public function testAddToGroupWithoutPermission() {
$_POST['groupid'] = 'GroupToAddTo';
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->with('admin')
->will($this->returnValue(false));
- $expected = new \OC_OCS_Result(null, 997);
+ $expected = new \OC\OCS\Result(null, 997);
$this->assertEquals($expected, $this->api->addToGroup(['userid' => 'TargetUser']));
}
->method('getUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 997);
+ $expected = new \OC\OCS\Result(null, 997);
$this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']]));
}
public function testRemoveFromGroupWithNoTargetGroup() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->will($this->returnValue($loggedInUser));
- $expected = new \OC_OCS_Result(null, 101);
+ $expected = new \OC\OCS\Result(null, 101);
$this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => []]));
}
public function testRemoveFromGroupWithNotExistingTargetGroup() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->with('TargetGroup')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 102);
+ $expected = new \OC\OCS\Result(null, 102);
$this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']]));
}
public function testRemoveFromGroupWithNotExistingTargetUser() {
- $loggedInUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->with('TargetUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 103);
+ $expected = new \OC\OCS\Result(null, 103);
$this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']]));
}
public function testRemoveFromGroupWithoutPermission() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->once())
->method('getUID')
->will($this->returnValue('unauthorizedUser'));
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->with('unauthorizedUser')
->will($this->returnValue(false));
- $expected = new \OC_OCS_Result(null, 104);
+ $expected = new \OC\OCS\Result(null, 104);
$this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']]));
}
public function testRemoveFromGroupAsAdminFromAdmin() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('admin'));
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$targetGroup
->expects($this->once())
->method('getGID')
->with('admin')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 105, 'Cannot remove yourself from the admin group');
+ $expected = new \OC\OCS\Result(null, 105, 'Cannot remove yourself from the admin group');
$this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'admin', '_delete' => ['groupid' => 'admin']]));
}
public function testRemoveFromGroupAsSubAdminFromSubAdmin() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('subadmin'));
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$targetGroup
->expects($this->any())
->method('getGID')
->with('subadmin')
->will($this->returnValue(false));
- $expected = new \OC_OCS_Result(null, 105, 'Cannot remove yourself from this group as you are a SubAdmin');
+ $expected = new \OC\OCS\Result(null, 105, 'Cannot remove yourself from this group as you are a SubAdmin');
$this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'subadmin', '_delete' => ['groupid' => 'subadmin']]));
}
public function testRemoveFromGroupSuccessful() {
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
->method('getUID')
->will($this->returnValue('admin'));
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
->method('getUser')
->method('removeUser')
->with($targetUser);
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'AnotherUser', '_delete' => ['groupid' => 'admin']]));
}
->with('NotExistingUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 101, 'User does not exist');
+ $expected = new \OC\OCS\Result(null, 101, 'User does not exist');
$this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'NotExistingUser']));
}
public function testAddSubAdminWithNotExistingTargetGroup() {
$_POST['groupid'] = 'NotExistingGroup';
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->with('NotExistingGroup')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 102, 'Group:NotExistingGroup does not exist');
+ $expected = new \OC\OCS\Result(null, 102, 'Group:NotExistingGroup does not exist');
$this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser']));
}
public function testAddSubAdminToAdminGroup() {
$_POST['groupid'] = 'ADmiN';
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->with('ADmiN')
->will($this->returnValue($targetGroup));
- $expected = new \OC_OCS_Result(null, 103, 'Cannot create subadmins for admin group');
+ $expected = new \OC\OCS\Result(null, 103, 'Cannot create subadmins for admin group');
$this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser']));
}
public function testAddSubAdminTwice() {
$_POST['groupid'] = 'TargetGroup';
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser']));
}
public function testAddSubAdminSuccessful() {
$_POST['groupid'] = 'TargetGroup';
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser']));
}
public function testAddSubAdminUnsuccessful() {
$_POST['groupid'] = 'TargetGroup';
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 103, 'Unknown error occurred');
+ $expected = new \OC\OCS\Result(null, 103, 'Unknown error occurred');
$this->assertEquals($expected, $this->api->addSubAdmin(['userid' => 'ExistingUser']));
}
->with('NotExistingUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 101, 'User does not exist');
+ $expected = new \OC\OCS\Result(null, 101, 'User does not exist');
$this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'NotExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']]));
}
public function testRemoveSubAdminNotExistingTargetGroup() {
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->with('GroupToDeleteFrom')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 101, 'Group does not exist');
+ $expected = new \OC\OCS\Result(null, 101, 'Group does not exist');
$this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'ExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']]));
}
public function testRemoveSubAdminFromNotASubadmin() {
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 102, 'User is not a subadmin of this group');
+ $expected = new \OC\OCS\Result(null, 102, 'User is not a subadmin of this group');
$this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'ExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']]));
}
public function testRemoveSubAdminSuccessful() {
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'ExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']]));
}
public function testRemoveSubAdminUnsuccessful() {
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 103, 'Unknown error occurred');
+ $expected = new \OC\OCS\Result(null, 103, 'Unknown error occurred');
$this->assertEquals($expected, $this->api->removeSubAdmin(['userid' => 'ExistingUser', '_delete' => ['groupid' => 'GroupToDeleteFrom']]));
}
->with('RequestedUser')
->will($this->returnValue(null));
- $expected = new \OC_OCS_Result(null, 101, 'User does not exist');
+ $expected = new \OC\OCS\Result(null, 101, 'User does not exist');
$this->assertEquals($expected, $this->api->getUserSubAdminGroups(['userid' => 'RequestedUser']));
}
public function testGetUserSubAdminGroupsWithGroups() {
- $targetUser = $this->getMock('OCP\IUser');
- $targetGroup = $this->getMock('OCP\IGroup');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$targetGroup
->expects($this->once())
->method('getGID')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(['TargetGroup'], 100);
+ $expected = new \OC\OCS\Result(['TargetGroup'], 100);
$this->assertEquals($expected, $this->api->getUserSubAdminGroups(['userid' => 'RequestedUser']));
}
public function testGetUserSubAdminGroupsWithoutGroups() {
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
->method('get')
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $expected = new \OC_OCS_Result(null, 102, 'Unknown error occurred');
+ $expected = new \OC\OCS\Result(null, 102, 'Unknown error occurred');
$this->assertEquals($expected, $this->api->getUserSubAdminGroups(['userid' => 'RequestedUser']));
}
public function testEnableUser() {
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser->expects($this->once())
->method('setEnabled')
->with(true);
->method('get')
->with('RequestedUser')
->will($this->returnValue($targetUser));
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->exactly(2))
->method('getUID')
->method('isAdmin')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->enableUser(['userid' => 'RequestedUser']));
}
public function testDisableUser() {
- $targetUser = $this->getMock('OCP\IUser');
+ $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser->expects($this->once())
->method('setEnabled')
->with(false);
->method('get')
->with('RequestedUser')
->will($this->returnValue($targetUser));
- $loggedInUser = $this->getMock('OCP\IUser');
+ $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->exactly(2))
->method('getUID')
->method('isAdmin')
->will($this->returnValue(true));
- $expected = new \OC_OCS_Result(null, 100);
+ $expected = new \OC\OCS\Result(null, 100);
$this->assertEquals($expected, $this->api->disableUser(['userid' => 'RequestedUser']));
}
}