diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2018-03-15 18:19:48 +0300 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2018-03-15 18:19:48 +0300 |
commit | 1141ca3fbbc5fcdfb567e145461ebad099f3c90e (patch) | |
tree | c82061d57199f658b8f944c62a49c3bf6759479f /tests | |
parent | 742ae5e80d9a7201c3f32485e219ffaf1044eff1 (diff) |
adjust unit tests
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/Settings/AdminTest.php | 5 | ||||
-rw-r--r-- | tests/unit/UserBackendTest.php | 62 |
2 files changed, 66 insertions, 1 deletions
diff --git a/tests/unit/Settings/AdminTest.php b/tests/unit/Settings/AdminTest.php index a209255a..449f7189 100644 --- a/tests/unit/Settings/AdminTest.php +++ b/tests/unit/Settings/AdminTest.php @@ -106,6 +106,11 @@ class AdminTest extends \Test\TestCase { 'type' => 'line', 'required' => true, ], + 'quota_mapping' => [ + 'text' => $this->l10n->t('Attribute to map the quota to.'), + 'type' => 'line', + 'required' => false, + ], ]; $params = [ diff --git a/tests/unit/UserBackendTest.php b/tests/unit/UserBackendTest.php index 03d649c4..81ea0660 100644 --- a/tests/unit/UserBackendTest.php +++ b/tests/unit/UserBackendTest.php @@ -133,7 +133,61 @@ class UserBackendTest extends TestCase { ->method('getAppValue') ->with('user_saml', 'saml-attribute-mapping-displayName_mapping', '') ->willReturn('displayname'); + $this->config + ->expects($this->at(2)) + ->method('getAppValue') + ->with('user_saml', 'saml-attribute-mapping-quota_mapping', '') + ->willReturn('quota'); + + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->willReturn($user); + $user + ->expects($this->once()) + ->method('getEMailAddress') + ->willReturn('old@example.com'); + $user + ->expects($this->once()) + ->method('setEMailAddress') + ->with('new@example.com'); + $user + ->expects($this->once()) + ->method('setQuota') + ->with('50MB'); + $this->userBackend + ->expects($this->once()) + ->method('getDisplayName') + ->with('ExistingUser') + ->willReturn(''); + $this->userBackend + ->expects($this->once()) + ->method('setDisplayName') + ->with('ExistingUser', 'New Displayname'); + $this->userBackend->updateAttributes('ExistingUser', ['email' => 'new@example.com', 'displayname' => 'New Displayname', 'quota' => '50MB']); + } + + public function testUpdateAttributesQuotaDefaultFallback() { + $this->getMockedBuilder(['getDisplayName', 'setDisplayName']); + /** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */ + $user = $this->createMock(IUser::class); + $this->config + ->expects($this->at(0)) + ->method('getAppValue') + ->with('user_saml', 'saml-attribute-mapping-email_mapping', '') + ->willReturn('email'); + $this->config + ->expects($this->at(1)) + ->method('getAppValue') + ->with('user_saml', 'saml-attribute-mapping-displayName_mapping', '') + ->willReturn('displayname'); + $this->config + ->expects($this->at(2)) + ->method('getAppValue') + ->with('user_saml', 'saml-attribute-mapping-quota_mapping', '') + ->willReturn('quota'); $this->userManager ->expects($this->once()) @@ -148,6 +202,10 @@ class UserBackendTest extends TestCase { ->expects($this->once()) ->method('setEMailAddress') ->with('new@example.com'); + $user + ->expects($this->once()) + ->method('setQuota') + ->with('default'); $this->userBackend ->expects($this->once()) ->method('getDisplayName') @@ -157,6 +215,8 @@ class UserBackendTest extends TestCase { ->expects($this->once()) ->method('setDisplayName') ->with('ExistingUser', 'New Displayname'); - $this->userBackend->updateAttributes('ExistingUser', ['email' => 'new@example.com', 'displayname' => 'New Displayname']); + $this->userBackend->updateAttributes('ExistingUser', ['email' => 'new@example.com', 'displayname' => 'New Displayname', 'quota' => '']); } + + } |