Add unit test for quote wrapper size root

remotes/origin/ldap_group_count
Robin Appelman 11 years ago
parent 20c2aaab00
commit 3afdcd85e7
  1. 25
      tests/lib/files/storage/wrapper/quota.php

@ -59,7 +59,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'),
@ -73,7 +73,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
@ -92,11 +92,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(''));
}
}

Loading…
Cancel
Save