summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorC. Montero Luque <cmonteroluque@users.noreply.github.com>2016-02-09 22:00:24 +0100
committerC. Montero Luque <cmonteroluque@users.noreply.github.com>2016-02-09 22:00:24 +0100
commit962d0c3290fc5b881c579d553373f3facaa3ab3e (patch)
tree90764075266a7708ba5ef899a5bdd4e60cbb03be /tests
parenta39c7591d6b0bfcb323cd14a5c1164576eaf7559 (diff)
parent03d0fb4e3f9734b36e015baa90901b222d03689c (diff)
downloadnextcloud-server-962d0c3290fc5b881c579d553373f3facaa3ab3e.tar.gz
nextcloud-server-962d0c3290fc5b881c579d553373f3facaa3ab3e.zip
Merge pull request #22252 from owncloud/consolidate-user-set-quota
Consolidate getQuota and setQuota methods in User instance
Diffstat (limited to 'tests')
-rw-r--r--tests/settings/controller/userscontrollertest.php80
1 files changed, 51 insertions, 29 deletions
diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php
index 38fc1ee6102..947540fa67b 100644
--- a/tests/settings/controller/userscontrollertest.php
+++ b/tests/settings/controller/userscontrollertest.php
@@ -86,7 +86,7 @@ class UsersControllerTest extends \Test\TestCase {
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('foo'));
$foo
@@ -98,6 +98,10 @@ class UsersControllerTest extends \Test\TestCase {
->method('getEMailAddress')
->will($this->returnValue('foo@bar.com'));
$foo
+ ->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('1024'));
+ $foo
->method('getLastLogin')
->will($this->returnValue(500));
$foo
@@ -110,7 +114,7 @@ class UsersControllerTest extends \Test\TestCase {
$admin = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$admin
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('admin'));
$admin
@@ -123,6 +127,10 @@ class UsersControllerTest extends \Test\TestCase {
->will($this->returnValue('admin@bar.com'));
$admin
->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('404'));
+ $admin
+ ->expects($this->once())
->method('getLastLogin')
->will($this->returnValue(12));
$admin
@@ -136,7 +144,7 @@ class UsersControllerTest extends \Test\TestCase {
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('bar'));
$bar
@@ -148,6 +156,10 @@ class UsersControllerTest extends \Test\TestCase {
->method('getEMailAddress')
->will($this->returnValue('bar@dummy.com'));
$bar
+ ->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('2323'));
+ $bar
->method('getLastLogin')
->will($this->returnValue(3999));
$bar
@@ -182,12 +194,6 @@ class UsersControllerTest extends \Test\TestCase {
->method('get')
->with('bar')
->will($this->returnValue($bar));
- $this->container['Config']
- ->expects($this->exactly(3))
- ->method('getUserValue')
- ->will($this->onConsecutiveCalls(1024,
- 404,
- 2323));
$subadmin = $this->getMockBuilder('\OC\SubAdmin')
->disableOriginalConstructor()
@@ -272,7 +278,7 @@ class UsersControllerTest extends \Test\TestCase {
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('foo'));
$foo
@@ -284,6 +290,10 @@ class UsersControllerTest extends \Test\TestCase {
->method('getEMailAddress')
->will($this->returnValue('foo@bar.com'));
$foo
+ ->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('1024'));
+ $foo
->method('getLastLogin')
->will($this->returnValue(500));
$foo
@@ -296,7 +306,7 @@ class UsersControllerTest extends \Test\TestCase {
$admin = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$admin
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('admin'));
$admin
@@ -309,6 +319,10 @@ class UsersControllerTest extends \Test\TestCase {
->will($this->returnValue('admin@bar.com'));
$admin
->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('404'));
+ $admin
+ ->expects($this->once())
->method('getLastLogin')
->will($this->returnValue(12));
$admin
@@ -322,7 +336,7 @@ class UsersControllerTest extends \Test\TestCase {
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('bar'));
$bar
@@ -334,6 +348,10 @@ class UsersControllerTest extends \Test\TestCase {
->method('getEMailAddress')
->will($this->returnValue('bar@dummy.com'));
$bar
+ ->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('2323'));
+ $bar
->method('getLastLogin')
->will($this->returnValue(3999));
$bar
@@ -377,14 +395,6 @@ class UsersControllerTest extends \Test\TestCase {
->method('get')
->with('admin')
->will($this->returnValue($admin));
- $this->container['Config']
- ->expects($this->exactly(3))
- ->method('getUserValue')
- ->will($this->onConsecutiveCalls(
- 2323,
- 1024,
- 404
- ));
$subgroup1 = $this->getMockBuilder('\OCP\IGroup')
->disableOriginalConstructor()
@@ -472,7 +482,7 @@ class UsersControllerTest extends \Test\TestCase {
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('foo'));
$foo
@@ -484,6 +494,10 @@ class UsersControllerTest extends \Test\TestCase {
->method('getEMailAddress')
->will($this->returnValue('foo@bar.com'));
$foo
+ ->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('1024'));
+ $foo
->method('getLastLogin')
->will($this->returnValue(500));
$foo
@@ -496,7 +510,7 @@ class UsersControllerTest extends \Test\TestCase {
$admin = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$admin
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('admin'));
$admin
@@ -509,6 +523,10 @@ class UsersControllerTest extends \Test\TestCase {
->will($this->returnValue('admin@bar.com'));
$admin
->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('404'));
+ $admin
+ ->expects($this->once())
->method('getLastLogin')
->will($this->returnValue(12));
$admin
@@ -522,7 +540,7 @@ class UsersControllerTest extends \Test\TestCase {
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('bar'));
$bar
@@ -534,6 +552,10 @@ class UsersControllerTest extends \Test\TestCase {
->method('getEMailAddress')
->will($this->returnValue('bar@dummy.com'));
$bar
+ ->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('2323'));
+ $bar
->method('getLastLogin')
->will($this->returnValue(3999));
$bar
@@ -553,10 +575,6 @@ class UsersControllerTest extends \Test\TestCase {
->expects($this->exactly(3))
->method('getUserGroupIds')
->will($this->onConsecutiveCalls(array('Users', 'Support'), array('admins', 'Support'), array('External Users')));
- $this->container['Config']
- ->expects($this->exactly(3))
- ->method('getUserValue')
- ->will($this->onConsecutiveCalls(1024, 404, 2323));
$subadmin = $this->getMockBuilder('\OC\SubAdmin')
->disableOriginalConstructor()
@@ -622,7 +640,7 @@ class UsersControllerTest extends \Test\TestCase {
$user = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$user
- ->expects($this->exactly(3))
+ ->expects($this->exactly(2))
->method('getUID')
->will($this->returnValue('foo'));
$user
@@ -634,6 +652,10 @@ class UsersControllerTest extends \Test\TestCase {
->method('getEMailAddress')
->will($this->returnValue(null));
$user
+ ->expects($this->once())
+ ->method('getQuota')
+ ->will($this->returnValue('none'));
+ $user
->method('getLastLogin')
->will($this->returnValue(500));
$user
@@ -674,7 +696,7 @@ class UsersControllerTest extends \Test\TestCase {
'displayname' => 'M. Foo',
'groups' => null,
'subadmin' => array(),
- 'quota' => null,
+ 'quota' => 'none',
'storageLocation' => '/home/foo',
'lastLogin' => 500000,
'backend' => 'OC_User_Database',
writeln($appId . ' disabled'); } catch(Throwable $e) { $output->writeln('<error>Error: ' . $e->getMessage() . '</error>'); $this->logger->logException($e, [ 'app' => 'CLI', 'level' => ILogger::ERROR ]); return 1; } } // Let's try to remove the app... try { $result = $this->installer->removeApp($appId); } catch(Throwable $e) { $output->writeln('<error>Error: ' . $e->getMessage() . '</error>'); $this->logger->logException($e, [ 'app' => 'CLI', 'level' => ILogger::ERROR ]); return 1; } if($result === false) { $output->writeln($appId . ' could not be removed'); return 1; } $output->writeln($appId . ' removed'); return 0; } /** * @param string $optionName * @param CompletionContext $context * @return string[] */ public function completeOptionValues($optionName, CompletionContext $context) { return []; } /** * @param string $argumentName * @param CompletionContext $context * @return string[] */ public function completeArgumentValues($argumentName, CompletionContext $context) { if ($argumentName === 'app-id') { return \OC_App::getAllApps(); } return []; } }