public function testEditUserSubadminUserInaccessible() { $loggedInUser = $this->getMock('\\OCP\\IUser'); $loggedInUser->expects($this->any())->method('getUID')->will($this->returnValue('subadmin')); $targetUser = $this->getMock('\\OCP\\IUser'); $this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($loggedInUser)); $this->userManager->expects($this->once())->method('get')->with('UserToEdit')->will($this->returnValue($targetUser)); $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->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']])); }
public function testUserEditOtherUserEmailAsAdmin() { $users = $this->generateUsers(2); $email = '*****@*****.**'; self::loginAsUser($users[0]); \OC_Group::addToGroup($users[0], 'admin'); $result = \OCA\provisioning_API\Users::editUser(array('userid' => $users[1], '_put' => array('key' => 'email', 'value' => $email))); $this->assertInstanceOf('OC_OCS_Result', $result); $this->assertTrue($result->succeeded()); $this->assertEquals($email, \OC::$server->getConfig()->getUserValue($users[1], 'settings', 'email', null)); }