Update unit tests
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
96e1daba33
commit
f2b8535c7e
1 changed files with 68 additions and 12 deletions
|
@ -19,6 +19,7 @@ use OCP\AppFramework\Http;
|
|||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\Files\Config\IUserMountCache;
|
||||
use OCP\IAvatar;
|
||||
use OCP\IAvatarManager;
|
||||
use OCP\IConfig;
|
||||
|
@ -79,6 +80,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
private $jobList;
|
||||
/** @var \OC\Security\IdentityProof\Manager |\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $securityManager;
|
||||
/** @var IUserMountCache |\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $userMountCache;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
@ -106,6 +109,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->will($this->returnCallback(function ($text, $parameters = []) {
|
||||
return vsprintf($text, $parameters);
|
||||
}));
|
||||
$this->userMountCache = $this->createMock(IUserMountCache::class);
|
||||
|
||||
/*
|
||||
* Set default avatar behaviour for whole test suite
|
||||
|
@ -149,7 +153,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$this->timeFactory,
|
||||
$this->crypto,
|
||||
$this->securityManager,
|
||||
$this->jobList
|
||||
$this->jobList,
|
||||
$this->userMountCache
|
||||
|
||||
);
|
||||
} else {
|
||||
|
@ -175,7 +180,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$this->timeFactory,
|
||||
$this->crypto,
|
||||
$this->securityManager,
|
||||
$this->jobList
|
||||
$this->jobList,
|
||||
$this->userMountCache,
|
||||
]
|
||||
)->setMethods($mockedMethods)->getMock();
|
||||
}
|
||||
|
@ -198,7 +204,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue('foo@bar.com'));
|
||||
$foo
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('1024'));
|
||||
$foo
|
||||
|
@ -228,7 +234,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue('admin@bar.com'));
|
||||
$admin
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('404'));
|
||||
$admin
|
||||
|
@ -260,7 +266,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue('bar@dummy.com'));
|
||||
$bar
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('2323'));
|
||||
$bar
|
||||
|
@ -331,6 +337,11 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getSubAdmin')
|
||||
->will($this->returnValue($subadmin));
|
||||
|
||||
$this->userMountCache
|
||||
->expects($this->once())
|
||||
->method('getUsedSpaceForUsers')
|
||||
->will($this->returnValue(['admin' => 200, 'bar' => 2000, 'foo' => 512]));
|
||||
|
||||
$expectedResponse = new DataResponse(
|
||||
array(
|
||||
0 => array(
|
||||
|
@ -339,6 +350,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => array('Users', 'Support'),
|
||||
'subadmin' => array(),
|
||||
'quota' => 1024,
|
||||
'quota_bytes' => 1024,
|
||||
'storageLocation' => '/home/foo',
|
||||
'lastLogin' => 500000,
|
||||
'backend' => 'OC_User_Database',
|
||||
|
@ -346,6 +358,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => true,
|
||||
'size' => 512,
|
||||
),
|
||||
1 => array(
|
||||
'name' => 'admin',
|
||||
|
@ -353,6 +366,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => array('admins', 'Support'),
|
||||
'subadmin' => array(),
|
||||
'quota' => 404,
|
||||
'quota_bytes' => 404,
|
||||
'storageLocation' => '/home/admin',
|
||||
'lastLogin' => 12000,
|
||||
'backend' => Dummy::class,
|
||||
|
@ -360,6 +374,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => false,
|
||||
'isEnabled' => true,
|
||||
'size' => 200,
|
||||
),
|
||||
2 => array(
|
||||
'name' => 'bar',
|
||||
|
@ -367,6 +382,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => array('External Users'),
|
||||
'subadmin' => array(),
|
||||
'quota' => 2323,
|
||||
'quota_bytes' => 2323,
|
||||
'storageLocation' => '/home/bar',
|
||||
'lastLogin' => 3999000,
|
||||
'backend' => Dummy::class,
|
||||
|
@ -374,6 +390,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => false,
|
||||
'size' => 2000,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
@ -404,7 +421,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue('foo@bar.com'));
|
||||
$foo
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('1024'));
|
||||
$foo
|
||||
|
@ -434,7 +451,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue('admin@bar.com'));
|
||||
$admin
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('404'));
|
||||
$admin
|
||||
|
@ -466,7 +483,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue('bar@dummy.com'));
|
||||
$bar
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('2323'));
|
||||
$bar
|
||||
|
@ -545,6 +562,11 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getSubAdmin')
|
||||
->will($this->returnValue($subadmin));
|
||||
|
||||
$this->userMountCache
|
||||
->expects($this->once())
|
||||
->method('getUsedSpaceForUsers')
|
||||
->will($this->returnValue(['admin' => 200, 'bar' => 2000, 'foo' => 512]));
|
||||
|
||||
$expectedResponse = new DataResponse(
|
||||
[
|
||||
0 => [
|
||||
|
@ -553,6 +575,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => ['SubGroup1'],
|
||||
'subadmin' => [],
|
||||
'quota' => 2323,
|
||||
'quota_bytes' => 2323,
|
||||
'storageLocation' => '/home/bar',
|
||||
'lastLogin' => 3999000,
|
||||
'backend' => Dummy::class,
|
||||
|
@ -560,6 +583,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => true,
|
||||
'size' => 2000,
|
||||
],
|
||||
1=> [
|
||||
'name' => 'foo',
|
||||
|
@ -567,6 +591,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => ['SubGroup2', 'SubGroup1'],
|
||||
'subadmin' => [],
|
||||
'quota' => 1024,
|
||||
'quota_bytes' => 1024,
|
||||
'storageLocation' => '/home/foo',
|
||||
'lastLogin' => 500000,
|
||||
'backend' => 'OC_User_Database',
|
||||
|
@ -574,6 +599,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => true,
|
||||
'size' => 512,
|
||||
],
|
||||
2 => [
|
||||
'name' => 'admin',
|
||||
|
@ -581,6 +607,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => ['SubGroup2'],
|
||||
'subadmin' => [],
|
||||
'quota' => 404,
|
||||
'quota_bytes' => 404,
|
||||
'storageLocation' => '/home/admin',
|
||||
'lastLogin' => 12000,
|
||||
'backend' => Dummy::class,
|
||||
|
@ -588,6 +615,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => false,
|
||||
'isEnabled' => true,
|
||||
'size' => 200,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
@ -617,7 +645,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue('foo@bar.com'));
|
||||
$foo
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('1024'));
|
||||
$foo
|
||||
|
@ -647,7 +675,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue('admin@bar.com'));
|
||||
$admin
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('404'));
|
||||
$admin
|
||||
|
@ -679,7 +707,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue('bar@dummy.com'));
|
||||
$bar
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('2323'));
|
||||
$bar
|
||||
|
@ -717,6 +745,11 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getSubAdmin')
|
||||
->will($this->returnValue($subadmin));
|
||||
|
||||
$this->userMountCache
|
||||
->expects($this->once())
|
||||
->method('getUsedSpaceForUsers')
|
||||
->will($this->returnValue(['admin' => 200, 'bar' => 2000, 'foo' => 512]));
|
||||
|
||||
$expectedResponse = new DataResponse(
|
||||
array(
|
||||
0 => array(
|
||||
|
@ -725,6 +758,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => array('Users', 'Support'),
|
||||
'subadmin' => array(),
|
||||
'quota' => 1024,
|
||||
'quota_bytes' => 1024,
|
||||
'storageLocation' => '/home/foo',
|
||||
'lastLogin' => 500000,
|
||||
'backend' => 'OC_User_Database',
|
||||
|
@ -732,6 +766,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => true,
|
||||
'size' => 512,
|
||||
),
|
||||
1 => array(
|
||||
'name' => 'admin',
|
||||
|
@ -739,6 +774,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => array('admins', 'Support'),
|
||||
'subadmin' => array(),
|
||||
'quota' => 404,
|
||||
'quota_bytes' => 404,
|
||||
'storageLocation' => '/home/admin',
|
||||
'lastLogin' => 12000,
|
||||
'backend' => Dummy::class,
|
||||
|
@ -746,6 +782,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => false,
|
||||
'isEnabled' => true,
|
||||
'size' => 200,
|
||||
),
|
||||
2 => array(
|
||||
'name' => 'bar',
|
||||
|
@ -753,6 +790,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => array('External Users'),
|
||||
'subadmin' => array(),
|
||||
'quota' => 2323,
|
||||
'quota_bytes' => 2323,
|
||||
'storageLocation' => '/home/bar',
|
||||
'lastLogin' => 3999000,
|
||||
'backend' => Dummy::class,
|
||||
|
@ -760,6 +798,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => true,
|
||||
'size' => 2000,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
@ -784,7 +823,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getEMailAddress')
|
||||
->will($this->returnValue(null));
|
||||
$user
|
||||
->expects($this->once())
|
||||
->expects($this->exactly(2))
|
||||
->method('getQuota')
|
||||
->will($this->returnValue('none'));
|
||||
$user
|
||||
|
@ -825,6 +864,11 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->method('getSubAdmin')
|
||||
->will($this->returnValue($subadmin));
|
||||
|
||||
$this->userMountCache
|
||||
->expects($this->once())
|
||||
->method('getUsedSpaceForUsers')
|
||||
->will($this->returnValue(['foo' => 512]));
|
||||
|
||||
$expectedResponse = new DataResponse(
|
||||
array(
|
||||
0 => array(
|
||||
|
@ -833,6 +877,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'groups' => null,
|
||||
'subadmin' => array(),
|
||||
'quota' => 'none',
|
||||
'quota_bytes' => 0,
|
||||
'storageLocation' => '/home/foo',
|
||||
'lastLogin' => 500000,
|
||||
'backend' => 'OC_User_Database',
|
||||
|
@ -840,6 +885,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => true,
|
||||
'size' => 512,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -860,6 +906,11 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->with('')
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$this->userMountCache
|
||||
->expects($this->once())
|
||||
->method('getUsedSpaceForUsers')
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$expectedResponse = new DataResponse([]);
|
||||
$response = $controller->index(0, 10, '','', Dummy::class);
|
||||
$this->assertEquals($expectedResponse, $response);
|
||||
|
@ -915,6 +966,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => true,
|
||||
'quota_bytes' => false,
|
||||
),
|
||||
Http::STATUS_CREATED
|
||||
);
|
||||
|
@ -1001,6 +1053,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => true,
|
||||
'quota_bytes' => false,
|
||||
),
|
||||
Http::STATUS_CREATED
|
||||
);
|
||||
|
@ -1093,6 +1146,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => true,
|
||||
'quota_bytes' => false,
|
||||
),
|
||||
Http::STATUS_CREATED
|
||||
);
|
||||
|
@ -1560,6 +1614,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'isRestoreDisabled' => false,
|
||||
'isAvatarAvailable' => true,
|
||||
'isEnabled' => $enabled,
|
||||
'quota_bytes' => false,
|
||||
];
|
||||
|
||||
return [$user, $result];
|
||||
|
@ -2393,6 +2448,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'lastLogin' => 0,
|
||||
'displayname' => 'John Doe',
|
||||
'quota' => null,
|
||||
'quota_bytes' => false,
|
||||
'subadmin' => array(),
|
||||
'email' => 'abc@example.org',
|
||||
'isRestoreDisabled' => false,
|
||||
|
|
Loading…
Reference in a new issue