[Pkg-owncloud-commits] [owncloud] 03/27: fix update quota with known value

David Prévot taffit at moszumanska.debian.org
Wed Oct 28 17:03:04 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v8.1.4RC2
in repository owncloud.

commit a05ead505d5cd6b29119e96c95d83b6d0bdb0f98
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Tue Sep 29 16:19:45 2015 +0200

    fix update quota with known value
---
 apps/user_ldap/lib/user/user.php   |  6 +++---
 apps/user_ldap/tests/user/user.php | 39 ++++++++++++++++++++++++++++++++++++++
 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 6498cdf..1f48a48 100644
--- a/apps/user_ldap/lib/user/user.php
+++ b/apps/user_ldap/lib/user/user.php
@@ -413,9 +413,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 1c41eb7..19581d8 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) =

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list