diff options
author | Juan Pablo Villafáñez <jvillafanez@solidgear.es> | 2017-03-17 13:02:08 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-03-29 13:32:16 +0200 |
commit | 4622bebdedf277ff19bdf7b261f2b4c6e78873b8 (patch) | |
tree | 80a6bbcd1015fb2b6d870f53b33a3bf63801f87d | |
parent | 3676189e05d3b51e3162c4410b30ea7268048c48 (diff) | |
download | nextcloud-server-4622bebdedf277ff19bdf7b261f2b4c6e78873b8.tar.gz nextcloud-server-4622bebdedf277ff19bdf7b261f2b4c6e78873b8.zip |
Include tests for "default" and "none" quotas
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-rw-r--r-- | apps/user_ldap/tests/User/UserTest.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php index b9182859631..6961e39d9f0 100644 --- a/apps/user_ldap/tests/User/UserTest.php +++ b/apps/user_ldap/tests/User/UserTest.php @@ -249,6 +249,86 @@ class UserTest extends \Test\TestCase { $user->updateQuota(); } + public function testUpdateQuotaToDefaultAllProvided() { + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = + $this->getTestInstances(); + + list($access, $connection) = + $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc); + + $connection->expects($this->at(0)) + ->method('__get') + ->with($this->equalTo('ldapQuotaAttribute')) + ->will($this->returnValue('myquota')); + + $connection->expects($this->exactly(1)) + ->method('__get'); + + $access->expects($this->once()) + ->method('readAttribute') + ->with($this->equalTo('uid=alice,dc=foo,dc=bar'), + $this->equalTo('myquota')) + ->will($this->returnValue(array('default'))); + + $user = $this->createMock('\OCP\IUser'); + $user->expects($this->once()) + ->method('setQuota') + ->with('default'); + + $userMgr->expects($this->once()) + ->method('get') + ->with('alice') + ->will($this->returnValue($user)); + + $uid = 'alice'; + $dn = 'uid=alice,dc=foo,dc=bar'; + + $user = new User( + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); + + $user->updateQuota(); + } + + public function testUpdateQuotaToNoneAllProvided() { + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = + $this->getTestInstances(); + + list($access, $connection) = + $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc); + + $connection->expects($this->at(0)) + ->method('__get') + ->with($this->equalTo('ldapQuotaAttribute')) + ->will($this->returnValue('myquota')); + + $connection->expects($this->exactly(1)) + ->method('__get'); + + $access->expects($this->once()) + ->method('readAttribute') + ->with($this->equalTo('uid=alice,dc=foo,dc=bar'), + $this->equalTo('myquota')) + ->will($this->returnValue(array('none'))); + + $user = $this->createMock('\OCP\IUser'); + $user->expects($this->once()) + ->method('setQuota') + ->with('none'); + + $userMgr->expects($this->once()) + ->method('get') + ->with('alice') + ->will($this->returnValue($user)); + + $uid = 'alice'; + $dn = 'uid=alice,dc=foo,dc=bar'; + + $user = new User( + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); + + $user->updateQuota(); + } + public function testUpdateQuotaDefaultProvided() { list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); |