Example #1
0
 public function testGetUserSubAdminGroupsWithoutGroups()
 {
     $targetUser = $this->getMock('\\OCP\\IUser');
     $this->userManager->expects($this->once())->method('get')->with('RequestedUser')->will($this->returnValue($targetUser));
     $subAdminManager = $this->getMockBuilder('\\OC\\Subadmin')->disableOriginalConstructor()->getMock();
     $subAdminManager->expects($this->once())->method('getSubAdminsGroups')->with($targetUser)->will($this->returnValue([]));
     $this->groupManager->expects($this->once())->method('getSubAdmin')->will($this->returnValue($subAdminManager));
     $expected = new \OC_OCS_Result(null, 102, 'Unknown error occurred');
     $this->assertEquals($expected, $this->api->getUserSubAdminGroups(['userid' => 'RequestedUser']));
 }
Example #2
0
 public function testGetSubAdminGroups()
 {
     $user1 = $this->generateUsers();
     $user2 = $this->generateUsers();
     self::loginAsUser($user1);
     \OC_Group::addToGroup($user1, 'admin');
     $group1 = $this->getUniqueID();
     \OC_Group::createGroup($group1);
     \OC_SubAdmin::createSubAdmin($user2, $group1);
     $result = \OCA\provisioning_api\Users::getUserSubAdminGroups(array('userid' => $user2));
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertTrue($result->succeeded());
     $data = $result->getData();
     $this->assertEquals($group1, reset($data));
     \OC_Group::deleteGroup($group1);
     $user1 = $this->generateUsers();
     self::loginAsUser($user1);
     \OC_Group::addToGroup($user1, 'admin');
     $group1 = $this->getUniqueID();
     $result = \OCA\provisioning_api\Users::getUserSubAdminGroups(array('userid' => $this->getUniqueID()));
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertFalse($result->succeeded());
     $this->assertEquals(101, $result->getStatusCode());
 }