aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-25 22:21:27 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-25 22:21:27 +0100
commit2ee65f177e4f7e09ad2287f14d564e7068d322fb (patch)
tree39075e87ea7927e20e8956824cb7c49bf626b178 /apps/files_external
parent3cf321fdfc4235a87015a9af2f59c63220016c65 (diff)
downloadnextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.tar.gz
nextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.zip
Use the shorter phpunit syntax for mocked return values
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/tests/Auth/Password/GlobalAuth.php20
-rw-r--r--apps/files_external/tests/Command/ApplicableTest.php4
-rw-r--r--apps/files_external/tests/Command/CommandTest.php4
-rw-r--r--apps/files_external/tests/Controller/StoragesControllerTest.php20
-rw-r--r--apps/files_external/tests/Controller/UserStoragesControllerTest.php2
-rw-r--r--apps/files_external/tests/FrontendDefinitionTraitTest.php4
-rw-r--r--apps/files_external/tests/PersonalMountTest.php2
-rw-r--r--apps/files_external/tests/Service/BackendServiceTest.php18
-rw-r--r--apps/files_external/tests/Service/StoragesServiceTest.php20
-rw-r--r--apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php10
-rw-r--r--apps/files_external/tests/Service/UserStoragesServiceTest.php2
11 files changed, 53 insertions, 53 deletions
diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuth.php
index bcfcaedbac1..88569c9cac9 100644
--- a/apps/files_external/tests/Auth/Password/GlobalAuth.php
+++ b/apps/files_external/tests/Auth/Password/GlobalAuth.php
@@ -57,22 +57,22 @@ class GlobalAuthTest extends TestCase {
$storageConfig = $this->createMock(StorageConfig::class);
$storageConfig->expects($this->any())
->method('getType')
- ->will($this->returnValue($type));
+ ->willReturn($type);
$storageConfig->expects($this->any())
->method('getBackendOptions')
- ->will($this->returnCallback(function () use (&$config) {
+ ->willReturnCallback(function () use (&$config) {
return $config;
- }));
+ });
$storageConfig->expects($this->any())
->method('getBackendOption')
- ->will($this->returnCallback(function ($key) use (&$config) {
+ ->willReturnCallback(function ($key) use (&$config) {
return $config[$key];
- }));
+ });
$storageConfig->expects($this->any())
->method('setBackendOption')
- ->will($this->returnCallback(function ($key, $value) use (&$config) {
+ ->willReturnCallback(function ($key, $value) use (&$config) {
$config[$key] = $value;
- }));
+ });
return $storageConfig;
}
@@ -80,7 +80,7 @@ class GlobalAuthTest extends TestCase {
public function testNoCredentials() {
$this->credentialsManager->expects($this->once())
->method('retrieve')
- ->will($this->returnValue(null));
+ ->willReturn(null);
$storage = $this->getStorageConfig(StorageConfig::MOUNT_TYPE_ADMIN);
@@ -91,10 +91,10 @@ class GlobalAuthTest extends TestCase {
public function testSavedCredentials() {
$this->credentialsManager->expects($this->once())
->method('retrieve')
- ->will($this->returnValue([
+ ->willReturn([
'user' => 'a',
'password' => 'b'
- ]));
+ ]);
$storage = $this->getStorageConfig(StorageConfig::MOUNT_TYPE_ADMIN);
diff --git a/apps/files_external/tests/Command/ApplicableTest.php b/apps/files_external/tests/Command/ApplicableTest.php
index 3b889ceaa78..49fae6e0013 100644
--- a/apps/files_external/tests/Command/ApplicableTest.php
+++ b/apps/files_external/tests/Command/ApplicableTest.php
@@ -36,11 +36,11 @@ class ApplicableTest extends CommandTest {
$userManager->expects($this->any())
->method('userExists')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$groupManager->expects($this->any())
->method('groupExists')
- ->will($this->returnValue(true));
+ ->willReturn(true);
return new Applicable($storageService, $userManager, $groupManager);
}
diff --git a/apps/files_external/tests/Command/CommandTest.php b/apps/files_external/tests/Command/CommandTest.php
index 39688a2e321..2e7e377c28e 100644
--- a/apps/files_external/tests/Command/CommandTest.php
+++ b/apps/files_external/tests/Command/CommandTest.php
@@ -53,14 +53,14 @@ abstract class CommandTest extends TestCase {
protected function bindMounts(\PHPUnit_Framework_MockObject_MockObject $mock, array $mounts) {
$mock->expects($this->any())
->method('getStorage')
- ->will($this->returnCallback(function ($id) use ($mounts) {
+ ->willReturnCallback(function ($id) use ($mounts) {
foreach ($mounts as $mount) {
if ($mount->getId() === $id) {
return $mount;
}
}
throw new NotFoundException();
- }));
+ });
}
/**
diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php
index 7dee96e3412..3ecf47419b5 100644
--- a/apps/files_external/tests/Controller/StoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/StoragesControllerTest.php
@@ -108,10 +108,10 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->once())
->method('addStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$response = $this->controller->create(
'mount',
@@ -149,10 +149,10 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->once())
->method('updateStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$response = $this->controller->update(
1,
@@ -191,7 +191,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->exactly(2))
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->never())
->method('addStorage');
$this->service->expects($this->never())
@@ -282,7 +282,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->once())
->method('updateStorage')
->will($this->throwException(new NotFoundException()));
@@ -332,7 +332,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('getStorage')
->with(1)
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$response = $this->controller->show(1);
$this->assertEquals(Http::STATUS_OK, $response->getStatus());
@@ -360,7 +360,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
- ->will($this->returnValue($authMechValidate));
+ ->willReturn($authMechValidate);
$authMech->method('isVisibleFor')
->willReturn(true);
@@ -372,13 +372,13 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->service->expects($this->once())
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
if ($expectSuccess) {
$this->service->expects($this->once())
->method('addStorage')
->with($storageConfig)
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
} else {
$this->service->expects($this->never())
->method('addStorage');
diff --git a/apps/files_external/tests/Controller/UserStoragesControllerTest.php b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
index 920bb72ab70..7d8f60380c6 100644
--- a/apps/files_external/tests/Controller/UserStoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
@@ -76,7 +76,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
$this->service->expects($this->exactly(2))
->method('createStorage')
- ->will($this->returnValue($storageConfig));
+ ->willReturn($storageConfig);
$this->service->expects($this->never())
->method('addStorage');
$this->service->expects($this->never())
diff --git a/apps/files_external/tests/FrontendDefinitionTraitTest.php b/apps/files_external/tests/FrontendDefinitionTraitTest.php
index 76a8ab326f0..e6a62991f36 100644
--- a/apps/files_external/tests/FrontendDefinitionTraitTest.php
+++ b/apps/files_external/tests/FrontendDefinitionTraitTest.php
@@ -101,10 +101,10 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
->willReturn('param');
$param->expects($this->once())
->method('validateValue')
- ->will($this->returnCallback(function(&$value) {
+ ->willReturnCallback(function(&$value) {
$value = 'foobar';
return true;
- }));
+ });
$storageConfig = $this->getMockBuilder(StorageConfig::class)
->disableOriginalConstructor()
diff --git a/apps/files_external/tests/PersonalMountTest.php b/apps/files_external/tests/PersonalMountTest.php
index 09862257ecb..621894138f4 100644
--- a/apps/files_external/tests/PersonalMountTest.php
+++ b/apps/files_external/tests/PersonalMountTest.php
@@ -40,7 +40,7 @@ class PersonalMountTest extends TestCase {
$storage->expects($this->any())
->method('getId')
- ->will($this->returnValue('dummy'));
+ ->willReturn('dummy');
$mount = new PersonalMount($storageService, 10, $storage, '/foo');
diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php
index bb65d9a6de6..2191060444a 100644
--- a/apps/files_external/tests/Service/BackendServiceTest.php
+++ b/apps/files_external/tests/Service/BackendServiceTest.php
@@ -51,8 +51,8 @@ class BackendServiceTest extends \Test\TestCase {
$backend = $this->getMockBuilder(Backend::class)
->disableOriginalConstructor()
->getMock();
- $backend->method('getIdentifier')->will($this->returnValue('identifier:'.$class));
- $backend->method('getIdentifierAliases')->will($this->returnValue(['identifier:'.$class]));
+ $backend->method('getIdentifier')->willReturn('identifier:'.$class);
+ $backend->method('getIdentifierAliases')->willReturn(['identifier:'.$class]);
return $backend;
}
@@ -65,8 +65,8 @@ class BackendServiceTest extends \Test\TestCase {
$backend = $this->getMockBuilder(AuthMechanism::class)
->disableOriginalConstructor()
->getMock();
- $backend->method('getIdentifier')->will($this->returnValue('identifier:'.$class));
- $backend->method('getIdentifierAliases')->will($this->returnValue(['identifier:'.$class]));
+ $backend->method('getIdentifier')->willReturn('identifier:'.$class);
+ $backend->method('getIdentifierAliases')->willReturn(['identifier:'.$class]);
return $backend;
}
@@ -167,10 +167,10 @@ class BackendServiceTest extends \Test\TestCase {
public function testUserMountingBackends() {
$this->config->expects($this->exactly(2))
->method('getAppValue')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['files_external', 'allow_user_mounting', 'yes', 'yes'],
['files_external', 'user_mounting_backends', '', 'identifier:\User\Mount\Allowed,identifier_alias']
- ]));
+ ]);
$service = new BackendService($this->config);
@@ -201,15 +201,15 @@ class BackendServiceTest extends \Test\TestCase {
$backendAvailable = $this->getBackendMock('\Backend\Available');
$backendAvailable->expects($this->once())
->method('checkDependencies')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$backendNotAvailable = $this->getBackendMock('\Backend\NotAvailable');
$backendNotAvailable->expects($this->once())
->method('checkDependencies')
- ->will($this->returnValue([
+ ->willReturn([
$this->getMockBuilder('\OCA\Files_External\Lib\MissingDependency')
->disableOriginalConstructor()
->getMock()
- ]));
+ ]);
$service->registerBackend($backendAvailable);
$service->registerBackend($backendNotAvailable);
diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php
index a598739b97e..9d3a44042e0 100644
--- a/apps/files_external/tests/Service/StoragesServiceTest.php
+++ b/apps/files_external/tests/Service/StoragesServiceTest.php
@@ -117,20 +117,20 @@ abstract class StoragesServiceTest extends \Test\TestCase {
'identifier:\OCA\Files_External\Lib\Auth\NullMechanism' => $this->getAuthMechMock(),
];
$this->backendService->method('getAuthMechanism')
- ->will($this->returnCallback(function ($class) use ($authMechanisms) {
+ ->willReturnCallback(function ($class) use ($authMechanisms) {
if (isset($authMechanisms[$class])) {
return $authMechanisms[$class];
}
return null;
- }));
+ });
$this->backendService->method('getAuthMechanismsByScheme')
- ->will($this->returnCallback(function ($schemes) use ($authMechanisms) {
+ ->willReturnCallback(function ($schemes) use ($authMechanisms) {
return array_filter($authMechanisms, function ($authMech) use ($schemes) {
return in_array($authMech->getScheme(), $schemes, true);
});
- }));
+ });
$this->backendService->method('getAuthMechanisms')
- ->will($this->returnValue($authMechanisms));
+ ->willReturn($authMechanisms);
$sftpBackend = $this->getBackendMock('\OCA\Files_External\Lib\Backend\SFTP', '\OCA\Files_External\Lib\Storage\SFTP');
$backends = [
@@ -142,14 +142,14 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$backends['identifier:\OCA\Files_External\Lib\Backend\SFTP']->method('getLegacyAuthMechanism')
->willReturn($authMechanisms['identifier:\Other\Auth\Mechanism']);
$this->backendService->method('getBackend')
- ->will($this->returnCallback(function ($backendClass) use ($backends) {
+ ->willReturnCallback(function ($backendClass) use ($backends) {
if (isset($backends[$backendClass])) {
return $backends[$backendClass];
}
return null;
- }));
+ });
$this->backendService->method('getBackends')
- ->will($this->returnValue($backends));
+ ->willReturn($backends);
\OCP\Util::connectHook(
Filesystem::CLASSNAME,
@@ -162,11 +162,11 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$containerMock = $this->createMock(IAppContainer::class);
$containerMock->method('query')
- ->will($this->returnCallback(function ($name) {
+ ->willReturnCallback(function ($name) {
if ($name === 'OCA\Files_External\Service\BackendService') {
return $this->backendService;
}
- }));
+ });
\OC_Mount_Config::$app = $this->getMockBuilder('\OCA\Files_External\Appinfo\Application')
->disableOriginalConstructor()
diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
index ef8dc8a250e..ebdc2e01d52 100644
--- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
@@ -71,11 +71,11 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
$userSession
->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->groupManager->method('isInGroup')
- ->will($this->returnCallback(function ($userId, $groupId) {
+ ->willReturnCallback(function ($userId, $groupId) {
if ($userId === self::USER_ID) {
switch ($groupId) {
case self::GROUP_ID:
@@ -84,15 +84,15 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
}
}
return false;
- }));
+ });
$this->groupManager->method('getUserGroupIds')
- ->will($this->returnCallback(function (IUser $user) {
+ ->willReturnCallback(function (IUser $user) {
if ($user->getUID() === self::USER_ID) {
return [self::GROUP_ID, self::GROUP_ID2];
} else {
return [];
}
- }));
+ });
$this->service = new UserGlobalStoragesService(
$this->backendService,
diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php
index 62f9f6b9d6c..cc000c28a80 100644
--- a/apps/files_external/tests/Service/UserStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php
@@ -64,7 +64,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
$userSession
->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->service = new UserStoragesService($this->backendService, $this->dbConfig, $userSession, $this->mountCache);
}