summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/tests/userstest.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-07 17:22:21 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-05-02 09:31:22 +0200
commit8486926a147ad767d2ac8957512142f8a4873fa7 (patch)
treeb05e4e103b445babbeba6beeac1916f2f7191e8d /apps/provisioning_api/tests/userstest.php
parent9c9fec36dd469494738b57c691338cbe71926c10 (diff)
downloadnextcloud-server-8486926a147ad767d2ac8957512142f8a4873fa7.tar.gz
nextcloud-server-8486926a147ad767d2ac8957512142f8a4873fa7.zip
Add provisioning api to enable and disable users
Diffstat (limited to 'apps/provisioning_api/tests/userstest.php')
-rw-r--r--apps/provisioning_api/tests/userstest.php64
1 files changed, 60 insertions, 4 deletions
diff --git a/apps/provisioning_api/tests/userstest.php b/apps/provisioning_api/tests/userstest.php
index 020071bcfa1..8f463ec8b88 100644
--- a/apps/provisioning_api/tests/userstest.php
+++ b/apps/provisioning_api/tests/userstest.php
@@ -58,8 +58,8 @@ class UsersTest extends OriginalTest {
parent::tearDown();
}
- protected function setup() {
- parent::setup();
+ protected function setUp() {
+ parent::setUp();
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->config = $this->getMock('\OCP\IConfig');
@@ -540,7 +540,7 @@ class UsersTest extends OriginalTest {
->expects($this->once())
->method('isSubAdminOfGroup')
->with($loggedInUser, $existingGroup)
- ->wilLReturn(false);
+ ->willReturn(false);
$this->groupManager
->expects($this->once())
->method('getSubAdmin')
@@ -642,7 +642,7 @@ class UsersTest extends OriginalTest {
[$loggedInUser, $existingGroup1],
[$loggedInUser, $existingGroup2]
)
- ->wilLReturn(true);
+ ->willReturn(true);
$expected = new \OC_OCS_Result(null, 100);
@@ -2295,4 +2295,60 @@ class UsersTest extends OriginalTest {
$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->expects($this->once())
+ ->method('setEnabled')
+ ->with(true);
+ $this->userManager
+ ->expects($this->once())
+ ->method('get')
+ ->with('RequestedUser')
+ ->will($this->returnValue($targetUser));
+ $loggedInUser = $this->getMock('\OCP\IUser');
+ $loggedInUser
+ ->expects($this->exactly(2))
+ ->method('getUID')
+ ->will($this->returnValue('admin'));
+ $this->userSession
+ ->expects($this->once())
+ ->method('getUser')
+ ->will($this->returnValue($loggedInUser));
+ $this->groupManager
+ ->expects($this->once())
+ ->method('isAdmin')
+ ->will($this->returnValue(true));
+
+ $expected = new \OC_OCS_Result(null, 100);
+ $this->assertEquals($expected, $this->api->enableUser(['userid' => 'RequestedUser']));
+ }
+
+ public function testDisableUser() {
+ $targetUser = $this->getMock('\OCP\IUser');
+ $targetUser->expects($this->once())
+ ->method('setEnabled')
+ ->with(false);
+ $this->userManager
+ ->expects($this->once())
+ ->method('get')
+ ->with('RequestedUser')
+ ->will($this->returnValue($targetUser));
+ $loggedInUser = $this->getMock('\OCP\IUser');
+ $loggedInUser
+ ->expects($this->exactly(2))
+ ->method('getUID')
+ ->will($this->returnValue('admin'));
+ $this->userSession
+ ->expects($this->once())
+ ->method('getUser')
+ ->will($this->returnValue($loggedInUser));
+ $this->groupManager
+ ->expects($this->once())
+ ->method('isAdmin')
+ ->will($this->returnValue(true));
+
+ $expected = new \OC_OCS_Result(null, 100);
+ $this->assertEquals($expected, $this->api->disableUser(['userid' => 'RequestedUser']));
+ }
}