示例#1
0
 public function testDeleteUserAsSubAdminAndUserIsNotAccessible()
 {
     $loggedInUser = $this->getMock('\\OCP\\IUser');
     $loggedInUser->expects($this->any())->method('getUID')->will($this->returnValue('subadmin'));
     $targetUser = $this->getMock('\\OCP\\IUser');
     $targetUser->expects($this->once())->method('getUID')->will($this->returnValue('UserToDelete'));
     $this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($loggedInUser));
     $this->userManager->expects($this->once())->method('get')->with('UserToDelete')->will($this->returnValue($targetUser));
     $this->groupManager->expects($this->once())->method('isAdmin')->with('subadmin')->will($this->returnValue(false));
     $subAdminManager = $this->getMockBuilder('\\OC\\Subadmin')->disableOriginalConstructor()->getMock();
     $subAdminManager->expects($this->once())->method('isUserAccessible')->with($loggedInUser, $targetUser)->will($this->returnValue(false));
     $this->groupManager->expects($this->once())->method('getSubAdmin')->will($this->returnValue($subAdminManager));
     $expected = new \OC_OCS_Result(null, 997);
     $this->assertEquals($expected, $this->api->deleteUser(['userid' => 'UserToDelete']));
 }
示例#2
0
 public function testDeleteSelfAsAdmin()
 {
     $user = $this->generateUsers();
     \OC_Group::addToGroup($user, 'admin');
     self::loginAsUser($user);
     $result = \OCA\provisioning_API\Users::deleteUser(array('userid' => $user));
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertFalse($result->succeeded());
 }