summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-05-23 21:03:25 +0200
committerRoeland Jago Douma <rullzer@owncloud.com>2016-05-23 21:57:41 +0200
commitabe338f4335ad4a4f0b6211b032e48f80962292f (patch)
tree6f7fea30995d1bb02e9f677b0dd7d480aa2b96dd /tests
parente03e4921a01cd2b01e10db7b5d7bd39dd0224b0b (diff)
downloadnextcloud-server-abe338f4335ad4a4f0b6211b032e48f80962292f.tar.gz
nextcloud-server-abe338f4335ad4a4f0b6211b032e48f80962292f.zip
Store user bucket in preferences
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Mount/ObjectHomeMountProviderTest.php90
1 files changed, 82 insertions, 8 deletions
diff --git a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
index 202c2c02b98..5d987f0d059 100644
--- a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
+++ b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
@@ -61,11 +61,29 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
'class' => 'Test\Files\Mount\FakeObjectStore',
]);
- $this->user->expects($this->once())
- ->method('getUID')
+ $this->user->method('getUID')
->willReturn('uid');
$this->loader->expects($this->never())->method($this->anything());
+ $this->config->expects($this->once())
+ ->method('getUserValue')
+ ->with(
+ $this->equalTo('uid'),
+ $this->equalTo('homeobjectstore'),
+ $this->equalTo('bucket'),
+ $this->equalTo(null)
+ )->willReturn(null);
+
+ $this->config->expects($this->once())
+ ->method('setUserValue')
+ ->with(
+ $this->equalTo('uid'),
+ $this->equalTo('homeobjectstore'),
+ $this->equalTo('bucket'),
+ $this->equalTo('987'),
+ $this->equalTo(null)
+ );
+
$config = $this->invokePrivate($this->provider, 'getMultiBucketObjectStoreConfig', [$this->user, $this->loader]);
$this->assertArrayHasKey('class', $config);
@@ -90,11 +108,29 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
],
]);
- $this->user->expects($this->once())
- ->method('getUID')
+ $this->user->method('getUID')
->willReturn('uid');
$this->loader->expects($this->never())->method($this->anything());
+ $this->config->expects($this->once())
+ ->method('getUserValue')
+ ->with(
+ $this->equalTo('uid'),
+ $this->equalTo('homeobjectstore'),
+ $this->equalTo('bucket'),
+ $this->equalTo(null)
+ )->willReturn(null);
+
+ $this->config->expects($this->once())
+ ->method('setUserValue')
+ ->with(
+ $this->equalTo('uid'),
+ $this->equalTo('homeobjectstore'),
+ $this->equalTo('bucket'),
+ $this->equalTo('myBucketPrefix987'),
+ $this->equalTo(null)
+ );
+
$config = $this->invokePrivate($this->provider, 'getMultiBucketObjectStoreConfig', [$this->user, $this->loader]);
$this->assertArrayHasKey('class', $config);
@@ -108,6 +144,46 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
$this->assertEquals('myBucketPrefix987', $config['arguments']['bucket']);
}
+ public function testMultiBucketBucketAlreadySet() {
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with($this->equalTo('objectstore_multibucket'), '')
+ ->willReturn([
+ 'class' => 'Test\Files\Mount\FakeObjectStore',
+ 'arguments' => [
+ 'bucket' => 'myBucketPrefix',
+ ],
+ ]);
+
+ $this->user->method('getUID')
+ ->willReturn('uid');
+ $this->loader->expects($this->never())->method($this->anything());
+
+ $this->config->expects($this->once())
+ ->method('getUserValue')
+ ->with(
+ $this->equalTo('uid'),
+ $this->equalTo('homeobjectstore'),
+ $this->equalTo('bucket'),
+ $this->equalTo(null)
+ )->willReturn('awesomeBucket1');
+
+ $this->config->expects($this->never())
+ ->method('setUserValue');
+
+ $config = $this->invokePrivate($this->provider, 'getMultiBucketObjectStoreConfig', [$this->user, $this->loader]);
+
+ $this->assertArrayHasKey('class', $config);
+ $this->assertEquals($config['class'], 'Test\Files\Mount\FakeObjectStore');
+ $this->assertArrayHasKey('arguments', $config);
+ $this->assertArrayHasKey('user', $config['arguments']);
+ $this->assertSame($this->user, $config['arguments']['user']);
+ $this->assertArrayHasKey('objectstore', $config['arguments']);
+ $this->assertInstanceOf('Test\Files\Mount\FakeObjectStore', $config['arguments']['objectstore']);
+ $this->assertArrayHasKey('bucket', $config['arguments']);
+ $this->assertEquals('awesomeBucket1', $config['arguments']['bucket']);
+ }
+
public function testMultiBucketConfigFirst() {
$this->config->expects($this->once())
->method('getSystemValue')
@@ -116,8 +192,7 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
'class' => 'Test\Files\Mount\FakeObjectStore',
]);
- $this->user->expects($this->exactly(2))
- ->method('getUID')
+ $this->user->method('getUID')
->willReturn('uid');
$this->loader->expects($this->never())->method($this->anything());
@@ -138,8 +213,7 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
'class' => 'Test\Files\Mount\FakeObjectStore',
]);
- $this->user->expects($this->once())
- ->method('getUID')
+ $this->user->method('getUID')
->willReturn('uid');
$this->loader->expects($this->never())->method($this->anything());