Add tests for encoded group id
Signed-off-by: Julius Härtl <jus@bitgrid.net> Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>
This commit is contained in:
parent
5252836f44
commit
c20321e7e0
|
@ -256,7 +256,6 @@ class GroupsControllerTest extends \Test\TestCase {
|
|||
'disabled' => 11,
|
||||
'canAdd' => true,
|
||||
'canRemove' => true
|
||||
|
||||
]
|
||||
]], $result->getData());
|
||||
}
|
||||
|
@ -478,6 +477,25 @@ class GroupsControllerTest extends \Test\TestCase {
|
|||
$this->api->deleteGroup('ExistingGroup');
|
||||
}
|
||||
|
||||
public function testDeleteGroupEncoding() {
|
||||
$this->groupManager
|
||||
->method('groupExists')
|
||||
->with('ExistingGroup A/B')
|
||||
->willReturn('true');
|
||||
|
||||
$group = $this->createGroup('ExistingGroup');
|
||||
$this->groupManager
|
||||
->method('get')
|
||||
->with('ExistingGroup A/B')
|
||||
->willReturn($group);
|
||||
$group
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
->willReturn(true);
|
||||
|
||||
$this->api->deleteGroup(urlencode('ExistingGroup A/B'));
|
||||
}
|
||||
|
||||
public function testGetGroupUsersDetails() {
|
||||
$gid = 'ncg1';
|
||||
|
||||
|
@ -523,4 +541,50 @@ class GroupsControllerTest extends \Test\TestCase {
|
|||
|
||||
$this->api->getGroupUsersDetails($gid);
|
||||
}
|
||||
|
||||
public function testGetGroupUsersDetailsEncoded() {
|
||||
$gid = 'Department A/B C/D';
|
||||
|
||||
$this->asAdmin();
|
||||
$this->useAccountManager();
|
||||
|
||||
$users = [
|
||||
'ncu1' => $this->createUser('ncu1'), # regular
|
||||
'ncu2' => $this->createUser('ncu2'), # the zombie
|
||||
];
|
||||
$users['ncu2']->expects($this->atLeastOnce())
|
||||
->method('getHome')
|
||||
->willThrowException(new NoUserException());
|
||||
|
||||
$this->userManager->expects($this->any())
|
||||
->method('get')
|
||||
->willReturnCallback(function(string $uid) use ($users) {
|
||||
return isset($users[$uid]) ? $users[$uid] : null;
|
||||
});
|
||||
|
||||
$group = $this->createGroup($gid);
|
||||
$group->expects($this->once())
|
||||
->method('searchUsers')
|
||||
->with('', null, 0)
|
||||
->willReturn(array_values($users));
|
||||
|
||||
$this->groupManager
|
||||
->method('get')
|
||||
->with($gid)
|
||||
->willReturn($group);
|
||||
$this->groupManager->expects($this->any())
|
||||
->method('getUserGroups')
|
||||
->willReturn([$group]);
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
$this->subAdminManager->expects($this->any())
|
||||
->method('isSubAdminOfGroup')
|
||||
->willReturn(false);
|
||||
$this->subAdminManager->expects($this->any())
|
||||
->method('getSubAdminsGroups')
|
||||
->willReturn([]);
|
||||
|
||||
|
||||
$this->api->getGroupUsersDetails(urlencode($gid));
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue