summaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests/frontenddefinitiontraittest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/tests/frontenddefinitiontraittest.php')
-rw-r--r--apps/files_external/tests/frontenddefinitiontraittest.php39
1 files changed, 36 insertions, 3 deletions
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));
+ }
}