diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-01-19 18:49:51 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-01-19 18:51:36 +0100 |
commit | 1af7dab5358d7fd495e4382037c6e2528e2b76d5 (patch) | |
tree | d2d27a980780f1f4a68f3b2afc93e8c84486e986 /tests | |
parent | 903b330cccaad0233274199c9ee8f047478bb72e (diff) | |
download | nextcloud-server-1af7dab5358d7fd495e4382037c6e2528e2b76d5.tar.gz nextcloud-server-1af7dab5358d7fd495e4382037c6e2528e2b76d5.zip |
Fixed quota wrapper to not wrap failed fopen streams
When calling fopen() on some storage types, these return false instead
of throwing an exception.
This fix makes sure that in case the stream wasn't opened (for example
when a file doesn't exist any more) the stream isn't wrapped.
Also added 'rb' as another case that doesn't need to be wrapped.
Fixes #6832
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/storage/wrapper/quota.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/lib/files/storage/wrapper/quota.php b/tests/lib/files/storage/wrapper/quota.php index 9b14335782f..87bafb64d41 100644 --- a/tests/lib/files/storage/wrapper/quota.php +++ b/tests/lib/files/storage/wrapper/quota.php @@ -59,6 +59,20 @@ class Quota extends \Test\Files\Storage\Storage { $this->assertEquals('foobarqwe', $instance->file_get_contents('foo')); } + public function testReturnFalseWhenFopenFailed(){ + $failStorage = $this->getMock( + '\OC\Files\Storage\Local', + array('fopen'), + array(array('datadir' => $this->tmpDir))); + $failStorage->expects($this->any()) + ->method('fopen') + ->will($this->returnValue(false)); + + $instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $failStorage, 'quota' => 1000)); + + $this->assertFalse($instance->fopen('failedfopen', 'r')); + } + public function testReturnRegularStreamOnRead(){ $instance = $this->getLimitedStorage(9); @@ -71,6 +85,11 @@ class Quota extends \Test\Files\Storage\Storage { $meta = stream_get_meta_data($stream); $this->assertEquals('plainfile', $meta['wrapper_type']); fclose($stream); + + $stream = $instance->fopen('foo', 'rb'); + $meta = stream_get_meta_data($stream); + $this->assertEquals('plainfile', $meta['wrapper_type']); + fclose($stream); } public function testReturnQuotaStreamOnWrite(){ |