Sync user backend test

Signed-off-by: Jonathan Treffler <mail@jonathan-treffler.de>
Signed-off-by: Giuliano Mele <giuliano.mele@verdigado.com>
This commit is contained in:
Giuliano Mele 2021-07-27 13:54:57 +02:00 committed by Jonathan Treffler
parent 266a2f4467
commit 368195f03b

View file

@ -161,8 +161,6 @@ class UserBackendTest extends TestCase {
$this->getMockedBuilder(['getDisplayName', 'setDisplayName']);
/** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$groupA = $this->createMock(IGroup::class);
$groupC = $this->createMock(IGroup::class);
$this->config
->expects($this->at(0))
@ -221,38 +219,8 @@ class UserBackendTest extends TestCase {
$this->groupManager
->expects($this->once())
->method('getUserGroupIds')
->with($user)
->willReturn(['groupA', 'groupB']);
$this->groupManager
->expects($this->once())
->method('groupExists')
->with('groupC')
->willReturn(false);
$this->groupManager
->expects($this->once())
->method('createGroup')
->with('groupC');
// updateAttributes first adds new groups, then removes old ones
// In this test groupA is removed from the user, groupB is unchanged
// and groupC is added
$this->groupManager
->expects($this->exactly(2))
->method('get')
->withConsecutive(['groupC'], ['groupA'])
->willReturnOnConsecutiveCalls($groupC, $groupA);
$groupA
->expects($this->once())
->method('removeUser')
->with($user);
$groupC
->expects($this->once())
->method('addUser')
->with($user);
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
->with(new UserChangedEvent($user, 'displayName', 'New Displayname', ''));
->method('replaceGroups')
->with($user->getUID(), ['groupB', 'groupC']);
$this->userBackend->updateAttributes('ExistingUser', [
'email' => 'new@example.com',