Skip to content

Commit

Permalink
Sync user backend test
Browse files Browse the repository at this point in the history
  • Loading branch information
melegiul committed Jul 28, 2021
1 parent 9744c96 commit 9e4bffe
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions tests/unit/UserBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ public function testUpdateAttributes() {
$this->getMockedBuilder(['getDisplayName', 'setDisplayName']);
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock(IUser::class);
$groupA = $this->createMock(IGroup::class);
$groupC = $this->createMock(IGroup::class);

$this->config
->expects($this->at(0))
Expand Down Expand Up @@ -199,35 +197,8 @@ public function testUpdateAttributes() {

$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);
->method('replaceGroups')
->with($user->getUID(), ['groupB', 'groupC']);

$this->userBackend->updateAttributes('ExistingUser', [
'email' => '[email protected]',
Expand Down

0 comments on commit 9e4bffe

Please sign in to comment.