summaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@owncloud.com>2015-08-20 12:23:12 +0100
committerRobin McCorkell <rmccorkell@owncloud.com>2015-08-20 12:23:12 +0100
commit643e3a5b6db19b9ba0210fef89f6ee163bc0edef (patch)
tree1406164f94b09de42e8508e99d081bb9563fd2a9 /apps/files_external/tests
parent62d328525a264015ba1f7035aed2e75de69f5cdd (diff)
downloadnextcloud-server-643e3a5b6db19b9ba0210fef89f6ee163bc0edef.tar.gz
nextcloud-server-643e3a5b6db19b9ba0210fef89f6ee163bc0edef.zip
Convert string booleans to real booleans
Legacy compatibility, from the days in stable8 when checkbox boolean values were stored as the strings 'true' and 'false'.
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r--apps/files_external/tests/definitionparameterttest.php8
-rw-r--r--apps/files_external/tests/frontenddefinitiontraittest.php39
-rw-r--r--apps/files_external/tests/service/globalstoragesservicetest.php7
3 files changed, 50 insertions, 4 deletions
diff --git a/apps/files_external/tests/definitionparameterttest.php b/apps/files_external/tests/definitionparameterttest.php
index 6be00508698..22e0b842254 100644
--- a/apps/files_external/tests/definitionparameterttest.php
+++ b/apps/files_external/tests/definitionparameterttest.php
@@ -49,6 +49,9 @@ class DefinitionParameterTest extends \Test\TestCase {
[Param::VALUE_BOOLEAN, Param::FLAG_NONE, false, true],
[Param::VALUE_BOOLEAN, Param::FLAG_NONE, 123, false],
+ // conversion from string to boolean
+ [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'false', true, false],
+ [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'true', true, true],
[Param::VALUE_PASSWORD, Param::FLAG_NONE, 'foobar', true],
[Param::VALUE_PASSWORD, Param::FLAG_NONE, '', false],
@@ -60,11 +63,14 @@ class DefinitionParameterTest extends \Test\TestCase {
/**
* @dataProvider validateValueProvider
*/
- public function testValidateValue($type, $flags, $value, $success) {
+ public function testValidateValue($type, $flags, $value, $success, $expectedValue = null) {
$param = new Param('foo', 'bar');
$param->setType($type);
$param->setFlags($flags);
$this->assertEquals($success, $param->validateValue($value));
+ if (isset($expectedValue)) {
+ $this->assertEquals($expectedValue, $value);
+ }
}
}
diff --git a/apps/files_external/tests/frontenddefinitiontraittest.php b/apps/files_external/tests/frontenddefinitiontraittest.php
index 871a87d4c52..d92d02b9854 100644
--- a/apps/files_external/tests/frontenddefinitiontraittest.php
+++ b/apps/files_external/tests/frontenddefinitiontraittest.php
@@ -70,9 +70,11 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
$storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig')
->disableOriginalConstructor()
->getMock();
- $storageConfig->expects($this->once())
- ->method('getBackendOptions')
- ->willReturn([]);
+ $storageConfig->expects($this->any())
+ ->method('getBackendOption')
+ ->willReturn(null);
+ $storageConfig->expects($this->any())
+ ->method('setBackendOption');
$trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait');
$trait->setText('test');
@@ -80,4 +82,35 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
$this->assertEquals($expectedSuccess, $trait->validateStorageDefinition($storageConfig));
}
+
+ public function testValidateStorageSet() {
+ $param = $this->getMockBuilder('\OCA\Files_External\Lib\DefinitionParameter')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $param->method('getName')
+ ->willReturn('param');
+ $param->expects($this->once())
+ ->method('validateValue')
+ ->will($this->returnCallback(function(&$value) {
+ $value = 'foobar';
+ return true;
+ }));
+
+ $storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $storageConfig->expects($this->once())
+ ->method('getBackendOption')
+ ->with('param')
+ ->willReturn('barfoo');
+ $storageConfig->expects($this->once())
+ ->method('setBackendOption')
+ ->with('param', 'foobar');
+
+ $trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait');
+ $trait->setText('test');
+ $trait->addParameter($param);
+
+ $this->assertEquals(true, $trait->validateStorageDefinition($storageConfig));
+ }
}
diff --git a/apps/files_external/tests/service/globalstoragesservicetest.php b/apps/files_external/tests/service/globalstoragesservicetest.php
index 05585d2c065..2bc480ca312 100644
--- a/apps/files_external/tests/service/globalstoragesservicetest.php
+++ b/apps/files_external/tests/service/globalstoragesservicetest.php
@@ -789,6 +789,13 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
file_put_contents($configFile, json_encode($json));
+ $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB')
+ ->expects($this->exactly(4))
+ ->method('validateStorageDefinition');
+ $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism')
+ ->expects($this->exactly(4))
+ ->method('validateStorageDefinition');
+
$allStorages = $this->service->getAllStorages();
$this->assertCount(4, $allStorages);