summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-09-29 16:19:45 +0200
committerArthur Schiwon <blizzz@owncloud.com>2015-10-27 18:07:40 +0100
commite1d61284f87f2bb5aaf1523ce4f78e439d737165 (patch)
treedc074fada9fda21f6f2bdea68f1e0ebcacea331a /apps
parentc30919303990c51b78157d86b95c0f97e004233d (diff)
downloadnextcloud-server-e1d61284f87f2bb5aaf1523ce4f78e439d737165.tar.gz
nextcloud-server-e1d61284f87f2bb5aaf1523ce4f78e439d737165.zip
fix update quota with known value
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/user/user.php6
-rw-r--r--apps/user_ldap/tests/user/user.php39
2 files changed, 42 insertions, 3 deletions
diff --git a/apps/user_ldap/lib/user/user.php b/apps/user_ldap/lib/user/user.php
index c77f7254c94..0dc3c8c0c26 100644
--- a/apps/user_ldap/lib/user/user.php
+++ b/apps/user_ldap/lib/user/user.php
@@ -417,9 +417,9 @@ class User {
}
//can be null
$quotaDefault = $this->connection->ldapQuotaDefault;
- $quota = !is_null($valueFromLDAP)
- ? $valueFromLDAP
- : $quotaDefault !== '' ? $quotaDefault : null;
+ $quota = $quotaDefault !== '' ? $quotaDefault : null;
+ $quota = !is_null($valueFromLDAP) ? $valueFromLDAP : $quota;
+
if(is_null($valueFromLDAP)) {
$quotaAttribute = $this->connection->ldapQuotaAttribute;
if(!empty($quotaAttribute)) {
diff --git a/apps/user_ldap/tests/user/user.php b/apps/user_ldap/tests/user/user.php
index 1c41eb71ec2..19581d835d1 100644
--- a/apps/user_ldap/tests/user/user.php
+++ b/apps/user_ldap/tests/user/user.php
@@ -370,6 +370,45 @@ class Test_User_User extends \Test\TestCase {
$user->updateQuota();
}
+ public function testUpdateQuotaFromValue() {
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =
+ $this->getTestInstances();
+
+ list($access, $connection) =
+ $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc);
+
+ $readQuota = '19 GB';
+
+ $connection->expects($this->at(0))
+ ->method('__get')
+ ->with($this->equalTo('ldapQuotaDefault'))
+ ->will($this->returnValue(''));
+
+ $connection->expects($this->once(1))
+ ->method('__get')
+ ->with($this->equalTo('ldapQuotaDefault'))
+ ->will($this->returnValue(null));
+
+ $access->expects($this->never())
+ ->method('readAttribute');
+
+ $config->expects($this->once())
+ ->method('setUserValue')
+ ->with($this->equalTo('alice'),
+ $this->equalTo('files'),
+ $this->equalTo('quota'),
+ $this->equalTo($readQuota))
+ ->will($this->returnValue(true));
+
+ $uid = 'alice';
+ $dn = 'uid=alice,dc=foo,dc=bar';
+
+ $user = new User(
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr);
+
+ $user->updateQuota($readQuota);
+ }
+
//the testUpdateAvatar series also implicitely tests getAvatarImage
public function testUpdateAvatarJpegPhotoProvided() {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) =