summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-02-20 16:47:59 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-02-20 16:47:59 +0100
commitec45a3c0e2567c89729bc6fe8c996b7939025429 (patch)
tree5ef1506bd10ed4b01b6cf5acf939dd1f53751237 /tests
parentbfe6dfe5daeb42723032c7ca2e526ff51326df4e (diff)
parente6df86f4cb4b28c07804cb5748cf3d0679e58b25 (diff)
downloadnextcloud-server-ec45a3c0e2567c89729bc6fe8c996b7939025429.tar.gz
nextcloud-server-ec45a3c0e2567c89729bc6fe8c996b7939025429.zip
Merge pull request #6962 from owncloud/quota-space-root
Allow passing a root folder to get the used space from in the quota wrapper
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/storage/wrapper/quota.php25
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/lib/files/storage/wrapper/quota.php b/tests/lib/files/storage/wrapper/quota.php
index e1b880255fb..43eae78415d 100644
--- a/tests/lib/files/storage/wrapper/quota.php
+++ b/tests/lib/files/storage/wrapper/quota.php
@@ -62,7 +62,7 @@ class Quota extends \Test\Files\Storage\Storage {
$this->assertEquals('foobarqwe', $instance->file_get_contents('foo'));
}
- public function testReturnFalseWhenFopenFailed(){
+ public function testReturnFalseWhenFopenFailed() {
$failStorage = $this->getMock(
'\OC\Files\Storage\Local',
array('fopen'),
@@ -76,7 +76,7 @@ class Quota extends \Test\Files\Storage\Storage {
$this->assertFalse($instance->fopen('failedfopen', 'r'));
}
- public function testReturnRegularStreamOnRead(){
+ public function testReturnRegularStreamOnRead() {
$instance = $this->getLimitedStorage(9);
// create test file first
@@ -95,11 +95,30 @@ class Quota extends \Test\Files\Storage\Storage {
fclose($stream);
}
- public function testReturnQuotaStreamOnWrite(){
+ public function testReturnQuotaStreamOnWrite() {
$instance = $this->getLimitedStorage(9);
$stream = $instance->fopen('foo', 'w+');
$meta = stream_get_meta_data($stream);
$this->assertEquals('user-space', $meta['wrapper_type']);
fclose($stream);
}
+
+ public function testSpaceRoot() {
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Local')->disableOriginalConstructor()->getMock();
+ $cache = $this->getMockBuilder('\OC\Files\Cache\Cache')->disableOriginalConstructor()->getMock();
+ $storage->expects($this->once())
+ ->method('getCache')
+ ->will($this->returnValue($cache));
+ $storage->expects($this->once())
+ ->method('free_space')
+ ->will($this->returnValue(2048));
+ $cache->expects($this->once())
+ ->method('get')
+ ->with('files')
+ ->will($this->returnValue(array('size' => 50)));
+
+ $instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 1024, 'root' => 'files'));
+
+ $this->assertEquals(1024 - 50, $instance->free_space(''));
+ }
}