2014-12-22 13:54:50 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Joas Schilling <nickvergessen@owncloud.com>
|
2015-10-27 13:09:45 +00:00
|
|
|
* @author Lukas Reschke <lukas@owncloud.com>
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2015-10-26 12:54:55 +00:00
|
|
|
* @author Roeland Jago Douma <rullzer@owncloud.com>
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Tom Needham <tom@owncloud.com>
|
2014-12-22 13:54:50 +00:00
|
|
|
*
|
2016-01-12 14:02:16 +00:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
2015-03-26 10:44:34 +00:00
|
|
|
* @license AGPL-3.0
|
2014-12-22 13:54:50 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
2014-12-22 13:54:50 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2014-12-22 13:54:50 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-03-26 10:44:34 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2014-12-22 13:54:50 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2014-12-22 13:54:50 +00:00
|
|
|
*
|
|
|
|
*/
|
2015-02-26 10:37:37 +00:00
|
|
|
|
2015-01-07 09:34:42 +00:00
|
|
|
namespace OCA\Provisioning_API\Tests;
|
2014-12-22 13:54:50 +00:00
|
|
|
|
2015-08-11 09:47:01 +00:00
|
|
|
use OCP\IGroupManager;
|
|
|
|
use OCP\IUserSession;
|
2015-11-06 13:54:31 +00:00
|
|
|
use OCP\IRequest;
|
2015-08-11 09:47:01 +00:00
|
|
|
|
2015-11-06 13:54:31 +00:00
|
|
|
class GroupsTest extends \Test\TestCase {
|
2015-12-08 08:11:50 +00:00
|
|
|
/** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
|
2015-08-11 09:47:01 +00:00
|
|
|
protected $groupManager;
|
2015-12-08 08:11:50 +00:00
|
|
|
/** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */
|
2015-08-11 09:47:01 +00:00
|
|
|
protected $userSession;
|
2015-12-08 08:11:50 +00:00
|
|
|
/** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */
|
2015-11-06 13:54:31 +00:00
|
|
|
protected $request;
|
2015-12-08 08:11:50 +00:00
|
|
|
/** @var \OC\SubAdmin|\PHPUnit_Framework_MockObject_MockObject */
|
2015-11-06 13:54:31 +00:00
|
|
|
protected $subAdminManager;
|
2015-10-27 13:09:45 +00:00
|
|
|
/** @var \OCA\Provisioning_API\Groups */
|
|
|
|
protected $api;
|
2015-08-11 09:47:01 +00:00
|
|
|
|
2015-07-25 12:32:49 +00:00
|
|
|
protected function setup() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->subAdminManager = $this->getMockBuilder('OC\SubAdmin')->disableOriginalConstructor()->getMock();
|
2015-07-25 12:32:49 +00:00
|
|
|
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->groupManager = $this->getMockBuilder('OC\Group\Manager')->disableOriginalConstructor()->getMock();
|
|
|
|
$this->groupManager
|
|
|
|
->method('getSubAdmin')
|
|
|
|
->willReturn($this->subAdminManager);
|
|
|
|
|
|
|
|
$this->userSession = $this->getMock('OCP\IUserSession');
|
|
|
|
$this->request = $this->getMock('OCP\IRequest');
|
2015-07-25 13:01:31 +00:00
|
|
|
$this->api = new \OCA\Provisioning_API\Groups(
|
|
|
|
$this->groupManager,
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->userSession,
|
|
|
|
$this->request
|
2015-07-25 13:01:31 +00:00
|
|
|
);
|
2015-07-25 12:32:49 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* @param string $gid
|
2015-12-08 08:11:50 +00:00
|
|
|
* @return \OCP\IGroup|\PHPUnit_Framework_MockObject_MockObject
|
2015-12-07 20:08:20 +00:00
|
|
|
*/
|
2015-11-06 13:54:31 +00:00
|
|
|
private function createGroup($gid) {
|
|
|
|
$group = $this->getMock('OCP\IGroup');
|
|
|
|
$group
|
|
|
|
->method('getGID')
|
|
|
|
->willReturn($gid);
|
|
|
|
return $group;
|
|
|
|
}
|
2015-08-11 09:47:01 +00:00
|
|
|
|
2015-12-07 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* @param string $uid
|
2015-12-08 08:11:50 +00:00
|
|
|
* @return \OCP\IUser|\PHPUnit_Framework_MockObject_MockObject
|
2015-12-07 20:08:20 +00:00
|
|
|
*/
|
2015-11-06 13:54:31 +00:00
|
|
|
private function createUser($uid) {
|
|
|
|
$user = $this->getMock('OCP\IUser');
|
|
|
|
$user
|
|
|
|
->method('getUID')
|
|
|
|
->willReturn($uid);
|
|
|
|
return $user;
|
|
|
|
}
|
2015-08-11 09:47:01 +00:00
|
|
|
|
2015-11-06 13:54:31 +00:00
|
|
|
private function asUser() {
|
|
|
|
$user = $this->createUser('user');
|
|
|
|
$this->userSession
|
|
|
|
->method('getUser')
|
|
|
|
->willReturn($user);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function asAdmin() {
|
|
|
|
$user = $this->createUser('admin');
|
|
|
|
$this->userSession
|
|
|
|
->method('getUser')
|
|
|
|
->willReturn($user);
|
|
|
|
|
|
|
|
$this->groupManager
|
|
|
|
->method('isAdmin')
|
|
|
|
->with('admin')
|
|
|
|
->willReturn(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function asSubAdminOfGroup($group) {
|
|
|
|
$user = $this->createUser('subAdmin');
|
|
|
|
$this->userSession
|
|
|
|
->method('getUser')
|
|
|
|
->willReturn($user);
|
|
|
|
|
|
|
|
$this->subAdminManager
|
|
|
|
->method('isSubAdminOfGroup')
|
|
|
|
->will($this->returnCallback(function($_user, $_group) use ($user, $group) {
|
|
|
|
if ($_user === $user && $_group === $group) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dataGetGroups() {
|
|
|
|
return [
|
|
|
|
[null, null, null],
|
|
|
|
['foo', null, null],
|
|
|
|
[null, 1, null],
|
|
|
|
[null, null, 2],
|
|
|
|
['foo', 1, 2],
|
2015-08-11 09:47:01 +00:00
|
|
|
];
|
2015-11-06 13:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataGetGroups
|
|
|
|
*/
|
|
|
|
public function testGetGroups($search, $limit, $offset) {
|
|
|
|
$this->request
|
|
|
|
->expects($this->exactly(3))
|
|
|
|
->method('getParam')
|
|
|
|
->will($this->returnValueMap([
|
|
|
|
['search', '', $search],
|
|
|
|
['limit', null, $limit],
|
|
|
|
['offset', null, $offset],
|
|
|
|
]));
|
|
|
|
|
|
|
|
$groups = [$this->createGroup('group1'), $this->createGroup('group2')];
|
|
|
|
|
|
|
|
$search = $search === null ? '' : $search;
|
|
|
|
|
|
|
|
$this->groupManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('search')
|
|
|
|
->with($search, $limit, $offset)
|
|
|
|
->willReturn($groups);
|
|
|
|
|
2015-08-11 09:47:01 +00:00
|
|
|
$result = $this->api->getGroups([]);
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertTrue($result->succeeded());
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->assertEquals(['group1', 'group2'], $result->getData()['groups']);
|
2015-08-11 09:47:01 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 09:34:42 +00:00
|
|
|
public function testGetGroupAsUser() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$result = $this->api->getGroup([]);
|
2014-12-22 13:54:50 +00:00
|
|
|
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertFalse($result->succeeded());
|
2015-04-18 08:30:02 +00:00
|
|
|
$this->assertEquals(\OCP\API::RESPOND_UNAUTHORISED, $result->getStatusCode());
|
2014-12-22 13:54:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-01-07 09:34:42 +00:00
|
|
|
public function testGetGroupAsSubadmin() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$group = $this->createGroup('group');
|
|
|
|
$this->asSubAdminOfGroup($group);
|
|
|
|
|
|
|
|
$this->groupManager
|
|
|
|
->method('get')
|
|
|
|
->with('group')
|
|
|
|
->willReturn($group);
|
|
|
|
$this->groupManager
|
|
|
|
->method('groupExists')
|
|
|
|
->with('group')
|
|
|
|
->willReturn(true);
|
|
|
|
$group
|
|
|
|
->method('getUsers')
|
|
|
|
->willReturn([
|
|
|
|
$this->createUser('user1'),
|
|
|
|
$this->createUser('user2')
|
|
|
|
]);
|
2014-12-22 13:54:50 +00:00
|
|
|
|
2015-07-25 20:37:14 +00:00
|
|
|
$result = $this->api->getGroup([
|
2015-11-06 13:54:31 +00:00
|
|
|
'groupid' => 'group',
|
2015-07-25 20:37:14 +00:00
|
|
|
]);
|
2014-12-22 13:54:50 +00:00
|
|
|
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertTrue($result->succeeded());
|
2015-02-25 15:21:18 +00:00
|
|
|
$this->assertEquals(1, sizeof($result->getData()), 'Asserting the result data array only has the "users" key');
|
|
|
|
$this->assertArrayHasKey('users', $result->getData());
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->assertEquals(['user1', 'user2'], $result->getData()['users']);
|
2014-12-22 13:54:50 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 09:34:42 +00:00
|
|
|
public function testGetGroupAsIrrelevantSubadmin() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$group = $this->createGroup('group');
|
|
|
|
$otherGroup = $this->createGroup('otherGroup');
|
|
|
|
$this->asSubAdminOfGroup($otherGroup);
|
|
|
|
|
|
|
|
$this->groupManager
|
|
|
|
->method('get')
|
|
|
|
->with('group')
|
|
|
|
->willReturn($group);
|
|
|
|
$this->groupManager
|
|
|
|
->method('groupExists')
|
|
|
|
->with('group')
|
|
|
|
->willReturn(true);
|
2014-12-22 13:54:50 +00:00
|
|
|
|
2015-07-25 20:37:14 +00:00
|
|
|
$result = $this->api->getGroup([
|
2015-11-06 13:54:31 +00:00
|
|
|
'groupid' => 'group',
|
2015-07-25 20:37:14 +00:00
|
|
|
]);
|
2014-12-22 13:54:50 +00:00
|
|
|
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertFalse($result->succeeded());
|
2015-04-18 08:30:02 +00:00
|
|
|
$this->assertEquals(\OCP\API::RESPOND_UNAUTHORISED, $result->getStatusCode());
|
2014-12-22 13:54:50 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 09:34:42 +00:00
|
|
|
public function testGetGroupAsAdmin() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$group = $this->createGroup('group');
|
|
|
|
$this->asAdmin();
|
|
|
|
|
|
|
|
$this->groupManager
|
|
|
|
->method('get')
|
|
|
|
->with('group')
|
|
|
|
->willReturn($group);
|
|
|
|
$this->groupManager
|
|
|
|
->method('groupExists')
|
|
|
|
->with('group')
|
|
|
|
->willReturn(true);
|
|
|
|
$group
|
|
|
|
->method('getUsers')
|
|
|
|
->willReturn([
|
|
|
|
$this->createUser('user1'),
|
|
|
|
$this->createUser('user2')
|
|
|
|
]);
|
2014-12-22 13:54:50 +00:00
|
|
|
|
2015-07-25 20:37:14 +00:00
|
|
|
$result = $this->api->getGroup([
|
2015-11-06 13:54:31 +00:00
|
|
|
'groupid' => 'group',
|
2015-07-25 20:37:14 +00:00
|
|
|
]);
|
2014-12-22 13:54:50 +00:00
|
|
|
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertTrue($result->succeeded());
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->assertEquals(1, sizeof($result->getData()), 'Asserting the result data array only has the "users" key');
|
|
|
|
$this->assertArrayHasKey('users', $result->getData());
|
|
|
|
$this->assertEquals(['user1', 'user2'], $result->getData()['users']);
|
2014-12-22 13:54:50 +00:00
|
|
|
}
|
|
|
|
|
2015-08-11 09:47:01 +00:00
|
|
|
public function testGetGroupNonExisting() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->asUser();
|
|
|
|
|
2015-08-11 09:47:01 +00:00
|
|
|
$result = $this->api->getGroup([
|
|
|
|
'groupid' => $this->getUniqueId()
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertFalse($result->succeeded());
|
|
|
|
$this->assertEquals(\OCP\API::RESPOND_NOT_FOUND, $result->getStatusCode());
|
|
|
|
$this->assertEquals('The requested group could not be found', $result->getMeta()['message']);
|
|
|
|
}
|
|
|
|
|
2015-11-06 13:54:31 +00:00
|
|
|
public function testGetSubAdminsOfGroupsNotExists() {
|
|
|
|
$result = $this->api->getSubAdminsOfGroup([
|
|
|
|
'groupid' => 'NonExistingGroup',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertFalse($result->succeeded());
|
|
|
|
$this->assertEquals(101, $result->getStatusCode());
|
|
|
|
$this->assertEquals('Group does not exist', $result->getMeta()['message']);
|
|
|
|
}
|
|
|
|
|
2015-01-07 09:34:42 +00:00
|
|
|
public function testGetSubAdminsOfGroup() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$group = $this->createGroup('GroupWithSubAdmins');
|
|
|
|
$this->groupManager
|
|
|
|
->method('get')
|
|
|
|
->with('GroupWithSubAdmins')
|
|
|
|
->willReturn($group);
|
|
|
|
|
|
|
|
$this->subAdminManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('getGroupsSubAdmins')
|
|
|
|
->with($group)
|
|
|
|
->willReturn([
|
|
|
|
$this->createUser('SubAdmin1'),
|
|
|
|
$this->createUser('SubAdmin2'),
|
|
|
|
]);
|
|
|
|
|
2015-07-25 20:37:14 +00:00
|
|
|
$result = $this->api->getSubAdminsOfGroup([
|
2015-11-06 13:54:31 +00:00
|
|
|
'groupid' => 'GroupWithSubAdmins',
|
2015-07-25 20:37:14 +00:00
|
|
|
]);
|
2015-11-06 13:54:31 +00:00
|
|
|
|
2014-12-22 13:54:50 +00:00
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertTrue($result->succeeded());
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->assertEquals(['SubAdmin1', 'SubAdmin2'], $result->getData());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetSubAdminsOfGroupEmptyList() {
|
|
|
|
$group = $this->createGroup('GroupWithOutSubAdmins');
|
|
|
|
$this->groupManager
|
|
|
|
->method('get')
|
|
|
|
->with('GroupWithOutSubAdmins')
|
|
|
|
->willReturn($group);
|
|
|
|
|
|
|
|
$this->subAdminManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('getGroupsSubAdmins')
|
|
|
|
->with($group)
|
|
|
|
->willReturn([
|
|
|
|
]);
|
2014-12-22 13:54:50 +00:00
|
|
|
|
2015-07-25 20:37:14 +00:00
|
|
|
$result = $this->api->getSubAdminsOfGroup([
|
2015-11-06 13:54:31 +00:00
|
|
|
'groupid' => 'GroupWithOutSubAdmins',
|
2015-07-25 20:37:14 +00:00
|
|
|
]);
|
2015-11-06 13:54:31 +00:00
|
|
|
|
2014-12-22 13:54:50 +00:00
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
2015-11-16 21:24:53 +00:00
|
|
|
$this->assertTrue($result->succeeded());
|
|
|
|
$this->assertEquals([], $result->getData());
|
2014-12-22 13:54:50 +00:00
|
|
|
}
|
2015-08-11 09:47:01 +00:00
|
|
|
|
|
|
|
public function testAddGroupEmptyGroup() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->request
|
|
|
|
->method('getParam')
|
|
|
|
->with('groupid')
|
|
|
|
->willReturn('');
|
|
|
|
|
2015-08-11 09:47:01 +00:00
|
|
|
$result = $this->api->addGroup([]);
|
|
|
|
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertFalse($result->succeeded());
|
|
|
|
$this->assertEquals(101, $result->getStatusCode());
|
|
|
|
$this->assertEquals('Invalid group name', $result->getMeta()['message']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAddGroupExistingGroup() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->request
|
|
|
|
->method('getParam')
|
|
|
|
->with('groupid')
|
|
|
|
->willReturn('ExistingGroup');
|
|
|
|
|
|
|
|
$this->groupManager
|
|
|
|
->method('groupExists')
|
|
|
|
->with('ExistingGroup')
|
|
|
|
->willReturn(true);
|
2015-08-11 09:47:01 +00:00
|
|
|
|
|
|
|
$result = $this->api->addGroup([]);
|
|
|
|
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertFalse($result->succeeded());
|
|
|
|
$this->assertEquals(102, $result->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAddGroup() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->request
|
|
|
|
->method('getParam')
|
|
|
|
->with('groupid')
|
|
|
|
->willReturn('NewGroup');
|
2015-08-11 09:47:01 +00:00
|
|
|
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->groupManager
|
|
|
|
->method('groupExists')
|
|
|
|
->with('NewGroup')
|
|
|
|
->willReturn(false);
|
|
|
|
|
|
|
|
$this->groupManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('createGroup')
|
|
|
|
->with('NewGroup');
|
2015-08-11 09:47:01 +00:00
|
|
|
|
|
|
|
$result = $this->api->addGroup([]);
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertTrue($result->succeeded());
|
|
|
|
}
|
|
|
|
|
2015-12-04 13:21:24 +00:00
|
|
|
public function testAddGroupWithSpecialChar() {
|
|
|
|
$this->request
|
|
|
|
->method('getParam')
|
|
|
|
->with('groupid')
|
|
|
|
->willReturn('Iñtërnâtiônàlizætiøn');
|
|
|
|
|
|
|
|
$this->groupManager
|
|
|
|
->method('groupExists')
|
2015-12-23 07:31:20 +00:00
|
|
|
->with('Iñtërnâtiônàlizætiøn')
|
2015-12-04 13:21:24 +00:00
|
|
|
->willReturn(false);
|
|
|
|
|
|
|
|
$this->groupManager
|
|
|
|
->expects($this->once())
|
|
|
|
->method('createGroup')
|
|
|
|
->with('Iñtërnâtiônàlizætiøn');
|
|
|
|
|
|
|
|
$result = $this->api->addGroup([]);
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertTrue($result->succeeded());
|
|
|
|
}
|
|
|
|
|
2015-08-11 09:47:01 +00:00
|
|
|
public function testDeleteGroupNonExisting() {
|
|
|
|
$result = $this->api->deleteGroup([
|
2015-11-06 13:54:31 +00:00
|
|
|
'groupid' => 'NonExistingGroup'
|
2015-08-11 09:47:01 +00:00
|
|
|
]);
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertFalse($result->succeeded());
|
|
|
|
$this->assertEquals(101, $result->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDeleteAdminGroup() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->groupManager
|
|
|
|
->method('groupExists')
|
|
|
|
->with('admin')
|
|
|
|
->willReturn('true');
|
|
|
|
|
2015-08-11 09:47:01 +00:00
|
|
|
$result = $this->api->deleteGroup([
|
|
|
|
'groupid' => 'admin'
|
|
|
|
]);
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertFalse($result->succeeded());
|
|
|
|
$this->assertEquals(102, $result->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDeleteGroup() {
|
2015-11-06 13:54:31 +00:00
|
|
|
$this->groupManager
|
|
|
|
->method('groupExists')
|
|
|
|
->with('ExistingGroup')
|
|
|
|
->willReturn('true');
|
|
|
|
|
|
|
|
$group = $this->createGroup('ExistingGroup');
|
|
|
|
$this->groupManager
|
|
|
|
->method('get')
|
|
|
|
->with('ExistingGroup')
|
|
|
|
->willReturn($group);
|
|
|
|
$group
|
|
|
|
->expects($this->once())
|
|
|
|
->method('delete')
|
|
|
|
->willReturn(true);
|
2015-08-11 09:47:01 +00:00
|
|
|
|
|
|
|
$result = $this->api->deleteGroup([
|
2015-11-06 13:54:31 +00:00
|
|
|
'groupid' => 'ExistingGroup',
|
2015-08-11 09:47:01 +00:00
|
|
|
]);
|
|
|
|
$this->assertInstanceOf('OC_OCS_Result', $result);
|
|
|
|
$this->assertTrue($result->succeeded());
|
|
|
|
}
|
2014-12-22 13:54:50 +00:00
|
|
|
}
|