Skip to content

Commit

Permalink
Fix user backend unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Giuliano Mele <[email protected]>
  • Loading branch information
melegiul committed Sep 16, 2021
1 parent 1b30405 commit aae3530
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions tests/unit/UserBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ public function testUpdateAttributesWithoutAttributes() {
->method('get')
->with('ExistingUser')
->willReturn($user);
$user
->expects($this->once())
->method('getEMailAddress')
->willReturn(null);
$user
->expects($this->never())
->method('setEMailAddress');
Expand All @@ -129,6 +125,17 @@ public function testUpdateAttributesWithoutAttributes() {
->method('getDisplayName')
->with('ExistingUser')
->willReturn('');
$user->expects($this->once())
->method('getUID')
->willReturn('ExistingUser');
$this->groupManager
->expects($this->once())
->method('replaceGroups')
->with('ExistingUser', []);
$this->groupManager
->expects($this->once())
->method('evaluateGroupMigrations')
->with([]);
$this->userBackend->updateAttributes('ExistingUser', []);
}

Expand Down Expand Up @@ -173,10 +180,6 @@ public function testUpdateAttributes() {
->method('get')
->with('ExistingUser')
->willReturn($user);
$user
->expects($this->once())
->method('getEMailAddress')
->willReturn('[email protected]');
$user
->expects($this->once())
->method('setEMailAddress')
Expand All @@ -194,12 +197,21 @@ public function testUpdateAttributes() {
->expects($this->once())
->method('setDisplayName')
->with('ExistingUser', 'New Displayname');

$this->groupManager
->expects($this->once())
->method('replaceGroups')
->with($user->getUID(), ['groupB', 'groupC']);

->with('ExistingUser', ['groupB', 'groupC']);
$user->expects($this->once())
->method('getUID')
->willReturn('ExistingUser');
$this->groupManager
->expects($this->once())
->method('evaluateGroupMigrations')
->with(['groupB', 'groupC']);
$this->groupManager
->expects($this->once())
->method('evaluateGroupMigrations')
->with(['groupB', 'groupC']);
$this->userBackend->updateAttributes('ExistingUser', [
'email' => '[email protected]',
'displayname' => 'New Displayname',
Expand Down Expand Up @@ -234,10 +246,6 @@ public function testUpdateAttributesQuotaDefaultFallback() {
->method('get')
->with('ExistingUser')
->willReturn($user);
$user
->expects($this->once())
->method('getEMailAddress')
->willReturn('[email protected]');
$user
->expects($this->once())
->method('setEMailAddress')
Expand All @@ -255,6 +263,17 @@ public function testUpdateAttributesQuotaDefaultFallback() {
->expects($this->once())
->method('setDisplayName')
->with('ExistingUser', 'New Displayname');
$user->expects($this->once())
->method('getUID')
->willReturn('ExistingUser');
$this->groupManager
->expects($this->once())
->method('replaceGroups')
->with('ExistingUser', []);
$this->groupManager
->expects($this->once())
->method('evaluateGroupMigrations')
->with([]);
$this->userBackend->updateAttributes('ExistingUser', ['email' => '[email protected]', 'displayname' => 'New Displayname', 'quota' => '']);
}

Expand Down

0 comments on commit aae3530

Please sign in to comment.