Merge pull request #22252 from owncloud/consolidate-user-set-quota
Consolidate getQuota and setQuota methods in User instance
This commit is contained in:
commit
962d0c3290
|
@ -564,11 +564,8 @@ class Trashbin {
|
||||||
$config = \OC::$server->getConfig();
|
$config = \OC::$server->getConfig();
|
||||||
|
|
||||||
$softQuota = true;
|
$softQuota = true;
|
||||||
$quota = $config->getUserValue($user, 'files', 'quota', null);
|
$quota = \OC::$server->getUserManager()->get($user)->getQuota();
|
||||||
$view = new \OC\Files\View('/' . $user);
|
$view = new \OC\Files\View('/' . $user);
|
||||||
if ($quota === null || $quota === 'default') {
|
|
||||||
$quota = $config->getAppValue('files', 'default_quota', null);
|
|
||||||
}
|
|
||||||
if ($quota === null || $quota === 'none') {
|
if ($quota === null || $quota === 'none') {
|
||||||
$quota = \OC\Files\Filesystem::free_space('/');
|
$quota = \OC\Files\Filesystem::free_space('/');
|
||||||
$softQuota = false;
|
$softQuota = false;
|
||||||
|
|
|
@ -653,11 +653,9 @@ class Storage {
|
||||||
$versionsFileview = new \OC\Files\View('/'.$uid.'/files_versions');
|
$versionsFileview = new \OC\Files\View('/'.$uid.'/files_versions');
|
||||||
|
|
||||||
// get available disk space for user
|
// get available disk space for user
|
||||||
|
$user = \OC::$server->getUserManager()->get($uid);
|
||||||
$softQuota = true;
|
$softQuota = true;
|
||||||
$quota = $config->getUserValue($uid, 'files', 'quota', null);
|
$quota = $user->getQuota();
|
||||||
if ( $quota === null || $quota === 'default') {
|
|
||||||
$quota = $config->getAppValue('files', 'default_quota', null);
|
|
||||||
}
|
|
||||||
if ( $quota === null || $quota === 'none' ) {
|
if ( $quota === null || $quota === 'none' ) {
|
||||||
$quota = \OC\Files\Filesystem::free_space('/');
|
$quota = \OC\Files\Filesystem::free_space('/');
|
||||||
$softQuota = false;
|
$softQuota = false;
|
||||||
|
|
|
@ -278,7 +278,7 @@ class Users {
|
||||||
$quota = \OCP\Util::humanFileSize($quota);
|
$quota = \OCP\Util::humanFileSize($quota);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->config->setUserValue($targetUserId, 'files', 'quota', $quota);
|
$targetUser->setQuota($quota);
|
||||||
break;
|
break;
|
||||||
case 'password':
|
case 'password':
|
||||||
$targetUser->setPassword($parameters['_put']['value']);
|
$targetUser->setPassword($parameters['_put']['value']);
|
||||||
|
|
|
@ -1015,6 +1015,9 @@ class UsersTest extends OriginalTest {
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('UserToEdit'));
|
->will($this->returnValue('UserToEdit'));
|
||||||
$targetUser = $this->getMock('\OCP\IUser');
|
$targetUser = $this->getMock('\OCP\IUser');
|
||||||
|
$targetUser->expects($this->once())
|
||||||
|
->method('setQuota')
|
||||||
|
->with('2.9 MB');
|
||||||
$this->userSession
|
$this->userSession
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getUser')
|
->method('getUser')
|
||||||
|
@ -1029,10 +1032,6 @@ class UsersTest extends OriginalTest {
|
||||||
->method('isAdmin')
|
->method('isAdmin')
|
||||||
->with('UserToEdit')
|
->with('UserToEdit')
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
$this->config
|
|
||||||
->expects($this->once())
|
|
||||||
->method('setUserValue')
|
|
||||||
->with('UserToEdit', 'files', 'quota', '2.9 MB');
|
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null, 100);
|
$expected = new \OC_OCS_Result(null, 100);
|
||||||
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
|
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
|
||||||
|
@ -1071,6 +1070,9 @@ class UsersTest extends OriginalTest {
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('admin'));
|
->will($this->returnValue('admin'));
|
||||||
$targetUser = $this->getMock('\OCP\IUser');
|
$targetUser = $this->getMock('\OCP\IUser');
|
||||||
|
$targetUser->expects($this->once())
|
||||||
|
->method('setQuota')
|
||||||
|
->with('2.9 MB');
|
||||||
$this->userSession
|
$this->userSession
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getUser')
|
->method('getUser')
|
||||||
|
@ -1092,10 +1094,6 @@ class UsersTest extends OriginalTest {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getSubAdmin')
|
->method('getSubAdmin')
|
||||||
->will($this->returnValue($subAdminManager));
|
->will($this->returnValue($subAdminManager));
|
||||||
$this->config
|
|
||||||
->expects($this->once())
|
|
||||||
->method('setUserValue')
|
|
||||||
->with('UserToEdit', 'files', 'quota', '2.9 MB');
|
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null, 100);
|
$expected = new \OC_OCS_Result(null, 100);
|
||||||
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
|
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
|
||||||
|
@ -1108,6 +1106,9 @@ class UsersTest extends OriginalTest {
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('subadmin'));
|
->will($this->returnValue('subadmin'));
|
||||||
$targetUser = $this->getMock('\OCP\IUser');
|
$targetUser = $this->getMock('\OCP\IUser');
|
||||||
|
$targetUser->expects($this->once())
|
||||||
|
->method('setQuota')
|
||||||
|
->with('2.9 MB');
|
||||||
$this->userSession
|
$this->userSession
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getUser')
|
->method('getUser')
|
||||||
|
@ -1129,10 +1130,6 @@ class UsersTest extends OriginalTest {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getSubAdmin')
|
->method('getSubAdmin')
|
||||||
->will($this->returnValue($subAdminManager));
|
->will($this->returnValue($subAdminManager));
|
||||||
$this->config
|
|
||||||
->expects($this->once())
|
|
||||||
->method('setUserValue')
|
|
||||||
->with('UserToEdit', 'files', 'quota', '2.9 MB');
|
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null, 100);
|
$expected = new \OC_OCS_Result(null, 100);
|
||||||
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
|
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
|
||||||
|
|
|
@ -456,7 +456,7 @@ class User {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!is_null($quota)) {
|
if(!is_null($quota)) {
|
||||||
$this->config->setUserValue($this->uid, 'files', 'quota', $quota);
|
$user = $this->userManager->get($this->uid)->setQuota($quota);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,13 +210,15 @@ class Test_User_User extends \Test\TestCase {
|
||||||
$this->equalTo('myquota'))
|
$this->equalTo('myquota'))
|
||||||
->will($this->returnValue(array('42 GB')));
|
->will($this->returnValue(array('42 GB')));
|
||||||
|
|
||||||
$config->expects($this->once())
|
$user = $this->getMock('\OCP\IUser');
|
||||||
->method('setUserValue')
|
$user->expects($this->once())
|
||||||
->with($this->equalTo('alice'),
|
->method('setQuota')
|
||||||
$this->equalTo('files'),
|
->with('42 GB');
|
||||||
$this->equalTo('quota'),
|
|
||||||
$this->equalTo('42 GB'))
|
$userMgr->expects($this->once())
|
||||||
->will($this->returnValue(true));
|
->method('get')
|
||||||
|
->with('alice')
|
||||||
|
->will($this->returnValue($user));
|
||||||
|
|
||||||
$uid = 'alice';
|
$uid = 'alice';
|
||||||
$dn = 'uid=alice,dc=foo,dc=bar';
|
$dn = 'uid=alice,dc=foo,dc=bar';
|
||||||
|
@ -253,13 +255,15 @@ class Test_User_User extends \Test\TestCase {
|
||||||
$this->equalTo('myquota'))
|
$this->equalTo('myquota'))
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
|
|
||||||
$config->expects($this->once())
|
$user = $this->getMock('\OCP\IUser');
|
||||||
->method('setUserValue')
|
$user->expects($this->once())
|
||||||
->with($this->equalTo('alice'),
|
->method('setQuota')
|
||||||
$this->equalTo('files'),
|
->with('25 GB');
|
||||||
$this->equalTo('quota'),
|
|
||||||
$this->equalTo('25 GB'))
|
$userMgr->expects($this->once())
|
||||||
->will($this->returnValue(true));
|
->method('get')
|
||||||
|
->with('alice')
|
||||||
|
->will($this->returnValue($user));
|
||||||
|
|
||||||
$uid = 'alice';
|
$uid = 'alice';
|
||||||
$dn = 'uid=alice,dc=foo,dc=bar';
|
$dn = 'uid=alice,dc=foo,dc=bar';
|
||||||
|
@ -296,13 +300,15 @@ class Test_User_User extends \Test\TestCase {
|
||||||
$this->equalTo('myquota'))
|
$this->equalTo('myquota'))
|
||||||
->will($this->returnValue(array('27 GB')));
|
->will($this->returnValue(array('27 GB')));
|
||||||
|
|
||||||
$config->expects($this->once())
|
$user = $this->getMock('\OCP\IUser');
|
||||||
->method('setUserValue')
|
$user->expects($this->once())
|
||||||
->with($this->equalTo('alice'),
|
->method('setQuota')
|
||||||
$this->equalTo('files'),
|
->with('27 GB');
|
||||||
$this->equalTo('quota'),
|
|
||||||
$this->equalTo('27 GB'))
|
$userMgr->expects($this->once())
|
||||||
->will($this->returnValue(true));
|
->method('get')
|
||||||
|
->with('alice')
|
||||||
|
->will($this->returnValue($user));
|
||||||
|
|
||||||
$uid = 'alice';
|
$uid = 'alice';
|
||||||
$dn = 'uid=alice,dc=foo,dc=bar';
|
$dn = 'uid=alice,dc=foo,dc=bar';
|
||||||
|
@ -408,13 +414,15 @@ class Test_User_User extends \Test\TestCase {
|
||||||
$access->expects($this->never())
|
$access->expects($this->never())
|
||||||
->method('readAttribute');
|
->method('readAttribute');
|
||||||
|
|
||||||
$config->expects($this->once())
|
$user = $this->getMock('\OCP\IUser');
|
||||||
->method('setUserValue')
|
$user->expects($this->once())
|
||||||
->with($this->equalTo('alice'),
|
->method('setQuota')
|
||||||
$this->equalTo('files'),
|
->with($readQuota);
|
||||||
$this->equalTo('quota'),
|
|
||||||
$this->equalTo($readQuota))
|
$userMgr->expects($this->once())
|
||||||
->will($this->returnValue(true));
|
->method('get')
|
||||||
|
->with('alice')
|
||||||
|
->will($this->returnValue($user));
|
||||||
|
|
||||||
$uid = 'alice';
|
$uid = 'alice';
|
||||||
$dn = 'uid=alice,dc=foo,dc=bar';
|
$dn = 'uid=alice,dc=foo,dc=bar';
|
||||||
|
|
|
@ -121,7 +121,7 @@ class Avatar implements IAvatar {
|
||||||
|
|
||||||
$this->remove();
|
$this->remove();
|
||||||
$this->folder->newFile('avatar.'.$type)->putContent($data);
|
$this->folder->newFile('avatar.'.$type)->putContent($data);
|
||||||
$this->user->triggerChange();
|
$this->user->triggerChange('avatar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,7 +137,7 @@ class Avatar implements IAvatar {
|
||||||
$avatar->delete();
|
$avatar->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->user->triggerChange();
|
$this->user->triggerChange('avatar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -244,9 +244,9 @@ class Server extends ServerContainer implements IServerContainer {
|
||||||
$userSession->listen('\OC\User', 'logout', function () {
|
$userSession->listen('\OC\User', 'logout', function () {
|
||||||
\OC_Hook::emit('OC_User', 'logout', array());
|
\OC_Hook::emit('OC_User', 'logout', array());
|
||||||
});
|
});
|
||||||
$userSession->listen('\OC\User', 'changeUser', function ($user) {
|
$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
|
||||||
/** @var $user \OC\User\User */
|
/** @var $user \OC\User\User */
|
||||||
\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user));
|
\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
|
||||||
});
|
});
|
||||||
return $userSession;
|
return $userSession;
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
namespace OC\User;
|
namespace OC\User;
|
||||||
|
|
||||||
use OC\Hooks\Emitter;
|
use OC\Hooks\Emitter;
|
||||||
|
use OC_Helper;
|
||||||
use OCP\IAvatarManager;
|
use OCP\IAvatarManager;
|
||||||
use OCP\IImage;
|
use OCP\IImage;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
|
@ -140,7 +141,7 @@ class User implements IUser {
|
||||||
$result = $this->backend->setDisplayName($this->uid, $displayName);
|
$result = $this->backend->setDisplayName($this->uid, $displayName);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->displayName = $displayName;
|
$this->displayName = $displayName;
|
||||||
$this->triggerChange();
|
$this->triggerChange('displayName', $displayName);
|
||||||
}
|
}
|
||||||
return $result !== false;
|
return $result !== false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -161,7 +162,7 @@ class User implements IUser {
|
||||||
} else {
|
} else {
|
||||||
$this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress);
|
$this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress);
|
||||||
}
|
}
|
||||||
$this->triggerChange();
|
$this->triggerChange('eMailAddress', $mailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -338,6 +339,36 @@ class User implements IUser {
|
||||||
return $this->config->getUserValue($this->uid, 'settings', 'email', null);
|
return $this->config->getUserValue($this->uid, 'settings', 'email', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the users' quota
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 9.0.0
|
||||||
|
*/
|
||||||
|
public function getQuota() {
|
||||||
|
$quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default');
|
||||||
|
if($quota === 'default') {
|
||||||
|
$quota = $this->config->getAppValue('files', 'default_quota', 'none');
|
||||||
|
}
|
||||||
|
return $quota;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the users' quota
|
||||||
|
*
|
||||||
|
* @param string $quota
|
||||||
|
* @return void
|
||||||
|
* @since 9.0.0
|
||||||
|
*/
|
||||||
|
public function setQuota($quota) {
|
||||||
|
if($quota !== 'none' and $quota !== 'default') {
|
||||||
|
$quota = OC_Helper::computerFileSize($quota);
|
||||||
|
$quota = OC_Helper::humanFileSize($quota);
|
||||||
|
}
|
||||||
|
$this->config->setUserValue($this->uid, 'files', 'quota', $quota);
|
||||||
|
$this->triggerChange('quota', $quota);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the avatar image if it exists
|
* get the avatar image if it exists
|
||||||
*
|
*
|
||||||
|
@ -386,9 +417,9 @@ class User implements IUser {
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function triggerChange() {
|
public function triggerChange($feature, $value = null) {
|
||||||
if ($this->emitter) {
|
if ($this->emitter) {
|
||||||
$this->emitter->emit('\OC\User', 'changeUser', array($this));
|
$this->emitter->emit('\OC\User', 'changeUser', array($this, $feature, $value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,11 +285,7 @@ class OC_Util {
|
||||||
* @return int Quota bytes
|
* @return int Quota bytes
|
||||||
*/
|
*/
|
||||||
public static function getUserQuota($user) {
|
public static function getUserQuota($user) {
|
||||||
$config = \OC::$server->getConfig();
|
$userQuota = \OC::$server->getUserManager()->get($user)->getQuota();
|
||||||
$userQuota = $config->getUserValue($user, 'files', 'quota', 'default');
|
|
||||||
if ($userQuota === 'default') {
|
|
||||||
$userQuota = $config->getAppValue('files', 'default_quota', 'none');
|
|
||||||
}
|
|
||||||
if($userQuota === 'none') {
|
if($userQuota === 'none') {
|
||||||
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -178,4 +178,23 @@ interface IUser {
|
||||||
* @since 9.0.0
|
* @since 9.0.0
|
||||||
*/
|
*/
|
||||||
public function setEMailAddress($mailAddress);
|
public function setEMailAddress($mailAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the users' quota in human readable form. If a specific quota is not
|
||||||
|
* set for the user, the default value is returned. If a default setting
|
||||||
|
* was not set otherwise, it is return as 'none', i.e. quota is not limited.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 9.0.0
|
||||||
|
*/
|
||||||
|
public function getQuota();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the users' quota
|
||||||
|
*
|
||||||
|
* @param string $quota
|
||||||
|
* @return void
|
||||||
|
* @since 9.0.0
|
||||||
|
*/
|
||||||
|
public function setQuota($quota);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ if($quota !== 'none' and $quota !== 'default') {
|
||||||
|
|
||||||
// Return Success story
|
// Return Success story
|
||||||
if($username) {
|
if($username) {
|
||||||
\OC::$server->getConfig()->setUserValue($username, 'files', 'quota', $quota);
|
$targetUserObject->setQuota($quota);
|
||||||
}else{//set the default quota when no username is specified
|
}else{//set the default quota when no username is specified
|
||||||
if($quota === 'default') {//'default' as default quota makes no sense
|
if($quota === 'default') {//'default' as default quota makes no sense
|
||||||
$quota='none';
|
$quota='none';
|
||||||
|
|
|
@ -184,7 +184,7 @@ class UsersController extends Controller {
|
||||||
'displayname' => $user->getDisplayName(),
|
'displayname' => $user->getDisplayName(),
|
||||||
'groups' => (empty($userGroups)) ? $this->groupManager->getUserGroupIds($user) : $userGroups,
|
'groups' => (empty($userGroups)) ? $this->groupManager->getUserGroupIds($user) : $userGroups,
|
||||||
'subadmin' => $subAdminGroups,
|
'subadmin' => $subAdminGroups,
|
||||||
'quota' => $this->config->getUserValue($user->getUID(), 'files', 'quota', 'default'),
|
'quota' => $user->getQuota(),
|
||||||
'storageLocation' => $user->getHome(),
|
'storageLocation' => $user->getHome(),
|
||||||
'lastLogin' => $user->getLastLogin() * 1000,
|
'lastLogin' => $user->getLastLogin() * 1000,
|
||||||
'backend' => $user->getBackendClassName(),
|
'backend' => $user->getBackendClassName(),
|
||||||
|
|
|
@ -86,7 +86,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$foo = $this->getMockBuilder('\OC\User\User')
|
$foo = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$foo
|
$foo
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('foo'));
|
->will($this->returnValue('foo'));
|
||||||
$foo
|
$foo
|
||||||
|
@ -97,6 +97,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue('foo@bar.com'));
|
->will($this->returnValue('foo@bar.com'));
|
||||||
|
$foo
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('1024'));
|
||||||
$foo
|
$foo
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
->will($this->returnValue(500));
|
->will($this->returnValue(500));
|
||||||
|
@ -110,7 +114,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$admin = $this->getMockBuilder('\OC\User\User')
|
$admin = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$admin
|
$admin
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('admin'));
|
->will($this->returnValue('admin'));
|
||||||
$admin
|
$admin
|
||||||
|
@ -121,6 +125,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue('admin@bar.com'));
|
->will($this->returnValue('admin@bar.com'));
|
||||||
|
$admin
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('404'));
|
||||||
$admin
|
$admin
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
|
@ -136,7 +144,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$bar = $this->getMockBuilder('\OC\User\User')
|
$bar = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$bar
|
$bar
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('bar'));
|
->will($this->returnValue('bar'));
|
||||||
$bar
|
$bar
|
||||||
|
@ -147,6 +155,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue('bar@dummy.com'));
|
->will($this->returnValue('bar@dummy.com'));
|
||||||
|
$bar
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('2323'));
|
||||||
$bar
|
$bar
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
->will($this->returnValue(3999));
|
->will($this->returnValue(3999));
|
||||||
|
@ -182,12 +194,6 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->method('get')
|
->method('get')
|
||||||
->with('bar')
|
->with('bar')
|
||||||
->will($this->returnValue($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')
|
$subadmin = $this->getMockBuilder('\OC\SubAdmin')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
@ -272,7 +278,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$foo = $this->getMockBuilder('\OC\User\User')
|
$foo = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$foo
|
$foo
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('foo'));
|
->will($this->returnValue('foo'));
|
||||||
$foo
|
$foo
|
||||||
|
@ -283,6 +289,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue('foo@bar.com'));
|
->will($this->returnValue('foo@bar.com'));
|
||||||
|
$foo
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('1024'));
|
||||||
$foo
|
$foo
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
->will($this->returnValue(500));
|
->will($this->returnValue(500));
|
||||||
|
@ -296,7 +306,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$admin = $this->getMockBuilder('\OC\User\User')
|
$admin = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$admin
|
$admin
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('admin'));
|
->will($this->returnValue('admin'));
|
||||||
$admin
|
$admin
|
||||||
|
@ -307,6 +317,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue('admin@bar.com'));
|
->will($this->returnValue('admin@bar.com'));
|
||||||
|
$admin
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('404'));
|
||||||
$admin
|
$admin
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
|
@ -322,7 +336,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$bar = $this->getMockBuilder('\OC\User\User')
|
$bar = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$bar
|
$bar
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('bar'));
|
->will($this->returnValue('bar'));
|
||||||
$bar
|
$bar
|
||||||
|
@ -333,6 +347,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue('bar@dummy.com'));
|
->will($this->returnValue('bar@dummy.com'));
|
||||||
|
$bar
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('2323'));
|
||||||
$bar
|
$bar
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
->will($this->returnValue(3999));
|
->will($this->returnValue(3999));
|
||||||
|
@ -377,14 +395,6 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->method('get')
|
->method('get')
|
||||||
->with('admin')
|
->with('admin')
|
||||||
->will($this->returnValue($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')
|
$subgroup1 = $this->getMockBuilder('\OCP\IGroup')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
@ -472,7 +482,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$foo = $this->getMockBuilder('\OC\User\User')
|
$foo = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$foo
|
$foo
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('foo'));
|
->will($this->returnValue('foo'));
|
||||||
$foo
|
$foo
|
||||||
|
@ -483,6 +493,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue('foo@bar.com'));
|
->will($this->returnValue('foo@bar.com'));
|
||||||
|
$foo
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('1024'));
|
||||||
$foo
|
$foo
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
->will($this->returnValue(500));
|
->will($this->returnValue(500));
|
||||||
|
@ -496,7 +510,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$admin = $this->getMockBuilder('\OC\User\User')
|
$admin = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$admin
|
$admin
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('admin'));
|
->will($this->returnValue('admin'));
|
||||||
$admin
|
$admin
|
||||||
|
@ -507,6 +521,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue('admin@bar.com'));
|
->will($this->returnValue('admin@bar.com'));
|
||||||
|
$admin
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('404'));
|
||||||
$admin
|
$admin
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
|
@ -522,7 +540,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$bar = $this->getMockBuilder('\OC\User\User')
|
$bar = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$bar
|
$bar
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('bar'));
|
->will($this->returnValue('bar'));
|
||||||
$bar
|
$bar
|
||||||
|
@ -533,6 +551,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue('bar@dummy.com'));
|
->will($this->returnValue('bar@dummy.com'));
|
||||||
|
$bar
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('2323'));
|
||||||
$bar
|
$bar
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
->will($this->returnValue(3999));
|
->will($this->returnValue(3999));
|
||||||
|
@ -553,10 +575,6 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(3))
|
||||||
->method('getUserGroupIds')
|
->method('getUserGroupIds')
|
||||||
->will($this->onConsecutiveCalls(array('Users', 'Support'), array('admins', 'Support'), array('External Users')));
|
->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')
|
$subadmin = $this->getMockBuilder('\OC\SubAdmin')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
@ -622,7 +640,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$user = $this->getMockBuilder('\OC\User\User')
|
$user = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$user
|
$user
|
||||||
->expects($this->exactly(3))
|
->expects($this->exactly(2))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('foo'));
|
->will($this->returnValue('foo'));
|
||||||
$user
|
$user
|
||||||
|
@ -633,6 +651,10 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getEMailAddress')
|
->method('getEMailAddress')
|
||||||
->will($this->returnValue(null));
|
->will($this->returnValue(null));
|
||||||
|
$user
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getQuota')
|
||||||
|
->will($this->returnValue('none'));
|
||||||
$user
|
$user
|
||||||
->method('getLastLogin')
|
->method('getLastLogin')
|
||||||
->will($this->returnValue(500));
|
->will($this->returnValue(500));
|
||||||
|
@ -674,7 +696,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
'displayname' => 'M. Foo',
|
'displayname' => 'M. Foo',
|
||||||
'groups' => null,
|
'groups' => null,
|
||||||
'subadmin' => array(),
|
'subadmin' => array(),
|
||||||
'quota' => null,
|
'quota' => 'none',
|
||||||
'storageLocation' => '/home/foo',
|
'storageLocation' => '/home/foo',
|
||||||
'lastLogin' => 500000,
|
'lastLogin' => 500000,
|
||||||
'backend' => 'OC_User_Database',
|
'backend' => 'OC_User_Database',
|
||||||
|
|
Loading…
Reference in New Issue