aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r--apps/files_external/tests/Backend/LegacyBackendTest.php4
-rw-r--r--apps/files_external/tests/DefinitionParameterTest.php11
-rw-r--r--apps/files_external/tests/Service/BackendServiceTest.php38
3 files changed, 25 insertions, 28 deletions
diff --git a/apps/files_external/tests/Backend/LegacyBackendTest.php b/apps/files_external/tests/Backend/LegacyBackendTest.php
index 303700c6611..cea46c1a0cd 100644
--- a/apps/files_external/tests/Backend/LegacyBackendTest.php
+++ b/apps/files_external/tests/Backend/LegacyBackendTest.php
@@ -32,7 +32,6 @@ class LegacyBackendTest extends \Test\TestCase {
'textfield' => 'Text field',
'passwordfield' => '*Password field',
'checkbox' => '!Checkbox',
- 'hiddenfield' => '#Hidden field',
'optionaltext' => '&Optional text field',
'optionalpassword' => '&*Optional password field',
],
@@ -66,9 +65,6 @@ class LegacyBackendTest extends \Test\TestCase {
$this->assertEquals('Checkbox', $parameters['checkbox']->getText());
$this->assertEquals(DefinitionParameter::VALUE_BOOLEAN, $parameters['checkbox']->getType());
$this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['checkbox']->getFlags());
- $this->assertEquals('Hidden field', $parameters['hiddenfield']->getText());
- $this->assertEquals(DefinitionParameter::VALUE_HIDDEN, $parameters['hiddenfield']->getType());
- $this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['hiddenfield']->getFlags());
$this->assertEquals('Optional text field', $parameters['optionaltext']->getText());
$this->assertEquals(DefinitionParameter::VALUE_TEXT, $parameters['optionaltext']->getType());
$this->assertEquals(DefinitionParameter::FLAG_OPTIONAL, $parameters['optionaltext']->getFlags());
diff --git a/apps/files_external/tests/DefinitionParameterTest.php b/apps/files_external/tests/DefinitionParameterTest.php
index 0b1d11bbf0c..3fc65eaf897 100644
--- a/apps/files_external/tests/DefinitionParameterTest.php
+++ b/apps/files_external/tests/DefinitionParameterTest.php
@@ -38,12 +38,12 @@ class DefinitionParameterTest extends \Test\TestCase {
'tooltip' => '',
], $param->jsonSerialize());
- $param->setType(Param::VALUE_HIDDEN);
- $param->setFlags(Param::FLAG_NONE);
+ $param->setType(Param::VALUE_TEXT);
+ $param->setFlags(Param::FLAG_HIDDEN);
$this->assertEquals([
'value' => 'bar',
- 'flags' => Param::FLAG_NONE,
- 'type' => Param::VALUE_HIDDEN,
+ 'flags' => Param::FLAG_HIDDEN,
+ 'type' => Param::VALUE_TEXT,
'tooltip' => '',
], $param->jsonSerialize());
}
@@ -53,6 +53,7 @@ class DefinitionParameterTest extends \Test\TestCase {
[Param::VALUE_TEXT, Param::FLAG_NONE, 'abc', true],
[Param::VALUE_TEXT, Param::FLAG_NONE, '', false],
[Param::VALUE_TEXT, Param::FLAG_OPTIONAL, '', true],
+ [Param::VALUE_TEXT, Param::FLAG_HIDDEN, '', false],
[Param::VALUE_BOOLEAN, Param::FLAG_NONE, false, true],
[Param::VALUE_BOOLEAN, Param::FLAG_NONE, 123, false],
@@ -62,8 +63,6 @@ class DefinitionParameterTest extends \Test\TestCase {
[Param::VALUE_PASSWORD, Param::FLAG_NONE, 'foobar', true],
[Param::VALUE_PASSWORD, Param::FLAG_NONE, '', false],
-
- [Param::VALUE_HIDDEN, Param::FLAG_NONE, '', false]
];
}
diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php
index e7644d8e523..c3a77d81b67 100644
--- a/apps/files_external/tests/Service/BackendServiceTest.php
+++ b/apps/files_external/tests/Service/BackendServiceTest.php
@@ -12,15 +12,15 @@ use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
use OCA\Files_External\Lib\Config\IBackendProvider;
use OCA\Files_External\Service\BackendService;
-use OCP\IConfig;
+use OCP\IAppConfig;
class BackendServiceTest extends \Test\TestCase {
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
- protected $config;
+ /** @var IAppConfig|\PHPUnit\Framework\MockObject\MockObject */
+ protected $appConfig;
protected function setUp(): void {
- $this->config = $this->createMock(IConfig::class);
+ $this->appConfig = $this->createMock(IAppConfig::class);
}
/**
@@ -52,7 +52,7 @@ class BackendServiceTest extends \Test\TestCase {
}
public function testRegisterBackend(): void {
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$backend = $this->getBackendMock('\Foo\Bar');
@@ -80,7 +80,7 @@ class BackendServiceTest extends \Test\TestCase {
}
public function testBackendProvider(): void {
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$backend1 = $this->getBackendMock('\Foo\Bar');
$backend2 = $this->getBackendMock('\Bar\Foo');
@@ -99,7 +99,7 @@ class BackendServiceTest extends \Test\TestCase {
}
public function testAuthMechanismProvider(): void {
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$backend1 = $this->getAuthMechanismMock('\Foo\Bar');
$backend2 = $this->getAuthMechanismMock('\Bar\Foo');
@@ -118,7 +118,7 @@ class BackendServiceTest extends \Test\TestCase {
}
public function testMultipleBackendProviders(): void {
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$backend1a = $this->getBackendMock('\Foo\Bar');
$backend1b = $this->getBackendMock('\Bar\Foo');
@@ -146,14 +146,16 @@ class BackendServiceTest extends \Test\TestCase {
}
public function testUserMountingBackends(): void {
- $this->config->expects($this->exactly(2))
- ->method('getAppValue')
- ->willReturnMap([
- ['files_external', 'allow_user_mounting', 'yes', 'yes'],
- ['files_external', 'user_mounting_backends', '', 'identifier:\User\Mount\Allowed,identifier_alias']
- ]);
+ $this->appConfig->expects($this->once())
+ ->method('getValueString')
+ ->with('files_external', 'user_mounting_backends')
+ ->willReturn('identifier:\User\Mount\Allowed,identifier_alias');
+ $this->appConfig->expects($this->once())
+ ->method('getValueBool')
+ ->with('files_external', 'allow_user_mounting')
+ ->willReturn(true);
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$backendAllowed = $this->getBackendMock('\User\Mount\Allowed');
$backendAllowed->expects($this->never())
@@ -177,7 +179,7 @@ class BackendServiceTest extends \Test\TestCase {
}
public function testGetAvailableBackends(): void {
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$backendAvailable = $this->getBackendMock('\Backend\Available');
$backendAvailable->expects($this->once())
@@ -220,7 +222,7 @@ class BackendServiceTest extends \Test\TestCase {
public function testRegisterConfigHandlerInvalid(array $placeholders): void {
$this->expectException(\RuntimeException::class);
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$mock = $this->createMock(IConfigHandler::class);
$cb = function () use ($mock) {
return $mock;
@@ -231,7 +233,7 @@ class BackendServiceTest extends \Test\TestCase {
}
public function testConfigHandlers(): void {
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$mock = $this->createMock(IConfigHandler::class);
$mock->expects($this->exactly(3))
->method('handle');